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
trondhindenes/ansible-modules-extras
packaging/os/slackpkg.py
131
6382
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2014, Kim Nørgaard # Written by Kim Nørgaard <jasen@jasen.dk> # Based on pkgng module written by bleader <bleader@ratonland.org> # that was based on pkgin module written by Shaun Zinck <shaun.zinck at gmail.com> # that was based on pacman module written by Afterburn <http://github.com/afterburn> # that was based on apt module written by Matthew Williams <matthew@flowroute.com> # # This module 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 software 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 software. If not, see <http://www.gnu.org/licenses/>. DOCUMENTATION = ''' --- module: slackpkg short_description: Package manager for Slackware >= 12.2 description: - Manage binary packages for Slackware using 'slackpkg' which is available in versions after 12.2. version_added: "2.0" options: name: description: - name of package to install/remove required: true state: description: - state of the package, you can use "installed" as an alias for C(present) and removed as one for c(absent). choices: [ 'present', 'absent', 'latest' ] required: false default: present update_cache: description: - update the package database first required: false default: false choices: [ true, false ] author: Kim Nørgaard (@KimNorgaard) requirements: [ "Slackware >= 12.2" ] ''' EXAMPLES = ''' # Install package foo - slackpkg: name=foo state=present # Remove packages foo and bar - slackpkg: name=foo,bar state=absent # Make sure that it is the most updated package - slackpkg: name=foo state=latest ''' def query_package(module, slackpkg_path, name): import glob import platform machine = platform.machine() packages = glob.glob("/var/log/packages/%s-*-[%s|noarch]*" % (name, machine)) if len(packages) > 0: return True return False def remove_packages(module, slackpkg_path, packages): remove_c = 0 # Using a for loop incase of error, we can report the package that failed for package in packages: # Query the package first, to see if we even need to remove if not query_package(module, slackpkg_path, package): continue if not module.check_mode: rc, out, err = module.run_command("%s -default_answer=y -batch=on \ remove %s" % (slackpkg_path, package)) if not module.check_mode and query_package(module, slackpkg_path, package): module.fail_json(msg="failed to remove %s: %s" % (package, out)) remove_c += 1 if remove_c > 0: module.exit_json(changed=True, msg="removed %s package(s)" % remove_c) module.exit_json(changed=False, msg="package(s) already absent") def install_packages(module, slackpkg_path, packages): install_c = 0 for package in packages: if query_package(module, slackpkg_path, package): continue if not module.check_mode: rc, out, err = module.run_command("%s -default_answer=y -batch=on \ install %s" % (slackpkg_path, package)) if not module.check_mode and not query_package(module, slackpkg_path, package): module.fail_json(msg="failed to install %s: %s" % (package, out), stderr=err) install_c += 1 if install_c > 0: module.exit_json(changed=True, msg="present %s package(s)" % (install_c)) module.exit_json(changed=False, msg="package(s) already present") def upgrade_packages(module, slackpkg_path, packages): install_c = 0 for package in packages: if not module.check_mode: rc, out, err = module.run_command("%s -default_answer=y -batch=on \ upgrade %s" % (slackpkg_path, package)) if not module.check_mode and not query_package(module, slackpkg_path, package): module.fail_json(msg="failed to install %s: %s" % (package, out), stderr=err) install_c += 1 if install_c > 0: module.exit_json(changed=True, msg="present %s package(s)" % (install_c)) module.exit_json(changed=False, msg="package(s) already present") def update_cache(module, slackpkg_path): rc, out, err = module.run_command("%s -batch=on update" % (slackpkg_path)) if rc != 0: module.fail_json(msg="Could not update package cache") def main(): module = AnsibleModule( argument_spec=dict( state=dict(default="installed", choices=['installed', 'removed', 'absent', 'present', 'latest']), name=dict(aliases=["pkg"], required=True, type='list'), update_cache=dict(default=False, aliases=["update-cache"], type='bool'), ), supports_check_mode=True) slackpkg_path = module.get_bin_path('slackpkg', True) p = module.params pkgs = p['name'] if p["update_cache"]: update_cache(module, slackpkg_path) if p['state'] == 'latest': upgrade_packages(module, slackpkg_path, pkgs) elif p['state'] in ['present', 'installed']: install_packages(module, slackpkg_path, pkgs) elif p["state"] in ['removed', 'absent']: remove_packages(module, slackpkg_path, pkgs) # import module snippets from ansible.module_utils.basic import * main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6927, 12, 1804, 1017, 653, 31087, 82, 5294, 1005, 199, 3, 27694, 701, 1804, 1017, 653, 31087, 82, 5294, 1005, 665, 74, 482, 78, 32, 74, 482, 78, 14, 6341, 30, 199, 3, 21311, 641, 3803, 784, 71, 859, 5313, 701, 330, 18498, 665, 830, 669, 32, 17565, 265, 9688, 14, 1308, 30, 199, 3, 626, 1990, 4079, 641, 3803, 903, 859, 5313, 701, 428, 2411, 324, 3107, 262, 346, 665, 4835, 324, 14, 90, 262, 346, 737, 29712, 14, 957, 30, 199, 3, 626, 1990, 4079, 641, 299, 645, 1237, 859, 5313, 701, 12836, 30736, 665, 1014, 921, 5031, 14, 957, 15, 4399, 30736, 30, 199, 3, 626, 1990, 4079, 641, 20932, 859, 5313, 701, 18619, 29640, 644, 8148, 19470, 665, 569, 29640, 32, 1659, 4449, 14, 957, 30, 199, 3, 199, 3, 961, 859, 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, 2032, 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, 2032, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 29877, 4600, 199, 3612, 63, 1802, 26, 15665, 5256, 367, 428, 5143, 1068, 2356, 3144, 14, 18, 199, 1802, 26, 272, 446, 14944, 3366, 6117, 367, 428, 5143, 1068, 1808, 283, 24567, 4600, 7, 1314, 489, 365, 2808, 315, 5459, 2410, 3144, 14, 18, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 536, 402, 2559, 370, 3907, 15, 2168, 267, 1415, 26, 2549, 339, 1174, 26, 267, 1369, 26, 288, 446, 1174, 402, 314, 2559, 12, 1265, 883, 675, 298, 7657, 2, 465, 376, 5162, 367, 445, 8, 1881, 9, 436, 4829, 465, 1373, 367, 286, 8, 5575, 680, 267, 3415, 26, 359, 283, 1881, 297, 283, 5575, 297, 283, 7410, 7, 1622, 267, 1415, 26, 3055, 267, 849, 26, 3451, 339, 1678, 63, 1637, 26, 267, 1369, 26, 288, 446, 1678, 314, 2559, 3050, 1642, 267, 1415, 26, 3055, 267, 849, 26, 3055, 267, 3415, 26, 359, 2549, 12, 3055, 1622, 199, 199, 2502, 26, 1804, 1017, 653, 31087, 82, 5294, 1005, 8593, 43, 1017, 46, 1308, 65, 1005, 9, 199, 7538, 26, 359, 298, 51, 5143, 1068, 2356, 3144, 14, 18, 2, 1622, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 13276, 2559, 3925, 199, 13, 29877, 4600, 26, 536, 29, 1421, 1174, 29, 1881, 199, 199, 3, 5852, 6117, 3925, 436, 4681, 199, 13, 29877, 4600, 26, 536, 29, 1421, 12, 1700, 1174, 29, 5575, 199, 199, 3, 4155, 3238, 626, 652, 365, 314, 4750, 4588, 2559, 199, 13, 29877, 4600, 26, 536, 29, 1421, 1174, 29, 7410, 199, 199, 2344, 421, 199, 318, 1827, 63, 2491, 8, 578, 12, 29877, 4600, 63, 515, 12, 536, 304, 339, 492, 5739, 272, 492, 4298, 339, 6844, 275, 4298, 14, 6744, 342, 272, 6117, 275, 5739, 14, 6463, 4769, 1391, 15, 793, 15, 5154, 3149, 83, 13, 1837, 9722, 83, 92, 889, 1047, 3672, 2, 450, 334, 354, 12, 25404, 6844, 430, 339, 340, 822, 8, 5154, 9, 690, 378, 26, 267, 372, 715, 339, 372, 756, 421, 199, 318, 2813, 63, 5154, 8, 578, 12, 29877, 4600, 63, 515, 12, 6117, 304, 339, 2813, 63, 67, 275, 378, 272, 327, 11719, 282, 367, 4438, 315, 2546, 402, 1125, 12, 781, 883, 3622, 314, 2559, 626, 3405, 272, 367, 2559, 315, 6117, 26, 267, 327, 8133, 314, 2559, 1642, 12, 370, 1937, 340, 781, 2755, 1929, 370, 2813, 267, 340, 440, 1827, 63, 2491, 8, 578, 12, 29877, 4600, 63, 515, 12, 2559, 304, 288, 1980, 398, 340, 440, 859, 14, 1074, 63, 632, 26, 288, 4819, 12, 734, 12, 2329, 275, 859, 14, 1065, 63, 1531, 3647, 83, 446, 885, 63, 5934, 29, 89, 446, 2912, 29, 265, 971, 6343, 2813, 450, 83, 2, 450, 334, 24567, 4600, 63, 515, 12, 6343, 2559, 430, 398, 340, 440, 859, 14, 1074, 63, 632, 436, 1827, 63, 2491, 8, 578, 12, 29877, 4600, 63, 515, 12, 8962, 2559, 304, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 4892, 370, 2813, 450, 83, 26, 450, 83, 2, 450, 334, 2491, 12, 734, 430, 398, 2813, 63, 67, 847, 413, 339, 340, 2813, 63, 67, 690, 378, 26, 398, 859, 14, 2224, 63, 1001, 8, 2489, 29, 549, 12, 1499, 628, 10649, 450, 83, 2559, 8, 83, 2924, 450, 2813, 63, 67, 9, 339, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 1499, 628, 2491, 8, 83, 9, 2575, 9552, 531, 421, 199, 318, 3907, 63, 5154, 8, 578, 12, 29877, 4600, 63, 515, 12, 6117, 304, 339, 3907, 63, 67, 275, 378, 339, 367, 2559, 315, 6117, 26, 267, 340, 1827, 63, 2491, 8, 578, 12, 29877, 4600, 63, 515, 12, 2559, 304, 288, 1980, 398, 340, 440, 859, 14, 1074, 63, 632, 26, 288, 4819, 12, 734, 12, 2329, 275, 859, 14, 1065, 63, 1531, 3647, 83, 446, 885, 63, 5934, 29, 89, 446, 2912, 29, 265, 971, 6343, 3907, 450, 83, 2, 450, 334, 24567, 4600, 63, 515, 12, 6343, 2559, 430, 398, 340, 440, 859, 14, 1074, 63, 632, 436, 440, 1827, 63, 2491, 8, 578, 12, 29877, 4600, 63, 515, 12, 10940, 2559, 304, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 4892, 370, 3907, 450, 83, 26, 450, 83 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6927, 12, 1804, 1017, 653, 31087, 82, 5294, 1005, 199, 3, 27694, 701, 1804, 1017, 653, 31087, 82, 5294, 1005, 665, 74, 482, 78, 32, 74, 482, 78, 14, 6341, 30, 199, 3, 21311, 641, 3803, 784, 71, 859, 5313, 701, 330, 18498, 665, 830, 669, 32, 17565, 265, 9688, 14, 1308, 30, 199, 3, 626, 1990, 4079, 641, 3803, 903, 859, 5313, 701, 428, 2411, 324, 3107, 262, 346, 665, 4835, 324, 14, 90, 262, 346, 737, 29712, 14, 957, 30, 199, 3, 626, 1990, 4079, 641, 299, 645, 1237, 859, 5313, 701, 12836, 30736, 665, 1014, 921, 5031, 14, 957, 15, 4399, 30736, 30, 199, 3, 626, 1990, 4079, 641, 20932, 859, 5313, 701, 18619, 29640, 644, 8148, 19470, 665, 569, 29640, 32, 1659, 4449, 14, 957, 30, 199, 3, 199, 3, 961, 859, 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, 2032, 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, 2032, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 29877, 4600, 199, 3612, 63, 1802, 26, 15665, 5256, 367, 428, 5143, 1068, 2356, 3144, 14, 18, 199, 1802, 26, 272, 446, 14944, 3366, 6117, 367, 428, 5143, 1068, 1808, 283, 24567, 4600, 7, 1314, 489, 365, 2808, 315, 5459, 2410, 3144, 14, 18, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 536, 402, 2559, 370, 3907, 15, 2168, 267, 1415, 26, 2549, 339, 1174, 26, 267, 1369, 26, 288, 446, 1174, 402, 314, 2559, 12, 1265, 883, 675, 298, 7657, 2, 465, 376, 5162, 367, 445, 8, 1881, 9, 436, 4829, 465, 1373, 367, 286, 8, 5575, 680, 267, 3415, 26, 359, 283, 1881, 297, 283, 5575, 297, 283, 7410, 7, 1622, 267, 1415, 26, 3055, 267, 849, 26, 3451, 339, 1678, 63, 1637, 26, 267, 1369, 26, 288, 446, 1678, 314, 2559, 3050, 1642, 267, 1415, 26, 3055, 267, 849, 26, 3055, 267, 3415, 26, 359, 2549, 12, 3055, 1622, 199, 199, 2502, 26, 1804, 1017, 653, 31087, 82, 5294, 1005, 8593, 43, 1017, 46, 1308, 65, 1005, 9, 199, 7538, 26, 359, 298, 51, 5143, 1068, 2356, 3144, 14, 18, 2, 1622, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 13276, 2559, 3925, 199, 13, 29877, 4600, 26, 536, 29, 1421, 1174, 29, 1881, 199, 199, 3, 5852, 6117, 3925, 436, 4681, 199, 13, 29877, 4600, 26, 536, 29, 1421, 12, 1700, 1174, 29, 5575, 199, 199, 3, 4155, 3238, 626, 652, 365, 314, 4750, 4588, 2559, 199, 13, 29877, 4600, 26, 536, 29, 1421, 1174, 29, 7410, 199, 199, 2344, 421, 199, 318, 1827, 63, 2491, 8, 578, 12, 29877, 4600, 63, 515, 12, 536, 304, 339, 492, 5739, 272, 492, 4298, 339, 6844, 275, 4298, 14, 6744, 342, 272, 6117, 275, 5739, 14, 6463, 4769, 1391, 15, 793, 15, 5154, 3149, 83, 13, 1837, 9722, 83, 92, 889, 1047, 3672, 2, 450, 334, 354, 12, 25404, 6844, 430, 339, 340, 822, 8, 5154, 9, 690, 378, 26, 267, 372, 715, 339, 372, 756, 421, 199, 318, 2813, 63, 5154, 8, 578, 12, 29877, 4600, 63, 515, 12, 6117, 304, 339, 2813, 63, 67, 275, 378, 272, 327, 11719, 282, 367, 4438, 315, 2546, 402, 1125, 12, 781, 883, 3622, 314, 2559, 626, 3405, 272, 367, 2559, 315, 6117, 26, 267, 327, 8133, 314, 2559, 1642, 12, 370, 1937, 340, 781, 2755, 1929, 370, 2813, 267, 340, 440, 1827, 63, 2491, 8, 578, 12, 29877, 4600, 63, 515, 12, 2559, 304, 288, 1980, 398, 340, 440, 859, 14, 1074, 63, 632, 26, 288, 4819, 12, 734, 12, 2329, 275, 859, 14, 1065, 63, 1531, 3647, 83, 446, 885, 63, 5934, 29, 89, 446, 2912, 29, 265, 971, 6343, 2813, 450, 83, 2, 450, 334, 24567, 4600, 63, 515, 12, 6343, 2559, 430, 398, 340, 440, 859, 14, 1074, 63, 632, 436, 1827, 63, 2491, 8, 578, 12, 29877, 4600, 63, 515, 12, 8962, 2559, 304, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 4892, 370, 2813, 450, 83, 26, 450, 83, 2, 450, 334, 2491, 12, 734, 430, 398, 2813, 63, 67, 847, 413, 339, 340, 2813, 63, 67, 690, 378, 26, 398, 859, 14, 2224, 63, 1001, 8, 2489, 29, 549, 12, 1499, 628, 10649, 450, 83, 2559, 8, 83, 2924, 450, 2813, 63, 67, 9, 339, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 1499, 628, 2491, 8, 83, 9, 2575, 9552, 531, 421, 199, 318, 3907, 63, 5154, 8, 578, 12, 29877, 4600, 63, 515, 12, 6117, 304, 339, 3907, 63, 67, 275, 378, 339, 367, 2559, 315, 6117, 26, 267, 340, 1827, 63, 2491, 8, 578, 12, 29877, 4600, 63, 515, 12, 2559, 304, 288, 1980, 398, 340, 440, 859, 14, 1074, 63, 632, 26, 288, 4819, 12, 734, 12, 2329, 275, 859, 14, 1065, 63, 1531, 3647, 83, 446, 885, 63, 5934, 29, 89, 446, 2912, 29, 265, 971, 6343, 3907, 450, 83, 2, 450, 334, 24567, 4600, 63, 515, 12, 6343, 2559, 430, 398, 340, 440, 859, 14, 1074, 63, 632, 436, 440, 1827, 63, 2491, 8, 578, 12, 29877, 4600, 63, 515, 12, 10940, 2559, 304, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 4892, 370, 3907, 450, 83, 26, 450, 83, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
aldryn/heroku-buildpack-python
vendor/setuptools-1.1/setuptools/command/alias.py
285
2486
import distutils, os from setuptools import Command from distutils.util import convert_path from distutils import log from distutils.errors import * from setuptools.command.setopt import edit_config, option_base, config_file def shquote(arg): """Quote an argument for later parsing by shlex.split()""" for c in '"', "'", "\\", "#": if c in arg: return repr(arg) if arg.split() != [arg]: return repr(arg) return arg class alias(option_base): """Define a shortcut that invokes one or more commands""" description = "define a shortcut to invoke one or more commands" command_consumes_arguments = True user_options = [ ('remove', 'r', 'remove (unset) the alias'), ] + option_base.user_options boolean_options = option_base.boolean_options + ['remove'] def initialize_options(self): option_base.initialize_options(self) self.args = None self.remove = None def finalize_options(self): option_base.finalize_options(self) if self.remove and len(self.args) != 1: raise DistutilsOptionError( "Must specify exactly one argument (the alias name) when " "using --remove" ) def run(self): aliases = self.distribution.get_option_dict('aliases') if not self.args: print("Command Aliases") print("---------------") for alias in aliases: print("setup.py alias", format_alias(alias, aliases)) return elif len(self.args)==1: alias, = self.args if self.remove: command = None elif alias in aliases: print("setup.py alias", format_alias(alias, aliases)) return else: print("No alias definition found for %r" % alias) return else: alias = self.args[0] command = ' '.join(map(shquote,self.args[1:])) edit_config(self.filename, {'aliases': {alias:command}}, self.dry_run) def format_alias(name, aliases): source, command = aliases[name] if source == config_file('global'): source = '--global-config ' elif source == config_file('user'): source = '--user-config ' elif source == config_file('local'): source = '' else: source = '--filename=%r' % source return source+name+' '+command
mit
[ 646, 7065, 12, 747, 199, 504, 9116, 492, 5817, 199, 504, 7065, 14, 1974, 492, 3957, 63, 515, 199, 504, 7065, 492, 943, 199, 504, 7065, 14, 2550, 492, 627, 199, 504, 9116, 14, 1531, 14, 29852, 492, 5283, 63, 888, 12, 945, 63, 1095, 12, 1101, 63, 493, 199, 199, 318, 1033, 3513, 8, 1273, 304, 272, 408, 12838, 376, 1423, 367, 2945, 6057, 701, 16701, 14, 1294, 32664, 272, 367, 286, 315, 32089, 3546, 401, 9926, 401, 5426, 582, 267, 340, 286, 315, 1680, 26, 372, 4700, 8, 1273, 9, 272, 340, 1680, 14, 1294, 342, 1137, 359, 1273, 2189, 267, 372, 4700, 8, 1273, 9, 272, 372, 1680, 260, 421, 199, 533, 5162, 8, 1422, 63, 1095, 304, 272, 408, 16213, 282, 17522, 626, 29761, 1373, 503, 1655, 3718, 624, 2286, 1369, 275, 298, 4640, 282, 17522, 370, 12677, 1373, 503, 1655, 3718, 2, 272, 1414, 63, 10235, 83, 63, 4958, 275, 715, 339, 922, 63, 1419, 275, 359, 267, 661, 2168, 297, 257, 283, 82, 297, 283, 2168, 334, 16787, 9, 314, 5162, 659, 5591, 1622, 435, 945, 63, 1095, 14, 751, 63, 1419, 339, 5046, 63, 1419, 275, 945, 63, 1095, 14, 4871, 63, 1419, 435, 788, 2168, 418, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 945, 63, 1095, 14, 8489, 63, 1419, 8, 277, 9, 267, 291, 14, 589, 275, 488, 267, 291, 14, 2168, 275, 488, 339, 347, 17284, 63, 1419, 8, 277, 304, 267, 945, 63, 1095, 14, 14450, 63, 1419, 8, 277, 9, 267, 340, 291, 14, 2168, 436, 822, 8, 277, 14, 589, 9, 1137, 413, 26, 288, 746, 31484, 8, 355, 298, 13757, 4165, 8840, 1373, 1423, 334, 1589, 5162, 536, 9, 1380, 298, 355, 298, 4941, 1553, 2168, 2, 288, 776, 339, 347, 1255, 8, 277, 304, 267, 5481, 275, 291, 14, 4972, 14, 362, 63, 1422, 63, 807, 360, 8602, 358, 398, 340, 440, 291, 14, 589, 26, 288, 870, 480, 3110, 15170, 3274, 531, 288, 870, 480, 18964, 531, 288, 367, 5162, 315, 5481, 26, 355, 870, 480, 2758, 14, 647, 5162, 401, 1475, 63, 3620, 8, 3620, 12, 5481, 430, 288, 372, 398, 916, 822, 8, 277, 14, 589, 12694, 17, 26, 288, 5162, 12, 275, 291, 14, 589, 288, 340, 291, 14, 2168, 26, 355, 1414, 275, 488, 288, 916, 5162, 315, 5481, 26, 355, 870, 480, 2758, 14, 647, 5162, 401, 1475, 63, 3620, 8, 3620, 12, 5481, 430, 355, 372, 288, 587, 26, 355, 870, 480, 1944, 5162, 5492, 1911, 367, 450, 82, 2, 450, 5162, 9, 355, 372, 267, 587, 26, 288, 5162, 275, 291, 14, 589, 59, 16, 61, 288, 1414, 275, 283, 1987, 904, 8, 1130, 8, 609, 3513, 12, 277, 14, 589, 59, 17, 16720, 398, 5283, 63, 888, 8, 277, 14, 1501, 12, 791, 8602, 356, 469, 3620, 26, 1531, 13459, 291, 14, 10481, 63, 1065, 9, 421, 199, 318, 1475, 63, 3620, 8, 354, 12, 5481, 304, 272, 1350, 12, 1414, 275, 5481, 59, 354, 61, 272, 340, 1350, 508, 1101, 63, 493, 360, 2966, 735, 267, 1350, 275, 2850, 2966, 13, 888, 283, 272, 916, 1350, 508, 1101, 63, 493, 360, 751, 735, 267, 1350, 275, 2850, 751, 13, 888, 283, 272, 916, 1350, 508, 1101, 63, 493, 360, 1832, 735, 267, 1350, 275, 2125, 272, 587, 26, 267, 1350, 275, 2850, 1501, 2458, 82, 7, 450, 1350, 272, 372, 1350, 11, 354, 4786, 6681, 1531, 1467, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 7065, 12, 747, 199, 504, 9116, 492, 5817, 199, 504, 7065, 14, 1974, 492, 3957, 63, 515, 199, 504, 7065, 492, 943, 199, 504, 7065, 14, 2550, 492, 627, 199, 504, 9116, 14, 1531, 14, 29852, 492, 5283, 63, 888, 12, 945, 63, 1095, 12, 1101, 63, 493, 199, 199, 318, 1033, 3513, 8, 1273, 304, 272, 408, 12838, 376, 1423, 367, 2945, 6057, 701, 16701, 14, 1294, 32664, 272, 367, 286, 315, 32089, 3546, 401, 9926, 401, 5426, 582, 267, 340, 286, 315, 1680, 26, 372, 4700, 8, 1273, 9, 272, 340, 1680, 14, 1294, 342, 1137, 359, 1273, 2189, 267, 372, 4700, 8, 1273, 9, 272, 372, 1680, 260, 421, 199, 533, 5162, 8, 1422, 63, 1095, 304, 272, 408, 16213, 282, 17522, 626, 29761, 1373, 503, 1655, 3718, 624, 2286, 1369, 275, 298, 4640, 282, 17522, 370, 12677, 1373, 503, 1655, 3718, 2, 272, 1414, 63, 10235, 83, 63, 4958, 275, 715, 339, 922, 63, 1419, 275, 359, 267, 661, 2168, 297, 257, 283, 82, 297, 283, 2168, 334, 16787, 9, 314, 5162, 659, 5591, 1622, 435, 945, 63, 1095, 14, 751, 63, 1419, 339, 5046, 63, 1419, 275, 945, 63, 1095, 14, 4871, 63, 1419, 435, 788, 2168, 418, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 945, 63, 1095, 14, 8489, 63, 1419, 8, 277, 9, 267, 291, 14, 589, 275, 488, 267, 291, 14, 2168, 275, 488, 339, 347, 17284, 63, 1419, 8, 277, 304, 267, 945, 63, 1095, 14, 14450, 63, 1419, 8, 277, 9, 267, 340, 291, 14, 2168, 436, 822, 8, 277, 14, 589, 9, 1137, 413, 26, 288, 746, 31484, 8, 355, 298, 13757, 4165, 8840, 1373, 1423, 334, 1589, 5162, 536, 9, 1380, 298, 355, 298, 4941, 1553, 2168, 2, 288, 776, 339, 347, 1255, 8, 277, 304, 267, 5481, 275, 291, 14, 4972, 14, 362, 63, 1422, 63, 807, 360, 8602, 358, 398, 340, 440, 291, 14, 589, 26, 288, 870, 480, 3110, 15170, 3274, 531, 288, 870, 480, 18964, 531, 288, 367, 5162, 315, 5481, 26, 355, 870, 480, 2758, 14, 647, 5162, 401, 1475, 63, 3620, 8, 3620, 12, 5481, 430, 288, 372, 398, 916, 822, 8, 277, 14, 589, 12694, 17, 26, 288, 5162, 12, 275, 291, 14, 589, 288, 340, 291, 14, 2168, 26, 355, 1414, 275, 488, 288, 916, 5162, 315, 5481, 26, 355, 870, 480, 2758, 14, 647, 5162, 401, 1475, 63, 3620, 8, 3620, 12, 5481, 430, 355, 372, 288, 587, 26, 355, 870, 480, 1944, 5162, 5492, 1911, 367, 450, 82, 2, 450, 5162, 9, 355, 372, 267, 587, 26, 288, 5162, 275, 291, 14, 589, 59, 16, 61, 288, 1414, 275, 283, 1987, 904, 8, 1130, 8, 609, 3513, 12, 277, 14, 589, 59, 17, 16720, 398, 5283, 63, 888, 8, 277, 14, 1501, 12, 791, 8602, 356, 469, 3620, 26, 1531, 13459, 291, 14, 10481, 63, 1065, 9, 421, 199, 318, 1475, 63, 3620, 8, 354, 12, 5481, 304, 272, 1350, 12, 1414, 275, 5481, 59, 354, 61, 272, 340, 1350, 508, 1101, 63, 493, 360, 2966, 735, 267, 1350, 275, 2850, 2966, 13, 888, 283, 272, 916, 1350, 508, 1101, 63, 493, 360, 751, 735, 267, 1350, 275, 2850, 751, 13, 888, 283, 272, 916, 1350, 508, 1101, 63, 493, 360, 1832, 735, 267, 1350, 275, 2125, 272, 587, 26, 267, 1350, 275, 2850, 1501, 2458, 82, 7, 450, 1350, 272, 372, 1350, 11, 354, 4786, 6681, 1531, 1467, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
Dhivyap/ansible
test/units/modules/network/nxos/test_nxos_interface_ospf.py
25
7234
# (c) 2016 Red Hat Inc. # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type from units.compat.mock import patch from ansible.modules.network.nxos import nxos_interface_ospf from .nxos_module import TestNxosModule, load_fixture, set_module_args class TestNxosInterfaceOspfModule(TestNxosModule): module = nxos_interface_ospf def setUp(self): super(TestNxosInterfaceOspfModule, self).setUp() self.mock_get_config = patch('ansible.modules.network.nxos.nxos_interface_ospf.get_config') self.get_config = self.mock_get_config.start() self.mock_load_config = patch('ansible.modules.network.nxos.nxos_interface_ospf.load_config') self.load_config = self.mock_load_config.start() def tearDown(self): super(TestNxosInterfaceOspfModule, self).tearDown() self.mock_get_config.stop() self.mock_load_config.stop() def load_fixtures(self, commands=None, device=''): module_name = self.module.__name__.rsplit('.', 1)[1] self.get_config.return_value = load_fixture(module_name, 'config.cfg') self.load_config.return_value = None def test_nxos_interface_ospf(self): set_module_args(dict(interface='ethernet1/32', ospf=1, area=1)) self.execute_module(changed=True, commands=['interface Ethernet1/32', 'ip router ospf 1 area 0.0.0.1']) def test_bfd_1(self): # default -> enable set_module_args(dict(interface='ethernet1/33', ospf=1, area=1, bfd='enable')) self.execute_module(changed=True, commands=['interface Ethernet1/33', 'ip router ospf 1 area 0.0.0.1', 'ip ospf bfd']) # default -> disable set_module_args(dict(interface='ethernet1/33', ospf=1, area=1, bfd='disable')) self.execute_module(changed=True, commands=['interface Ethernet1/33', 'ip router ospf 1 area 0.0.0.1', 'ip ospf bfd disable']) def test_bfd_2(self): # default -> default set_module_args(dict(interface='ethernet1/33.101', ospf=1, area=1, bfd='default')) self.execute_module(changed=False) # enable -> default set_module_args(dict(interface='ethernet1/36', ospf=1, area=1, bfd='default')) self.execute_module(changed=True, commands=['interface Ethernet1/36', 'no ip ospf bfd']) # disable -> default set_module_args(dict(interface='ethernet1/37', ospf=1, area=1, bfd='default')) self.execute_module(changed=True, commands=['interface Ethernet1/37', 'no ip ospf bfd']) def test_bfd_3(self): # enable -> idempotence set_module_args(dict(interface='ethernet1/36', ospf=1, area=1, bfd='enable')) self.execute_module(changed=False) # disable -> idempotence set_module_args(dict(interface='ethernet1/37', ospf=1, area=1, bfd='disable')) self.execute_module(changed=False) def test_bfd_4(self): # None -> absent set_module_args(dict(interface='ethernet1/33.101', ospf=1, area=1, state='absent')) self.execute_module(changed=True, commands=['interface Ethernet1/33.101', 'no ip router ospf 1 area 0.0.0.1']) # enable -> absent set_module_args(dict(interface='ethernet1/36', ospf=1, area=1, bfd='enable', state='absent')) self.execute_module(changed=True, commands=['interface Ethernet1/36', 'no ip router ospf 1 area 0.0.0.1', 'no ip ospf bfd']) # disable -> absent set_module_args(dict(interface='ethernet1/37', ospf=1, area=1, bfd='disable', state='absent')) self.execute_module(changed=True, commands=['interface Ethernet1/37', 'no ip router ospf 1 area 0.0.0.1', 'no ip ospf bfd']) def test_absent_1(self): # area only -> absent set_module_args(dict(interface='ethernet1/33.101', ospf=1, area=1, state='absent')) self.execute_module(changed=True, commands=['interface Ethernet1/33.101', 'no ip router ospf 1 area 0.0.0.1']) # None -> absent set_module_args(dict(interface='ethernet1/33', ospf=1, area=1, state='absent')) self.execute_module(changed=False) def test_loopback_interface_failed(self): set_module_args(dict(interface='loopback0', ospf=1, area=0, passive_interface=True)) self.execute_module(failed=True, changed=False) set_module_args(dict(interface='loopback0', ospf=1, area=0, network='broadcast')) self.execute_module(failed=True, changed=False) def test_nxos_interface_ospf_passive(self): # default -> True set_module_args(dict(interface='ethernet1/33', ospf=1, area=1, passive_interface=True)) self.execute_module(changed=True, commands=['interface Ethernet1/33', 'ip router ospf 1 area 0.0.0.1', 'ip ospf passive-interface']) # default -> False set_module_args(dict(interface='ethernet1/33', ospf=1, area=1, passive_interface=False)) self.execute_module(changed=True, commands=['interface Ethernet1/33', 'ip router ospf 1 area 0.0.0.1', 'no ip ospf passive-interface']) # True -> False set_module_args(dict(interface='ethernet1/34', ospf=1, area=1, passive_interface=False)) self.execute_module(changed=True, commands=['interface Ethernet1/34', 'no ip ospf passive-interface']) # True -> default (absent) set_module_args(dict(interface='ethernet1/34', ospf=1, area=1, state='absent')) self.execute_module(changed=True, commands=['interface Ethernet1/34', 'no ip router ospf 1 area 0.0.0.1', 'default ip ospf passive-interface']) # False -> True set_module_args(dict(interface='ethernet1/35', ospf=1, area=1, passive_interface=True)) self.execute_module(changed=True, commands=['interface Ethernet1/35', 'ip ospf passive-interface']) # False -> default (absent) set_module_args(dict(interface='ethernet1/35', ospf=1, area=1, state='absent')) self.execute_module(changed=True, commands=['interface Ethernet1/35', 'no ip router ospf 1 area 0.0.0.1', 'default ip ospf passive-interface'])
gpl-3.0
[ 3, 334, 67, 9, 7800, 9572, 13002, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 6204, 14, 5819, 14, 1805, 492, 3371, 199, 504, 3242, 14, 3112, 14, 1200, 14, 17982, 492, 22072, 63, 3266, 63, 18303, 199, 504, 1275, 17982, 63, 578, 492, 1379, 46, 22101, 2377, 12, 2248, 63, 5997, 12, 663, 63, 578, 63, 589, 421, 199, 533, 1379, 46, 22101, 4267, 47, 12704, 2377, 8, 774, 46, 22101, 2377, 304, 339, 859, 275, 22072, 63, 3266, 63, 18303, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 46, 22101, 4267, 47, 12704, 2377, 12, 291, 680, 5996, 342, 398, 291, 14, 1805, 63, 362, 63, 888, 275, 3371, 360, 4853, 14, 3112, 14, 1200, 14, 17982, 14, 17982, 63, 3266, 63, 18303, 14, 362, 63, 888, 358, 267, 291, 14, 362, 63, 888, 275, 291, 14, 1805, 63, 362, 63, 888, 14, 928, 342, 398, 291, 14, 1805, 63, 912, 63, 888, 275, 3371, 360, 4853, 14, 3112, 14, 1200, 14, 17982, 14, 17982, 63, 3266, 63, 18303, 14, 912, 63, 888, 358, 267, 291, 14, 912, 63, 888, 275, 291, 14, 1805, 63, 912, 63, 888, 14, 928, 342, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 774, 46, 22101, 4267, 47, 12704, 2377, 12, 291, 680, 12336, 342, 267, 291, 14, 1805, 63, 362, 63, 888, 14, 2379, 342, 267, 291, 14, 1805, 63, 912, 63, 888, 14, 2379, 342, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 12, 2243, 9280, 267, 859, 63, 354, 275, 291, 14, 578, 855, 354, 4343, 13490, 14078, 413, 2788, 17, 61, 267, 291, 14, 362, 63, 888, 14, 1107, 63, 585, 275, 2248, 63, 5997, 8, 578, 63, 354, 12, 283, 888, 14, 4128, 358, 267, 291, 14, 912, 63, 888, 14, 1107, 63, 585, 275, 488, 339, 347, 511, 63, 17982, 63, 3266, 63, 18303, 8, 277, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 708, 297, 26494, 29, 17, 12, 9150, 29, 17, 430, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 3718, 2968, 3266, 26125, 17, 15, 708, 297, 283, 711, 6197, 26494, 413, 9150, 378, 14, 16, 14, 16, 14, 17, 1105, 339, 347, 511, 63, 21090, 63, 17, 8, 277, 304, 267, 327, 849, 1035, 4756, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1153, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 4296, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 3718, 2968, 3266, 26125, 17, 15, 1153, 297, 283, 711, 6197, 26494, 413, 9150, 378, 14, 16, 14, 16, 14, 17, 297, 283, 711, 26494, 330, 2592, 1105, 398, 327, 849, 1035, 3507, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1153, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 5993, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 3718, 2968, 3266, 26125, 17, 15, 1153, 297, 283, 711, 6197, 26494, 413, 9150, 378, 14, 16, 14, 16, 14, 17, 297, 283, 711, 26494, 330, 2592, 3507, 1105, 339, 347, 511, 63, 21090, 63, 18, 8, 277, 304, 267, 327, 849, 1035, 849, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1153, 14, 4893, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 885, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 797, 9, 398, 327, 4756, 1035, 849, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1344, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 885, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 3718, 2968, 3266, 26125, 17, 15, 1344, 297, 283, 889, 3384, 26494, 330, 2592, 1105, 398, 327, 3507, 1035, 849, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1401, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 885, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 3718, 2968, 3266, 26125, 17, 15, 1401, 297, 283, 889, 3384, 26494, 330, 2592, 1105, 339, 347, 511, 63, 21090, 63, 19, 8, 277, 304, 267, 327, 4756, 1035, 9979, 9613, 6692, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1344, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 4296, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 797, 9, 398, 327, 3507, 1035, 9979, 9613, 6692, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1401, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 5993, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 797, 9, 339, 347, 511, 63, 21090, 63, 20, 8, 277, 304, 267, 327, 488, 1035, 9552, 267, 663, 63, 578, 63, 589, 8, 807, 8 ]
[ 334, 67, 9, 7800, 9572, 13002, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 6204, 14, 5819, 14, 1805, 492, 3371, 199, 504, 3242, 14, 3112, 14, 1200, 14, 17982, 492, 22072, 63, 3266, 63, 18303, 199, 504, 1275, 17982, 63, 578, 492, 1379, 46, 22101, 2377, 12, 2248, 63, 5997, 12, 663, 63, 578, 63, 589, 421, 199, 533, 1379, 46, 22101, 4267, 47, 12704, 2377, 8, 774, 46, 22101, 2377, 304, 339, 859, 275, 22072, 63, 3266, 63, 18303, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 46, 22101, 4267, 47, 12704, 2377, 12, 291, 680, 5996, 342, 398, 291, 14, 1805, 63, 362, 63, 888, 275, 3371, 360, 4853, 14, 3112, 14, 1200, 14, 17982, 14, 17982, 63, 3266, 63, 18303, 14, 362, 63, 888, 358, 267, 291, 14, 362, 63, 888, 275, 291, 14, 1805, 63, 362, 63, 888, 14, 928, 342, 398, 291, 14, 1805, 63, 912, 63, 888, 275, 3371, 360, 4853, 14, 3112, 14, 1200, 14, 17982, 14, 17982, 63, 3266, 63, 18303, 14, 912, 63, 888, 358, 267, 291, 14, 912, 63, 888, 275, 291, 14, 1805, 63, 912, 63, 888, 14, 928, 342, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 774, 46, 22101, 4267, 47, 12704, 2377, 12, 291, 680, 12336, 342, 267, 291, 14, 1805, 63, 362, 63, 888, 14, 2379, 342, 267, 291, 14, 1805, 63, 912, 63, 888, 14, 2379, 342, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 12, 2243, 9280, 267, 859, 63, 354, 275, 291, 14, 578, 855, 354, 4343, 13490, 14078, 413, 2788, 17, 61, 267, 291, 14, 362, 63, 888, 14, 1107, 63, 585, 275, 2248, 63, 5997, 8, 578, 63, 354, 12, 283, 888, 14, 4128, 358, 267, 291, 14, 912, 63, 888, 14, 1107, 63, 585, 275, 488, 339, 347, 511, 63, 17982, 63, 3266, 63, 18303, 8, 277, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 708, 297, 26494, 29, 17, 12, 9150, 29, 17, 430, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 3718, 2968, 3266, 26125, 17, 15, 708, 297, 283, 711, 6197, 26494, 413, 9150, 378, 14, 16, 14, 16, 14, 17, 1105, 339, 347, 511, 63, 21090, 63, 17, 8, 277, 304, 267, 327, 849, 1035, 4756, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1153, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 4296, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 3718, 2968, 3266, 26125, 17, 15, 1153, 297, 283, 711, 6197, 26494, 413, 9150, 378, 14, 16, 14, 16, 14, 17, 297, 283, 711, 26494, 330, 2592, 1105, 398, 327, 849, 1035, 3507, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1153, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 5993, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 3718, 2968, 3266, 26125, 17, 15, 1153, 297, 283, 711, 6197, 26494, 413, 9150, 378, 14, 16, 14, 16, 14, 17, 297, 283, 711, 26494, 330, 2592, 3507, 1105, 339, 347, 511, 63, 21090, 63, 18, 8, 277, 304, 267, 327, 849, 1035, 849, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1153, 14, 4893, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 885, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 797, 9, 398, 327, 4756, 1035, 849, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1344, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 885, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 3718, 2968, 3266, 26125, 17, 15, 1344, 297, 283, 889, 3384, 26494, 330, 2592, 1105, 398, 327, 3507, 1035, 849, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1401, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 885, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 3718, 2968, 3266, 26125, 17, 15, 1401, 297, 283, 889, 3384, 26494, 330, 2592, 1105, 339, 347, 511, 63, 21090, 63, 19, 8, 277, 304, 267, 327, 4756, 1035, 9979, 9613, 6692, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1344, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 4296, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 797, 9, 398, 327, 3507, 1035, 9979, 9613, 6692, 267, 663, 63, 578, 63, 589, 8, 807, 8, 3266, 534, 20354, 17, 15, 1401, 297, 26494, 29, 17, 12, 9150, 29, 17, 12, 330, 2592, 534, 5993, 1333, 267, 291, 14, 2526, 63, 578, 8, 2489, 29, 797, 9, 339, 347, 511, 63, 21090, 63, 20, 8, 277, 304, 267, 327, 488, 1035, 9552, 267, 663, 63, 578, 63, 589, 8, 807, 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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defineDict = {} typedefDict = {} #////////////////////////////////////////////////////////////////////// #@system 新一代交易所系统 #@company 上海期货信息技术有限公司 #@file ThostFtdcUserApiDataType.h #@brief 定义了客户端接口使用的业务数据类型 #@history #20060106 赵鸿昊 创建该文件 #////////////////////////////////////////////////////////////////////// #////////////////////////////////////////////////////////////////////// #TFtdcTraderIDType是一个交易所交易员代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTraderIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInvestorIDType是一个投资者代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInvestorIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBrokerIDType是一个经纪公司代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBrokerIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBrokerAbbrType是一个经纪公司简称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBrokerAbbrType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBrokerNameType是一个经纪公司名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBrokerNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExchangeInstIDType是一个合约在交易所的代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcExchangeInstIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrderRefType是一个报单引用类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOrderRefType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcParticipantIDType是一个会员代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcParticipantIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUserIDType是一个用户代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUserIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPasswordType是一个密码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPasswordType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcClientIDType是一个交易编码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcClientIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInstrumentIDType是一个合约代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInstrumentIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMarketIDType是一个市场代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcMarketIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcProductNameType是一个产品名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcProductNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExchangeIDType是一个交易所代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcExchangeIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExchangeNameType是一个交易所名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcExchangeNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExchangeAbbrType是一个交易所简称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcExchangeAbbrType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExchangeFlagType是一个交易所标志类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcExchangeFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMacAddressType是一个Mac地址类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcMacAddressType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSystemIDType是一个系统编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSystemIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExchangePropertyType是一个交易所属性类型 #////////////////////////////////////////////////////////////////////// #正常 defineDict["THOST_FTDC_EXP_Normal"] = '0' #根据成交生成报单 defineDict["THOST_FTDC_EXP_GenOrderByTrade"] = '1' typedefDict["TThostFtdcExchangePropertyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDateType是一个日期类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDateType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTimeType是一个时间类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTimeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcLongTimeType是一个长时间类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcLongTimeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInstrumentNameType是一个合约名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInstrumentNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSettlementGroupIDType是一个结算组代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSettlementGroupIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrderSysIDType是一个报单编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOrderSysIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTradeIDType是一个成交编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTradeIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCommandTypeType是一个DB命令类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCommandTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcIPAddressType是一个IP地址类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcIPAddressType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcIPPortType是一个IP端口类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcIPPortType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcProductInfoType是一个产品信息类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcProductInfoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcProtocolInfoType是一个协议信息类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcProtocolInfoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBusinessUnitType是一个业务单元类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBusinessUnitType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDepositSeqNoType是一个出入金流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDepositSeqNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcIdentifiedCardNoType是一个证件号码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcIdentifiedCardNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcIdCardTypeType是一个证件类型类型 #////////////////////////////////////////////////////////////////////// #组织机构代码 defineDict["THOST_FTDC_ICT_EID"] = '0' #中国公民身份证 defineDict["THOST_FTDC_ICT_IDCard"] = '1' #军官证 defineDict["THOST_FTDC_ICT_OfficerIDCard"] = '2' #警官证 defineDict["THOST_FTDC_ICT_PoliceIDCard"] = '3' #士兵证 defineDict["THOST_FTDC_ICT_SoldierIDCard"] = '4' #户口簿 defineDict["THOST_FTDC_ICT_HouseholdRegister"] = '5' #护照 defineDict["THOST_FTDC_ICT_Passport"] = '6' #台胞证 defineDict["THOST_FTDC_ICT_TaiwanCompatriotIDCard"] = '7' #回乡证 defineDict["THOST_FTDC_ICT_HomeComingCard"] = '8' #营业执照号 defineDict["THOST_FTDC_ICT_LicenseNo"] = '9' #税务登记号/当地纳税ID defineDict["THOST_FTDC_ICT_TaxNo"] = 'A' #港澳居民来往内地通行证 defineDict["THOST_FTDC_ICT_HMMainlandTravelPermit"] = 'B' #台湾居民来往大陆通行证 defineDict["THOST_FTDC_ICT_TwMainlandTravelPermit"] = 'C' #驾照 defineDict["THOST_FTDC_ICT_DrivingLicense"] = 'D' #当地社保ID defineDict["THOST_FTDC_ICT_SocialID"] = 'F' #当地身份证 defineDict["THOST_FTDC_ICT_LocalID"] = 'G' #商业登记证 defineDict["THOST_FTDC_ICT_BusinessRegistration"] = 'H' #港澳永久性居民身份证 defineDict["THOST_FTDC_ICT_HKMCIDCard"] = 'I' #其他证件 defineDict["THOST_FTDC_ICT_OtherCard"] = 'x' typedefDict["TThostFtdcIdCardTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrderLocalIDType是一个本地报单编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOrderLocalIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUserNameType是一个用户名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUserNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPartyNameType是一个参与人名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPartyNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcErrorMsgType是一个错误信息类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcErrorMsgType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFieldNameType是一个字段名类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFieldNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFieldContentType是一个字段内容类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFieldContentType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSystemNameType是一个系统名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSystemNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcContentType是一个消息正文类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcContentType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInvestorRangeType是一个投资者范围类型 #////////////////////////////////////////////////////////////////////// #所有 defineDict["THOST_FTDC_IR_All"] = '1' #投资者组 defineDict["THOST_FTDC_IR_Group"] = '2' #单一投资者 defineDict["THOST_FTDC_IR_Single"] = '3' typedefDict["TThostFtdcInvestorRangeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDepartmentRangeType是一个投资者范围类型 #////////////////////////////////////////////////////////////////////// #所有 defineDict["THOST_FTDC_DR_All"] = '1' #组织架构 defineDict["THOST_FTDC_DR_Group"] = '2' #单一投资者 defineDict["THOST_FTDC_DR_Single"] = '3' typedefDict["TThostFtdcDepartmentRangeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDataSyncStatusType是一个数据同步状态类型 #////////////////////////////////////////////////////////////////////// #未同步 defineDict["THOST_FTDC_DS_Asynchronous"] = '1' #同步中 defineDict["THOST_FTDC_DS_Synchronizing"] = '2' #已同步 defineDict["THOST_FTDC_DS_Synchronized"] = '3' typedefDict["TThostFtdcDataSyncStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBrokerDataSyncStatusType是一个经纪公司数据同步状态类型 #////////////////////////////////////////////////////////////////////// #已同步 defineDict["THOST_FTDC_BDS_Synchronized"] = '1' #同步中 defineDict["THOST_FTDC_BDS_Synchronizing"] = '2' typedefDict["TThostFtdcBrokerDataSyncStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExchangeConnectStatusType是一个交易所连接状态类型 #////////////////////////////////////////////////////////////////////// #没有任何连接 defineDict["THOST_FTDC_ECS_NoConnection"] = '1' #已经发出合约查询请求 defineDict["THOST_FTDC_ECS_QryInstrumentSent"] = '2' #已经获取信息 defineDict["THOST_FTDC_ECS_GotInformation"] = '9' typedefDict["TThostFtdcExchangeConnectStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTraderConnectStatusType是一个交易所交易员连接状态类型 #////////////////////////////////////////////////////////////////////// #没有任何连接 defineDict["THOST_FTDC_TCS_NotConnected"] = '1' #已经连接 defineDict["THOST_FTDC_TCS_Connected"] = '2' #已经发出合约查询请求 defineDict["THOST_FTDC_TCS_QryInstrumentSent"] = '3' #订阅私有流 defineDict["THOST_FTDC_TCS_SubPrivateFlow"] = '4' typedefDict["TThostFtdcTraderConnectStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFunctionCodeType是一个功能代码类型 #////////////////////////////////////////////////////////////////////// #数据异步化 defineDict["THOST_FTDC_FC_DataAsync"] = '1' #强制用户登出 defineDict["THOST_FTDC_FC_ForceUserLogout"] = '2' #变更管理用户口令 defineDict["THOST_FTDC_FC_UserPasswordUpdate"] = '3' #变更经纪公司口令 defineDict["THOST_FTDC_FC_BrokerPasswordUpdate"] = '4' #变更投资者口令 defineDict["THOST_FTDC_FC_InvestorPasswordUpdate"] = '5' #报单插入 defineDict["THOST_FTDC_FC_OrderInsert"] = '6' #报单操作 defineDict["THOST_FTDC_FC_OrderAction"] = '7' #同步系统数据 defineDict["THOST_FTDC_FC_SyncSystemData"] = '8' #同步经纪公司数据 defineDict["THOST_FTDC_FC_SyncBrokerData"] = '9' #批量同步经纪公司数据 defineDict["THOST_FTDC_FC_BachSyncBrokerData"] = 'A' #超级查询 defineDict["THOST_FTDC_FC_SuperQuery"] = 'B' #预埋报单插入 defineDict["THOST_FTDC_FC_ParkedOrderInsert"] = 'C' #预埋报单操作 defineDict["THOST_FTDC_FC_ParkedOrderAction"] = 'D' #同步动态令牌 defineDict["THOST_FTDC_FC_SyncOTP"] = 'E' #删除未知单 defineDict["THOST_FTDC_FC_DeleteOrder"] = 'F' typedefDict["TThostFtdcFunctionCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBrokerFunctionCodeType是一个经纪公司功能代码类型 #////////////////////////////////////////////////////////////////////// #强制用户登出 defineDict["THOST_FTDC_BFC_ForceUserLogout"] = '1' #变更用户口令 defineDict["THOST_FTDC_BFC_UserPasswordUpdate"] = '2' #同步经纪公司数据 defineDict["THOST_FTDC_BFC_SyncBrokerData"] = '3' #批量同步经纪公司数据 defineDict["THOST_FTDC_BFC_BachSyncBrokerData"] = '4' #报单插入 defineDict["THOST_FTDC_BFC_OrderInsert"] = '5' #报单操作 defineDict["THOST_FTDC_BFC_OrderAction"] = '6' #全部查询 defineDict["THOST_FTDC_BFC_AllQuery"] = '7' #系统功能:登入/登出/修改密码等 defineDict["THOST_FTDC_BFC_log"] = 'a' #基本查询:查询基础数据,如合约,交易所等常量 defineDict["THOST_FTDC_BFC_BaseQry"] = 'b' #交易查询:如查成交,委托 defineDict["THOST_FTDC_BFC_TradeQry"] = 'c' #交易功能:报单,撤单 defineDict["THOST_FTDC_BFC_Trade"] = 'd' #银期转账 defineDict["THOST_FTDC_BFC_Virement"] = 'e' #风险监控 defineDict["THOST_FTDC_BFC_Risk"] = 'f' #查询/管理:查询会话,踢人等 defineDict["THOST_FTDC_BFC_Session"] = 'g' #风控通知控制 defineDict["THOST_FTDC_BFC_RiskNoticeCtl"] = 'h' #风控通知发送 defineDict["THOST_FTDC_BFC_RiskNotice"] = 'i' #察看经纪公司资金权限 defineDict["THOST_FTDC_BFC_BrokerDeposit"] = 'j' #资金查询 defineDict["THOST_FTDC_BFC_QueryFund"] = 'k' #报单查询 defineDict["THOST_FTDC_BFC_QueryOrder"] = 'l' #成交查询 defineDict["THOST_FTDC_BFC_QueryTrade"] = 'm' #持仓查询 defineDict["THOST_FTDC_BFC_QueryPosition"] = 'n' #行情查询 defineDict["THOST_FTDC_BFC_QueryMarketData"] = 'o' #用户事件查询 defineDict["THOST_FTDC_BFC_QueryUserEvent"] = 'p' #风险通知查询 defineDict["THOST_FTDC_BFC_QueryRiskNotify"] = 'q' #出入金查询 defineDict["THOST_FTDC_BFC_QueryFundChange"] = 'r' #投资者信息查询 defineDict["THOST_FTDC_BFC_QueryInvestor"] = 's' #交易编码查询 defineDict["THOST_FTDC_BFC_QueryTradingCode"] = 't' #强平 defineDict["THOST_FTDC_BFC_ForceClose"] = 'u' #压力测试 defineDict["THOST_FTDC_BFC_PressTest"] = 'v' #权益反算 defineDict["THOST_FTDC_BFC_RemainCalc"] = 'w' #净持仓保证金指标 defineDict["THOST_FTDC_BFC_NetPositionInd"] = 'x' #风险预算 defineDict["THOST_FTDC_BFC_RiskPredict"] = 'y' #数据导出 defineDict["THOST_FTDC_BFC_DataExport"] = 'z' #风控指标设置 defineDict["THOST_FTDC_BFC_RiskTargetSetup"] = 'A' #行情预警 defineDict["THOST_FTDC_BFC_MarketDataWarn"] = 'B' #业务通知查询 defineDict["THOST_FTDC_BFC_QryBizNotice"] = 'C' #业务通知模板设置 defineDict["THOST_FTDC_BFC_CfgBizNotice"] = 'D' #同步动态令牌 defineDict["THOST_FTDC_BFC_SyncOTP"] = 'E' #发送业务通知 defineDict["THOST_FTDC_BFC_SendBizNotice"] = 'F' #风险级别标准设置 defineDict["THOST_FTDC_BFC_CfgRiskLevelStd"] = 'G' #交易终端应急功能 defineDict["THOST_FTDC_BFC_TbCommand"] = 'H' #删除未知单 defineDict["THOST_FTDC_BFC_DeleteOrder"] = 'J' #预埋报单插入 defineDict["THOST_FTDC_BFC_ParkedOrderInsert"] = 'K' #预埋报单操作 defineDict["THOST_FTDC_BFC_ParkedOrderAction"] = 'L' typedefDict["TThostFtdcBrokerFunctionCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrderActionStatusType是一个报单操作状态类型 #////////////////////////////////////////////////////////////////////// #已经提交 defineDict["THOST_FTDC_OAS_Submitted"] = 'a' #已经接受 defineDict["THOST_FTDC_OAS_Accepted"] = 'b' #已经被拒绝 defineDict["THOST_FTDC_OAS_Rejected"] = 'c' typedefDict["TThostFtdcOrderActionStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrderStatusType是一个报单状态类型 #////////////////////////////////////////////////////////////////////// #全部成交 defineDict["THOST_FTDC_OST_AllTraded"] = '0' #部分成交还在队列中 defineDict["THOST_FTDC_OST_PartTradedQueueing"] = '1' #部分成交不在队列中 defineDict["THOST_FTDC_OST_PartTradedNotQueueing"] = '2' #未成交还在队列中 defineDict["THOST_FTDC_OST_NoTradeQueueing"] = '3' #未成交不在队列中 defineDict["THOST_FTDC_OST_NoTradeNotQueueing"] = '4' #撤单 defineDict["THOST_FTDC_OST_Canceled"] = '5' #未知 defineDict["THOST_FTDC_OST_Unknown"] = 'a' #尚未触发 defineDict["THOST_FTDC_OST_NotTouched"] = 'b' #已触发 defineDict["THOST_FTDC_OST_Touched"] = 'c' typedefDict["TThostFtdcOrderStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrderSubmitStatusType是一个报单提交状态类型 #////////////////////////////////////////////////////////////////////// #已经提交 defineDict["THOST_FTDC_OSS_InsertSubmitted"] = '0' #撤单已经提交 defineDict["THOST_FTDC_OSS_CancelSubmitted"] = '1' #修改已经提交 defineDict["THOST_FTDC_OSS_ModifySubmitted"] = '2' #已经接受 defineDict["THOST_FTDC_OSS_Accepted"] = '3' #报单已经被拒绝 defineDict["THOST_FTDC_OSS_InsertRejected"] = '4' #撤单已经被拒绝 defineDict["THOST_FTDC_OSS_CancelRejected"] = '5' #改单已经被拒绝 defineDict["THOST_FTDC_OSS_ModifyRejected"] = '6' typedefDict["TThostFtdcOrderSubmitStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPositionDateType是一个持仓日期类型 #////////////////////////////////////////////////////////////////////// #今日持仓 defineDict["THOST_FTDC_PSD_Today"] = '1' #历史持仓 defineDict["THOST_FTDC_PSD_History"] = '2' typedefDict["TThostFtdcPositionDateType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPositionDateTypeType是一个持仓日期类型类型 #////////////////////////////////////////////////////////////////////// #使用历史持仓 defineDict["THOST_FTDC_PDT_UseHistory"] = '1' #不使用历史持仓 defineDict["THOST_FTDC_PDT_NoUseHistory"] = '2' typedefDict["TThostFtdcPositionDateTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTradingRoleType是一个交易角色类型 #////////////////////////////////////////////////////////////////////// #代理 defineDict["THOST_FTDC_ER_Broker"] = '1' #自营 defineDict["THOST_FTDC_ER_Host"] = '2' #做市商 defineDict["THOST_FTDC_ER_Maker"] = '3' typedefDict["TThostFtdcTradingRoleType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcProductClassType是一个产品类型类型 #////////////////////////////////////////////////////////////////////// #期货 defineDict["THOST_FTDC_PC_Futures"] = '1' #期货期权 defineDict["THOST_FTDC_PC_Options"] = '2' #组合 defineDict["THOST_FTDC_PC_Combination"] = '3' #即期 defineDict["THOST_FTDC_PC_Spot"] = '4' #期转现 defineDict["THOST_FTDC_PC_EFP"] = '5' #现货期权 defineDict["THOST_FTDC_PC_SpotOption"] = '6' typedefDict["TThostFtdcProductClassType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInstLifePhaseType是一个合约生命周期状态类型 #////////////////////////////////////////////////////////////////////// #未上市 defineDict["THOST_FTDC_IP_NotStart"] = '0' #上市 defineDict["THOST_FTDC_IP_Started"] = '1' #停牌 defineDict["THOST_FTDC_IP_Pause"] = '2' #到期 defineDict["THOST_FTDC_IP_Expired"] = '3' typedefDict["TThostFtdcInstLifePhaseType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDirectionType是一个买卖方向类型 #////////////////////////////////////////////////////////////////////// #买 defineDict["THOST_FTDC_D_Buy"] = '0' #卖 defineDict["THOST_FTDC_D_Sell"] = '1' typedefDict["TThostFtdcDirectionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPositionTypeType是一个持仓类型类型 #////////////////////////////////////////////////////////////////////// #净持仓 defineDict["THOST_FTDC_PT_Net"] = '1' #综合持仓 defineDict["THOST_FTDC_PT_Gross"] = '2' typedefDict["TThostFtdcPositionTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPosiDirectionType是一个持仓多空方向类型 #////////////////////////////////////////////////////////////////////// #净 defineDict["THOST_FTDC_PD_Net"] = '1' #多头 defineDict["THOST_FTDC_PD_Long"] = '2' #空头 defineDict["THOST_FTDC_PD_Short"] = '3' typedefDict["TThostFtdcPosiDirectionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSysSettlementStatusType是一个系统结算状态类型 #////////////////////////////////////////////////////////////////////// #不活跃 defineDict["THOST_FTDC_SS_NonActive"] = '1' #启动 defineDict["THOST_FTDC_SS_Startup"] = '2' #操作 defineDict["THOST_FTDC_SS_Operating"] = '3' #结算 defineDict["THOST_FTDC_SS_Settlement"] = '4' #结算完成 defineDict["THOST_FTDC_SS_SettlementFinished"] = '5' typedefDict["TThostFtdcSysSettlementStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRatioAttrType是一个费率属性类型 #////////////////////////////////////////////////////////////////////// #交易费率 defineDict["THOST_FTDC_RA_Trade"] = '0' #结算费率 defineDict["THOST_FTDC_RA_Settlement"] = '1' typedefDict["TThostFtdcRatioAttrType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcHedgeFlagType是一个投机套保标志类型 #////////////////////////////////////////////////////////////////////// #投机 defineDict["THOST_FTDC_HF_Speculation"] = '1' #套利 defineDict["THOST_FTDC_HF_Arbitrage"] = '2' #套保 defineDict["THOST_FTDC_HF_Hedge"] = '3' typedefDict["TThostFtdcHedgeFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBillHedgeFlagType是一个投机套保标志类型 #////////////////////////////////////////////////////////////////////// #投机 defineDict["THOST_FTDC_BHF_Speculation"] = '1' #套利 defineDict["THOST_FTDC_BHF_Arbitrage"] = '2' #套保 defineDict["THOST_FTDC_BHF_Hedge"] = '3' typedefDict["TThostFtdcBillHedgeFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcClientIDTypeType是一个交易编码类型类型 #////////////////////////////////////////////////////////////////////// #投机 defineDict["THOST_FTDC_CIDT_Speculation"] = '1' #套利 defineDict["THOST_FTDC_CIDT_Arbitrage"] = '2' #套保 defineDict["THOST_FTDC_CIDT_Hedge"] = '3' typedefDict["TThostFtdcClientIDTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrderPriceTypeType是一个报单价格条件类型 #////////////////////////////////////////////////////////////////////// #任意价 defineDict["THOST_FTDC_OPT_AnyPrice"] = '1' #限价 defineDict["THOST_FTDC_OPT_LimitPrice"] = '2' #最优价 defineDict["THOST_FTDC_OPT_BestPrice"] = '3' #最新价 defineDict["THOST_FTDC_OPT_LastPrice"] = '4' #最新价浮动上浮1个ticks defineDict["THOST_FTDC_OPT_LastPricePlusOneTicks"] = '5' #最新价浮动上浮2个ticks defineDict["THOST_FTDC_OPT_LastPricePlusTwoTicks"] = '6' #最新价浮动上浮3个ticks defineDict["THOST_FTDC_OPT_LastPricePlusThreeTicks"] = '7' #卖一价 defineDict["THOST_FTDC_OPT_AskPrice1"] = '8' #卖一价浮动上浮1个ticks defineDict["THOST_FTDC_OPT_AskPrice1PlusOneTicks"] = '9' #卖一价浮动上浮2个ticks defineDict["THOST_FTDC_OPT_AskPrice1PlusTwoTicks"] = 'A' #卖一价浮动上浮3个ticks defineDict["THOST_FTDC_OPT_AskPrice1PlusThreeTicks"] = 'B' #买一价 defineDict["THOST_FTDC_OPT_BidPrice1"] = 'C' #买一价浮动上浮1个ticks defineDict["THOST_FTDC_OPT_BidPrice1PlusOneTicks"] = 'D' #买一价浮动上浮2个ticks defineDict["THOST_FTDC_OPT_BidPrice1PlusTwoTicks"] = 'E' #买一价浮动上浮3个ticks defineDict["THOST_FTDC_OPT_BidPrice1PlusThreeTicks"] = 'F' typedefDict["TThostFtdcOrderPriceTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOffsetFlagType是一个开平标志类型 #////////////////////////////////////////////////////////////////////// #开仓 defineDict["THOST_FTDC_OF_Open"] = '0' #平仓 defineDict["THOST_FTDC_OF_Close"] = '1' #强平 defineDict["THOST_FTDC_OF_ForceClose"] = '2' #平今 defineDict["THOST_FTDC_OF_CloseToday"] = '3' #平昨 defineDict["THOST_FTDC_OF_CloseYesterday"] = '4' #强减 defineDict["THOST_FTDC_OF_ForceOff"] = '5' #本地强平 defineDict["THOST_FTDC_OF_LocalForceClose"] = '6' typedefDict["TThostFtdcOffsetFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcForceCloseReasonType是一个强平原因类型 #////////////////////////////////////////////////////////////////////// #非强平 defineDict["THOST_FTDC_FCC_NotForceClose"] = '0' #资金不足 defineDict["THOST_FTDC_FCC_LackDeposit"] = '1' #客户超仓 defineDict["THOST_FTDC_FCC_ClientOverPositionLimit"] = '2' #会员超仓 defineDict["THOST_FTDC_FCC_MemberOverPositionLimit"] = '3' #持仓非整数倍 defineDict["THOST_FTDC_FCC_NotMultiple"] = '4' #违规 defineDict["THOST_FTDC_FCC_Violation"] = '5' #其它 defineDict["THOST_FTDC_FCC_Other"] = '6' #自然人临近交割 defineDict["THOST_FTDC_FCC_PersonDeliv"] = '7' typedefDict["TThostFtdcForceCloseReasonType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrderTypeType是一个报单类型类型 #////////////////////////////////////////////////////////////////////// #正常 defineDict["THOST_FTDC_ORDT_Normal"] = '0' #报价衍生 defineDict["THOST_FTDC_ORDT_DeriveFromQuote"] = '1' #组合衍生 defineDict["THOST_FTDC_ORDT_DeriveFromCombination"] = '2' #组合报单 defineDict["THOST_FTDC_ORDT_Combination"] = '3' #条件单 defineDict["THOST_FTDC_ORDT_ConditionalOrder"] = '4' #互换单 defineDict["THOST_FTDC_ORDT_Swap"] = '5' typedefDict["TThostFtdcOrderTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTimeConditionType是一个有效期类型类型 #////////////////////////////////////////////////////////////////////// #立即完成,否则撤销 defineDict["THOST_FTDC_TC_IOC"] = '1' #本节有效 defineDict["THOST_FTDC_TC_GFS"] = '2' #当日有效 defineDict["THOST_FTDC_TC_GFD"] = '3' #指定日期前有效 defineDict["THOST_FTDC_TC_GTD"] = '4' #撤销前有效 defineDict["THOST_FTDC_TC_GTC"] = '5' #集合竞价有效 defineDict["THOST_FTDC_TC_GFA"] = '6' typedefDict["TThostFtdcTimeConditionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcVolumeConditionType是一个成交量类型类型 #////////////////////////////////////////////////////////////////////// #任何数量 defineDict["THOST_FTDC_VC_AV"] = '1' #最小数量 defineDict["THOST_FTDC_VC_MV"] = '2' #全部数量 defineDict["THOST_FTDC_VC_CV"] = '3' typedefDict["TThostFtdcVolumeConditionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcContingentConditionType是一个触发条件类型 #////////////////////////////////////////////////////////////////////// #立即 defineDict["THOST_FTDC_CC_Immediately"] = '1' #止损 defineDict["THOST_FTDC_CC_Touch"] = '2' #止赢 defineDict["THOST_FTDC_CC_TouchProfit"] = '3' #预埋单 defineDict["THOST_FTDC_CC_ParkedOrder"] = '4' #最新价大于条件价 defineDict["THOST_FTDC_CC_LastPriceGreaterThanStopPrice"] = '5' #最新价大于等于条件价 defineDict["THOST_FTDC_CC_LastPriceGreaterEqualStopPrice"] = '6' #最新价小于条件价 defineDict["THOST_FTDC_CC_LastPriceLesserThanStopPrice"] = '7' #最新价小于等于条件价 defineDict["THOST_FTDC_CC_LastPriceLesserEqualStopPrice"] = '8' #卖一价大于条件价 defineDict["THOST_FTDC_CC_AskPriceGreaterThanStopPrice"] = '9' #卖一价大于等于条件价 defineDict["THOST_FTDC_CC_AskPriceGreaterEqualStopPrice"] = 'A' #卖一价小于条件价 defineDict["THOST_FTDC_CC_AskPriceLesserThanStopPrice"] = 'B' #卖一价小于等于条件价 defineDict["THOST_FTDC_CC_AskPriceLesserEqualStopPrice"] = 'C' #买一价大于条件价 defineDict["THOST_FTDC_CC_BidPriceGreaterThanStopPrice"] = 'D' #买一价大于等于条件价 defineDict["THOST_FTDC_CC_BidPriceGreaterEqualStopPrice"] = 'E' #买一价小于条件价 defineDict["THOST_FTDC_CC_BidPriceLesserThanStopPrice"] = 'F' #买一价小于等于条件价 defineDict["THOST_FTDC_CC_BidPriceLesserEqualStopPrice"] = 'H' typedefDict["TThostFtdcContingentConditionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcActionFlagType是一个操作标志类型 #////////////////////////////////////////////////////////////////////// #删除 defineDict["THOST_FTDC_AF_Delete"] = '0' #修改 defineDict["THOST_FTDC_AF_Modify"] = '3' typedefDict["TThostFtdcActionFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTradingRightType是一个交易权限类型 #////////////////////////////////////////////////////////////////////// #可以交易 defineDict["THOST_FTDC_TR_Allow"] = '0' #只能平仓 defineDict["THOST_FTDC_TR_CloseOnly"] = '1' #不能交易 defineDict["THOST_FTDC_TR_Forbidden"] = '2' typedefDict["TThostFtdcTradingRightType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrderSourceType是一个报单来源类型 #////////////////////////////////////////////////////////////////////// #来自参与者 defineDict["THOST_FTDC_OSRC_Participant"] = '0' #来自管理员 defineDict["THOST_FTDC_OSRC_Administrator"] = '1' typedefDict["TThostFtdcOrderSourceType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTradeTypeType是一个成交类型类型 #////////////////////////////////////////////////////////////////////// #组合持仓拆分为单一持仓,初始化不应包含该类型的持仓 defineDict["THOST_FTDC_TRDT_SplitCombination"] = '#' #普通成交 defineDict["THOST_FTDC_TRDT_Common"] = '0' #期权执行 defineDict["THOST_FTDC_TRDT_OptionsExecution"] = '1' #OTC成交 defineDict["THOST_FTDC_TRDT_OTC"] = '2' #期转现衍生成交 defineDict["THOST_FTDC_TRDT_EFPDerived"] = '3' #组合衍生成交 defineDict["THOST_FTDC_TRDT_CombinationDerived"] = '4' typedefDict["TThostFtdcTradeTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPriceSourceType是一个成交价来源类型 #////////////////////////////////////////////////////////////////////// #前成交价 defineDict["THOST_FTDC_PSRC_LastPrice"] = '0' #买委托价 defineDict["THOST_FTDC_PSRC_Buy"] = '1' #卖委托价 defineDict["THOST_FTDC_PSRC_Sell"] = '2' typedefDict["TThostFtdcPriceSourceType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInstrumentStatusType是一个合约交易状态类型 #////////////////////////////////////////////////////////////////////// #开盘前 defineDict["THOST_FTDC_IS_BeforeTrading"] = '0' #非交易 defineDict["THOST_FTDC_IS_NoTrading"] = '1' #连续交易 defineDict["THOST_FTDC_IS_Continous"] = '2' #集合竞价报单 defineDict["THOST_FTDC_IS_AuctionOrdering"] = '3' #集合竞价价格平衡 defineDict["THOST_FTDC_IS_AuctionBalance"] = '4' #集合竞价撮合 defineDict["THOST_FTDC_IS_AuctionMatch"] = '5' #收盘 defineDict["THOST_FTDC_IS_Closed"] = '6' typedefDict["TThostFtdcInstrumentStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInstStatusEnterReasonType是一个品种进入交易状态原因类型 #////////////////////////////////////////////////////////////////////// #自动切换 defineDict["THOST_FTDC_IER_Automatic"] = '1' #手动切换 defineDict["THOST_FTDC_IER_Manual"] = '2' #熔断 defineDict["THOST_FTDC_IER_Fuse"] = '3' typedefDict["TThostFtdcInstStatusEnterReasonType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrderActionRefType是一个报单操作引用类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOrderActionRefType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcInstallCountType是一个安装数量类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInstallCountType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcInstallIDType是一个安装编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInstallIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcErrorIDType是一个错误代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcErrorIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcSettlementIDType是一个结算编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSettlementIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcVolumeType是一个数量类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcVolumeType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcFrontIDType是一个前置编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFrontIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcSessionIDType是一个会话编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSessionIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcSequenceNoType是一个序号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSequenceNoType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcCommandNoType是一个DB命令序号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCommandNoType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcMillisecType是一个时间(毫秒)类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcMillisecType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcVolumeMultipleType是一个合约数量乘数类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcVolumeMultipleType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcTradingSegmentSNType是一个交易阶段编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTradingSegmentSNType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcRequestIDType是一个请求编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRequestIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcYearType是一个年份类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcYearType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcMonthType是一个月份类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcMonthType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcBoolType是一个布尔型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBoolType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcPriceType是一个价格类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPriceType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcCombOffsetFlagType是一个组合开平标志类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCombOffsetFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCombHedgeFlagType是一个组合投机套保标志类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCombHedgeFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRatioType是一个比率类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRatioType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcMoneyType是一个资金类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcMoneyType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcLargeVolumeType是一个大额数量类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcLargeVolumeType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcSequenceSeriesType是一个序列系列号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSequenceSeriesType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcCommPhaseNoType是一个通讯时段编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCommPhaseNoType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcSequenceLabelType是一个序列编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSequenceLabelType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUnderlyingMultipleType是一个基础商品乘数类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUnderlyingMultipleType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcPriorityType是一个优先级类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPriorityType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcContractCodeType是一个合同编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcContractCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCityType是一个市类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCityType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcIsStockType是一个是否股民类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcIsStockType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcChannelType是一个渠道类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcChannelType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAddressType是一个通讯地址类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAddressType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcZipCodeType是一个邮政编码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcZipCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTelephoneType是一个联系电话类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTelephoneType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFaxType是一个传真类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFaxType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMobileType是一个手机类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcMobileType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcEMailType是一个电子邮件类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcEMailType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMemoType是一个备注类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcMemoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCompanyCodeType是一个企业代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCompanyCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcWebsiteType是一个网站地址类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcWebsiteType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTaxNoType是一个税务登记号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTaxNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBatchStatusType是一个处理状态类型 #////////////////////////////////////////////////////////////////////// #未上传 defineDict["THOST_FTDC_BS_NoUpload"] = '1' #已上传 defineDict["THOST_FTDC_BS_Uploaded"] = '2' #审核失败 defineDict["THOST_FTDC_BS_Failed"] = '3' typedefDict["TThostFtdcBatchStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPropertyIDType是一个属性代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPropertyIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPropertyNameType是一个属性名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPropertyNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcLicenseNoType是一个营业执照号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcLicenseNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAgentIDType是一个经纪人代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAgentIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAgentNameType是一个经纪人名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAgentNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAgentGroupIDType是一个经纪人组代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAgentGroupIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAgentGroupNameType是一个经纪人组名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAgentGroupNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcReturnStyleType是一个按品种返还方式类型 #////////////////////////////////////////////////////////////////////// #按所有品种 defineDict["THOST_FTDC_RS_All"] = '1' #按品种 defineDict["THOST_FTDC_RS_ByProduct"] = '2' typedefDict["TThostFtdcReturnStyleType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcReturnPatternType是一个返还模式类型 #////////////////////////////////////////////////////////////////////// #按成交手数 defineDict["THOST_FTDC_RP_ByVolume"] = '1' #按留存手续费 defineDict["THOST_FTDC_RP_ByFeeOnHand"] = '2' typedefDict["TThostFtdcReturnPatternType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcReturnLevelType是一个返还级别类型 #////////////////////////////////////////////////////////////////////// #级别1 defineDict["THOST_FTDC_RL_Level1"] = '1' #级别2 defineDict["THOST_FTDC_RL_Level2"] = '2' #级别3 defineDict["THOST_FTDC_RL_Level3"] = '3' #级别4 defineDict["THOST_FTDC_RL_Level4"] = '4' #级别5 defineDict["THOST_FTDC_RL_Level5"] = '5' #级别6 defineDict["THOST_FTDC_RL_Level6"] = '6' #级别7 defineDict["THOST_FTDC_RL_Level7"] = '7' #级别8 defineDict["THOST_FTDC_RL_Level8"] = '8' #级别9 defineDict["THOST_FTDC_RL_Level9"] = '9' typedefDict["TThostFtdcReturnLevelType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcReturnStandardType是一个返还标准类型 #////////////////////////////////////////////////////////////////////// #分阶段返还 defineDict["THOST_FTDC_RSD_ByPeriod"] = '1' #按某一标准 defineDict["THOST_FTDC_RSD_ByStandard"] = '2' typedefDict["TThostFtdcReturnStandardType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMortgageTypeType是一个质押类型类型 #////////////////////////////////////////////////////////////////////// #质出 defineDict["THOST_FTDC_MT_Out"] = '0' #质入 defineDict["THOST_FTDC_MT_In"] = '1' typedefDict["TThostFtdcMortgageTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInvestorSettlementParamIDType是一个投资者结算参数代码类型 #////////////////////////////////////////////////////////////////////// #质押比例 defineDict["THOST_FTDC_ISPI_MortgageRatio"] = '4' #保证金算法 defineDict["THOST_FTDC_ISPI_MarginWay"] = '5' #结算单结存是否包含质押 defineDict["THOST_FTDC_ISPI_BillDeposit"] = '9' typedefDict["TThostFtdcInvestorSettlementParamIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExchangeSettlementParamIDType是一个交易所结算参数代码类型 #////////////////////////////////////////////////////////////////////// #质押比例 defineDict["THOST_FTDC_ESPI_MortgageRatio"] = '1' #分项资金导入项 defineDict["THOST_FTDC_ESPI_OtherFundItem"] = '2' #分项资金入交易所出入金 defineDict["THOST_FTDC_ESPI_OtherFundImport"] = '3' #中金所开户最低可用金额 defineDict["THOST_FTDC_ESPI_CFFEXMinPrepa"] = '6' #郑商所结算方式 defineDict["THOST_FTDC_ESPI_CZCESettlementType"] = '7' #交易所交割手续费收取方式 defineDict["THOST_FTDC_ESPI_ExchDelivFeeMode"] = '9' #投资者交割手续费收取方式 defineDict["THOST_FTDC_ESPI_DelivFeeMode"] = '0' #郑商所组合持仓保证金收取方式 defineDict["THOST_FTDC_ESPI_CZCEComMarginType"] = 'A' #大商所套利保证金是否优惠 defineDict["THOST_FTDC_ESPI_DceComMarginType"] = 'B' #虚值期权保证金优惠比率 defineDict["THOST_FTDC_ESPI_OptOutDisCountRate"] = 'a' #最低保障系数 defineDict["THOST_FTDC_ESPI_OptMiniGuarantee"] = 'b' typedefDict["TThostFtdcExchangeSettlementParamIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSystemParamIDType是一个系统参数代码类型 #////////////////////////////////////////////////////////////////////// #投资者代码最小长度 defineDict["THOST_FTDC_SPI_InvestorIDMinLength"] = '1' #投资者帐号代码最小长度 defineDict["THOST_FTDC_SPI_AccountIDMinLength"] = '2' #投资者开户默认登录权限 defineDict["THOST_FTDC_SPI_UserRightLogon"] = '3' #投资者交易结算单成交汇总方式 defineDict["THOST_FTDC_SPI_SettlementBillTrade"] = '4' #统一开户更新交易编码方式 defineDict["THOST_FTDC_SPI_TradingCode"] = '5' #结算是否判断存在未复核的出入金和分项资金 defineDict["THOST_FTDC_SPI_CheckFund"] = '6' #是否启用手续费模板数据权限 defineDict["THOST_FTDC_SPI_CommModelRight"] = '7' #是否启用保证金率模板数据权限 defineDict["THOST_FTDC_SPI_MarginModelRight"] = '9' #是否规范用户才能激活 defineDict["THOST_FTDC_SPI_IsStandardActive"] = '8' #上传的交易所结算文件路径 defineDict["THOST_FTDC_SPI_UploadSettlementFile"] = 'U' #上报保证金监控中心文件路径 defineDict["THOST_FTDC_SPI_DownloadCSRCFile"] = 'D' #生成的结算单文件路径 defineDict["THOST_FTDC_SPI_SettlementBillFile"] = 'S' #证监会文件标识 defineDict["THOST_FTDC_SPI_CSRCOthersFile"] = 'C' #投资者照片路径 defineDict["THOST_FTDC_SPI_InvestorPhoto"] = 'P' #全结经纪公司上传文件路径 defineDict["THOST_FTDC_SPI_CSRCData"] = 'R' #开户密码录入方式 defineDict["THOST_FTDC_SPI_InvestorPwdModel"] = 'I' #投资者中金所结算文件下载路径 defineDict["THOST_FTDC_SPI_CFFEXInvestorSettleFile"] = 'F' #投资者代码编码方式 defineDict["THOST_FTDC_SPI_InvestorIDType"] = 'a' #休眠户最高权益 defineDict["THOST_FTDC_SPI_FreezeMaxReMain"] = 'r' #手续费相关操作实时上场开关 defineDict["THOST_FTDC_SPI_IsSync"] = 'A' #解除开仓权限限制 defineDict["THOST_FTDC_SPI_RelieveOpenLimit"] = 'O' #是否规范用户才能休眠 defineDict["THOST_FTDC_SPI_IsStandardFreeze"] = 'X' #郑商所是否开放所有品种套保交易 defineDict["THOST_FTDC_SPI_CZCENormalProductHedge"] = 'B' typedefDict["TThostFtdcSystemParamIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTradeParamIDType是一个交易系统参数代码类型 #////////////////////////////////////////////////////////////////////// #系统加密算法 defineDict["THOST_FTDC_TPID_EncryptionStandard"] = 'E' #系统风险算法 defineDict["THOST_FTDC_TPID_RiskMode"] = 'R' #系统风险算法是否全局 0-否 1-是 defineDict["THOST_FTDC_TPID_RiskModeGlobal"] = 'G' #密码加密算法 defineDict["THOST_FTDC_TPID_modeEncode"] = 'P' #价格小数位数参数 defineDict["THOST_FTDC_TPID_tickMode"] = 'T' #用户最大会话数 defineDict["THOST_FTDC_TPID_SingleUserSessionMaxNum"] = 'S' #最大连续登录失败数 defineDict["THOST_FTDC_TPID_LoginFailMaxNum"] = 'L' #是否强制认证 defineDict["THOST_FTDC_TPID_IsAuthForce"] = 'A' typedefDict["TThostFtdcTradeParamIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSettlementParamValueType是一个参数代码值类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSettlementParamValueType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCounterIDType是一个计数器代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCounterIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInvestorGroupNameType是一个投资者分组名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInvestorGroupNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBrandCodeType是一个牌号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBrandCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcWarehouseType是一个仓库类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcWarehouseType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcProductDateType是一个产期类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcProductDateType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcGradeType是一个等级类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcGradeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcClassifyType是一个类别类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcClassifyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPositionType是一个货位类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPositionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcYieldlyType是一个产地类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcYieldlyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcWeightType是一个公定重量类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcWeightType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSubEntryFundNoType是一个分项资金流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSubEntryFundNoType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcFileIDType是一个文件标识类型 #////////////////////////////////////////////////////////////////////// #资金数据 defineDict["THOST_FTDC_FI_SettlementFund"] = 'F' #成交数据 defineDict["THOST_FTDC_FI_Trade"] = 'T' #投资者持仓数据 defineDict["THOST_FTDC_FI_InvestorPosition"] = 'P' #投资者分项资金数据 defineDict["THOST_FTDC_FI_SubEntryFund"] = 'O' #组合持仓数据 defineDict["THOST_FTDC_FI_CZCECombinationPos"] = 'C' #上报保证金监控中心数据 defineDict["THOST_FTDC_FI_CSRCData"] = 'R' #郑商所平仓了结数据 defineDict["THOST_FTDC_FI_CZCEClose"] = 'L' #郑商所非平仓了结数据 defineDict["THOST_FTDC_FI_CZCENoClose"] = 'N' #持仓明细数据 defineDict["THOST_FTDC_FI_PositionDtl"] = 'D' #期权执行文件 defineDict["THOST_FTDC_FI_OptionStrike"] = 'S' #结算价比对文件 defineDict["THOST_FTDC_FI_SettlementPriceComparison"] = 'M' #上期所非持仓变动明细 defineDict["THOST_FTDC_FI_NonTradePosChange"] = 'B' typedefDict["TThostFtdcFileIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFileNameType是一个文件名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFileNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFileTypeType是一个文件上传类型类型 #////////////////////////////////////////////////////////////////////// #结算 defineDict["THOST_FTDC_FUT_Settlement"] = '0' #核对 defineDict["THOST_FTDC_FUT_Check"] = '1' typedefDict["TThostFtdcFileTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFileFormatType是一个文件格式类型 #////////////////////////////////////////////////////////////////////// #文本文件(.txt) defineDict["THOST_FTDC_FFT_Txt"] = '0' #压缩文件(.zip) defineDict["THOST_FTDC_FFT_Zip"] = '1' #DBF文件(.dbf) defineDict["THOST_FTDC_FFT_DBF"] = '2' typedefDict["TThostFtdcFileFormatType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFileUploadStatusType是一个文件状态类型 #////////////////////////////////////////////////////////////////////// #上传成功 defineDict["THOST_FTDC_FUS_SucceedUpload"] = '1' #上传失败 defineDict["THOST_FTDC_FUS_FailedUpload"] = '2' #导入成功 defineDict["THOST_FTDC_FUS_SucceedLoad"] = '3' #导入部分成功 defineDict["THOST_FTDC_FUS_PartSucceedLoad"] = '4' #导入失败 defineDict["THOST_FTDC_FUS_FailedLoad"] = '5' typedefDict["TThostFtdcFileUploadStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTransferDirectionType是一个移仓方向类型 #////////////////////////////////////////////////////////////////////// #移出 defineDict["THOST_FTDC_TD_Out"] = '0' #移入 defineDict["THOST_FTDC_TD_In"] = '1' typedefDict["TThostFtdcTransferDirectionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUploadModeType是一个上传文件类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUploadModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAccountIDType是一个投资者帐号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAccountIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankFlagType是一个银行统一标识类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankAccountType是一个银行账户类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankAccountType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOpenNameType是一个银行账户的开户人名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOpenNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOpenBankType是一个银行账户的开户行类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOpenBankType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankNameType是一个银行名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPublishPathType是一个发布路径类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPublishPathType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOperatorIDType是一个操作员代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOperatorIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMonthCountType是一个月份数量类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcMonthCountType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcAdvanceMonthArrayType是一个月份提前数组类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAdvanceMonthArrayType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDateExprType是一个日期表达式类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDateExprType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInstrumentIDExprType是一个合约代码表达式类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInstrumentIDExprType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInstrumentNameExprType是一个合约名称表达式类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInstrumentNameExprType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSpecialCreateRuleType是一个特殊的创建规则类型 #////////////////////////////////////////////////////////////////////// #没有特殊创建规则 defineDict["THOST_FTDC_SC_NoSpecialRule"] = '0' #不包含春节 defineDict["THOST_FTDC_SC_NoSpringFestival"] = '1' typedefDict["TThostFtdcSpecialCreateRuleType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBasisPriceTypeType是一个挂牌基准价类型类型 #////////////////////////////////////////////////////////////////////// #上一合约结算价 defineDict["THOST_FTDC_IPT_LastSettlement"] = '1' #上一合约收盘价 defineDict["THOST_FTDC_IPT_LaseClose"] = '2' typedefDict["TThostFtdcBasisPriceTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcProductLifePhaseType是一个产品生命周期状态类型 #////////////////////////////////////////////////////////////////////// #活跃 defineDict["THOST_FTDC_PLP_Active"] = '1' #不活跃 defineDict["THOST_FTDC_PLP_NonActive"] = '2' #注销 defineDict["THOST_FTDC_PLP_Canceled"] = '3' typedefDict["TThostFtdcProductLifePhaseType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDeliveryModeType是一个交割方式类型 #////////////////////////////////////////////////////////////////////// #现金交割 defineDict["THOST_FTDC_DM_CashDeliv"] = '1' #实物交割 defineDict["THOST_FTDC_DM_CommodityDeliv"] = '2' typedefDict["TThostFtdcDeliveryModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcLogLevelType是一个日志级别类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcLogLevelType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcProcessNameType是一个存储过程名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcProcessNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOperationMemoType是一个操作摘要类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOperationMemoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFundIOTypeType是一个出入金类型类型 #////////////////////////////////////////////////////////////////////// #出入金 defineDict["THOST_FTDC_FIOT_FundIO"] = '1' #银期转帐 defineDict["THOST_FTDC_FIOT_Transfer"] = '2' #银期换汇 defineDict["THOST_FTDC_FIOT_SwapCurrency"] = '3' typedefDict["TThostFtdcFundIOTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFundTypeType是一个资金类型类型 #////////////////////////////////////////////////////////////////////// #银行存款 defineDict["THOST_FTDC_FT_Deposite"] = '1' #分项资金 defineDict["THOST_FTDC_FT_ItemFund"] = '2' #公司调整 defineDict["THOST_FTDC_FT_Company"] = '3' #资金内转 defineDict["THOST_FTDC_FT_InnerTransfer"] = '4' typedefDict["TThostFtdcFundTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFundDirectionType是一个出入金方向类型 #////////////////////////////////////////////////////////////////////// #入金 defineDict["THOST_FTDC_FD_In"] = '1' #出金 defineDict["THOST_FTDC_FD_Out"] = '2' typedefDict["TThostFtdcFundDirectionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFundStatusType是一个资金状态类型 #////////////////////////////////////////////////////////////////////// #已录入 defineDict["THOST_FTDC_FS_Record"] = '1' #已复核 defineDict["THOST_FTDC_FS_Check"] = '2' #已冲销 defineDict["THOST_FTDC_FS_Charge"] = '3' typedefDict["TThostFtdcFundStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBillNoType是一个票据号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBillNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBillNameType是一个票据名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBillNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPublishStatusType是一个发布状态类型 #////////////////////////////////////////////////////////////////////// #未发布 defineDict["THOST_FTDC_PS_None"] = '1' #正在发布 defineDict["THOST_FTDC_PS_Publishing"] = '2' #已发布 defineDict["THOST_FTDC_PS_Published"] = '3' typedefDict["TThostFtdcPublishStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcEnumValueIDType是一个枚举值代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcEnumValueIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcEnumValueTypeType是一个枚举值类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcEnumValueTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcEnumValueLabelType是一个枚举值名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcEnumValueLabelType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcEnumValueResultType是一个枚举值结果类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcEnumValueResultType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSystemStatusType是一个系统状态类型 #////////////////////////////////////////////////////////////////////// #不活跃 defineDict["THOST_FTDC_ES_NonActive"] = '1' #启动 defineDict["THOST_FTDC_ES_Startup"] = '2' #交易开始初始化 defineDict["THOST_FTDC_ES_Initialize"] = '3' #交易完成初始化 defineDict["THOST_FTDC_ES_Initialized"] = '4' #收市开始 defineDict["THOST_FTDC_ES_Close"] = '5' #收市完成 defineDict["THOST_FTDC_ES_Closed"] = '6' #结算 defineDict["THOST_FTDC_ES_Settlement"] = '7' typedefDict["TThostFtdcSystemStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSettlementStatusType是一个结算状态类型 #////////////////////////////////////////////////////////////////////// #初始 defineDict["THOST_FTDC_STS_Initialize"] = '0' #结算中 defineDict["THOST_FTDC_STS_Settlementing"] = '1' #已结算 defineDict["THOST_FTDC_STS_Settlemented"] = '2' #结算完成 defineDict["THOST_FTDC_STS_Finished"] = '3' typedefDict["TThostFtdcSettlementStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRangeIntTypeType是一个限定值类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRangeIntTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRangeIntFromType是一个限定值下限类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRangeIntFromType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRangeIntToType是一个限定值上限类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRangeIntToType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFunctionIDType是一个功能代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFunctionIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFunctionValueCodeType是一个功能编码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFunctionValueCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFunctionNameType是一个功能名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFunctionNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRoleIDType是一个角色编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRoleIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRoleNameType是一个角色名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRoleNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDescriptionType是一个描述类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDescriptionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCombineIDType是一个组合编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCombineIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCombineTypeType是一个组合类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCombineTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInvestorTypeType是一个投资者类型类型 #////////////////////////////////////////////////////////////////////// #自然人 defineDict["THOST_FTDC_CT_Person"] = '0' #法人 defineDict["THOST_FTDC_CT_Company"] = '1' #投资基金 defineDict["THOST_FTDC_CT_Fund"] = '2' #特殊法人 defineDict["THOST_FTDC_CT_SpecialOrgan"] = '3' #资管户 defineDict["THOST_FTDC_CT_Asset"] = '4' typedefDict["TThostFtdcInvestorTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBrokerTypeType是一个经纪公司类型类型 #////////////////////////////////////////////////////////////////////// #交易会员 defineDict["THOST_FTDC_BT_Trade"] = '0' #交易结算会员 defineDict["THOST_FTDC_BT_TradeSettle"] = '1' typedefDict["TThostFtdcBrokerTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRiskLevelType是一个风险等级类型 #////////////////////////////////////////////////////////////////////// #低风险客户 defineDict["THOST_FTDC_FAS_Low"] = '1' #普通客户 defineDict["THOST_FTDC_FAS_Normal"] = '2' #关注客户 defineDict["THOST_FTDC_FAS_Focus"] = '3' #风险客户 defineDict["THOST_FTDC_FAS_Risk"] = '4' typedefDict["TThostFtdcRiskLevelType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFeeAcceptStyleType是一个手续费收取方式类型 #////////////////////////////////////////////////////////////////////// #按交易收取 defineDict["THOST_FTDC_FAS_ByTrade"] = '1' #按交割收取 defineDict["THOST_FTDC_FAS_ByDeliv"] = '2' #不收 defineDict["THOST_FTDC_FAS_None"] = '3' #按指定手续费收取 defineDict["THOST_FTDC_FAS_FixFee"] = '4' typedefDict["TThostFtdcFeeAcceptStyleType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPasswordTypeType是一个密码类型类型 #////////////////////////////////////////////////////////////////////// #交易密码 defineDict["THOST_FTDC_PWDT_Trade"] = '1' #资金密码 defineDict["THOST_FTDC_PWDT_Account"] = '2' typedefDict["TThostFtdcPasswordTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAlgorithmType是一个盈亏算法类型 #////////////////////////////////////////////////////////////////////// #浮盈浮亏都计算 defineDict["THOST_FTDC_AG_All"] = '1' #浮盈不计,浮亏计 defineDict["THOST_FTDC_AG_OnlyLost"] = '2' #浮盈计,浮亏不计 defineDict["THOST_FTDC_AG_OnlyGain"] = '3' #浮盈浮亏都不计算 defineDict["THOST_FTDC_AG_None"] = '4' typedefDict["TThostFtdcAlgorithmType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcIncludeCloseProfitType是一个是否包含平仓盈利类型 #////////////////////////////////////////////////////////////////////// #包含平仓盈利 defineDict["THOST_FTDC_ICP_Include"] = '0' #不包含平仓盈利 defineDict["THOST_FTDC_ICP_NotInclude"] = '2' typedefDict["TThostFtdcIncludeCloseProfitType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAllWithoutTradeType是一个是否受可提比例限制类型 #////////////////////////////////////////////////////////////////////// #无仓无成交不受可提比例限制 defineDict["THOST_FTDC_AWT_Enable"] = '0' #受可提比例限制 defineDict["THOST_FTDC_AWT_Disable"] = '2' #无仓不受可提比例限制 defineDict["THOST_FTDC_AWT_NoHoldEnable"] = '3' typedefDict["TThostFtdcAllWithoutTradeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCommentType是一个盈亏算法说明类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCommentType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcVersionType是一个版本号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcVersionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTradeCodeType是一个交易代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTradeCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTradeDateType是一个交易日期类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTradeDateType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTradeTimeType是一个交易时间类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTradeTimeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTradeSerialType是一个发起方流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTradeSerialType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTradeSerialNoType是一个发起方流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTradeSerialNoType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcFutureIDType是一个期货公司代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFutureIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankIDType是一个银行代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankBrchIDType是一个银行分中心代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankBrchIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankBranchIDType是一个分中心代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankBranchIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOperNoType是一个交易柜员类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOperNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDeviceIDType是一个渠道标志类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDeviceIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRecordNumType是一个记录数类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRecordNumType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFutureAccountType是一个期货资金账号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFutureAccountType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFuturePwdFlagType是一个资金密码核对标志类型 #////////////////////////////////////////////////////////////////////// #不核对 defineDict["THOST_FTDC_FPWD_UnCheck"] = '0' #核对 defineDict["THOST_FTDC_FPWD_Check"] = '1' typedefDict["TThostFtdcFuturePwdFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTransferTypeType是一个银期转账类型类型 #////////////////////////////////////////////////////////////////////// #银行转期货 defineDict["THOST_FTDC_TT_BankToFuture"] = '0' #期货转银行 defineDict["THOST_FTDC_TT_FutureToBank"] = '1' typedefDict["TThostFtdcTransferTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFutureAccPwdType是一个期货资金密码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFutureAccPwdType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCurrencyCodeType是一个币种类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCurrencyCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRetCodeType是一个响应代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRetCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRetInfoType是一个响应信息类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRetInfoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTradeAmtType是一个银行总余额类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTradeAmtType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUseAmtType是一个银行可用余额类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUseAmtType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFetchAmtType是一个银行可取余额类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFetchAmtType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTransferValidFlagType是一个转账有效标志类型 #////////////////////////////////////////////////////////////////////// #无效或失败 defineDict["THOST_FTDC_TVF_Invalid"] = '0' #有效 defineDict["THOST_FTDC_TVF_Valid"] = '1' #冲正 defineDict["THOST_FTDC_TVF_Reverse"] = '2' typedefDict["TThostFtdcTransferValidFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCertCodeType是一个证件号码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCertCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcReasonType是一个事由类型 #////////////////////////////////////////////////////////////////////// #错单 defineDict["THOST_FTDC_RN_CD"] = '0' #资金在途 defineDict["THOST_FTDC_RN_ZT"] = '1' #其它 defineDict["THOST_FTDC_RN_QT"] = '2' typedefDict["TThostFtdcReasonType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFundProjectIDType是一个资金项目编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFundProjectIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSexType是一个性别类型 #////////////////////////////////////////////////////////////////////// #未知 defineDict["THOST_FTDC_SEX_None"] = '0' #男 defineDict["THOST_FTDC_SEX_Man"] = '1' #女 defineDict["THOST_FTDC_SEX_Woman"] = '2' typedefDict["TThostFtdcSexType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcProfessionType是一个职业类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcProfessionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcNationalType是一个国籍类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcNationalType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcProvinceType是一个省类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcProvinceType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRegionType是一个区类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRegionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCountryType是一个国家类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCountryType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcLicenseNOType是一个营业执照类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcLicenseNOType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCompanyTypeType是一个企业性质类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCompanyTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBusinessScopeType是一个经营范围类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBusinessScopeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCapitalCurrencyType是一个注册资本币种类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCapitalCurrencyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUserTypeType是一个用户类型类型 #////////////////////////////////////////////////////////////////////// #投资者 defineDict["THOST_FTDC_UT_Investor"] = '0' #操作员 defineDict["THOST_FTDC_UT_Operator"] = '1' #管理员 defineDict["THOST_FTDC_UT_SuperUser"] = '2' typedefDict["TThostFtdcUserTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRateTypeType是一个费率类型类型 #////////////////////////////////////////////////////////////////////// #保证金率 defineDict["THOST_FTDC_RATETYPE_MarginRate"] = '2' typedefDict["TThostFtdcRateTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcNoteTypeType是一个通知类型类型 #////////////////////////////////////////////////////////////////////// #交易结算单 defineDict["THOST_FTDC_NOTETYPE_TradeSettleBill"] = '1' #交易结算月报 defineDict["THOST_FTDC_NOTETYPE_TradeSettleMonth"] = '2' #追加保证金通知书 defineDict["THOST_FTDC_NOTETYPE_CallMarginNotes"] = '3' #强行平仓通知书 defineDict["THOST_FTDC_NOTETYPE_ForceCloseNotes"] = '4' #成交通知书 defineDict["THOST_FTDC_NOTETYPE_TradeNotes"] = '5' #交割通知书 defineDict["THOST_FTDC_NOTETYPE_DelivNotes"] = '6' typedefDict["TThostFtdcNoteTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSettlementStyleType是一个结算单方式类型 #////////////////////////////////////////////////////////////////////// #逐日盯市 defineDict["THOST_FTDC_SBS_Day"] = '1' #逐笔对冲 defineDict["THOST_FTDC_SBS_Volume"] = '2' typedefDict["TThostFtdcSettlementStyleType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBrokerDNSType是一个域名类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBrokerDNSType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSentenceType是一个语句类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSentenceType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSettlementBillTypeType是一个结算单类型类型 #////////////////////////////////////////////////////////////////////// #日报 defineDict["THOST_FTDC_ST_Day"] = '0' #月报 defineDict["THOST_FTDC_ST_Month"] = '1' typedefDict["TThostFtdcSettlementBillTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUserRightTypeType是一个客户权限类型类型 #////////////////////////////////////////////////////////////////////// #登录 defineDict["THOST_FTDC_URT_Logon"] = '1' #银期转帐 defineDict["THOST_FTDC_URT_Transfer"] = '2' #邮寄结算单 defineDict["THOST_FTDC_URT_EMail"] = '3' #传真结算单 defineDict["THOST_FTDC_URT_Fax"] = '4' #条件单 defineDict["THOST_FTDC_URT_ConditionOrder"] = '5' typedefDict["TThostFtdcUserRightTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMarginPriceTypeType是一个保证金价格类型类型 #////////////////////////////////////////////////////////////////////// #昨结算价 defineDict["THOST_FTDC_MPT_PreSettlementPrice"] = '1' #最新价 defineDict["THOST_FTDC_MPT_SettlementPrice"] = '2' #成交均价 defineDict["THOST_FTDC_MPT_AveragePrice"] = '3' #开仓价 defineDict["THOST_FTDC_MPT_OpenPrice"] = '4' typedefDict["TThostFtdcMarginPriceTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBillGenStatusType是一个结算单生成状态类型 #////////////////////////////////////////////////////////////////////// #未生成 defineDict["THOST_FTDC_BGS_None"] = '0' #生成中 defineDict["THOST_FTDC_BGS_NoGenerated"] = '1' #已生成 defineDict["THOST_FTDC_BGS_Generated"] = '2' typedefDict["TThostFtdcBillGenStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAlgoTypeType是一个算法类型类型 #////////////////////////////////////////////////////////////////////// #持仓处理算法 defineDict["THOST_FTDC_AT_HandlePositionAlgo"] = '1' #寻找保证金率算法 defineDict["THOST_FTDC_AT_FindMarginRateAlgo"] = '2' typedefDict["TThostFtdcAlgoTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcHandlePositionAlgoIDType是一个持仓处理算法编号类型 #////////////////////////////////////////////////////////////////////// #基本 defineDict["THOST_FTDC_HPA_Base"] = '1' #大连商品交易所 defineDict["THOST_FTDC_HPA_DCE"] = '2' #郑州商品交易所 defineDict["THOST_FTDC_HPA_CZCE"] = '3' typedefDict["TThostFtdcHandlePositionAlgoIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFindMarginRateAlgoIDType是一个寻找保证金率算法编号类型 #////////////////////////////////////////////////////////////////////// #基本 defineDict["THOST_FTDC_FMRA_Base"] = '1' #大连商品交易所 defineDict["THOST_FTDC_FMRA_DCE"] = '2' #郑州商品交易所 defineDict["THOST_FTDC_FMRA_CZCE"] = '3' typedefDict["TThostFtdcFindMarginRateAlgoIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcHandleTradingAccountAlgoIDType是一个资金处理算法编号类型 #////////////////////////////////////////////////////////////////////// #基本 defineDict["THOST_FTDC_HTAA_Base"] = '1' #大连商品交易所 defineDict["THOST_FTDC_HTAA_DCE"] = '2' #郑州商品交易所 defineDict["THOST_FTDC_HTAA_CZCE"] = '3' typedefDict["TThostFtdcHandleTradingAccountAlgoIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPersonTypeType是一个联系人类型类型 #////////////////////////////////////////////////////////////////////// #指定下单人 defineDict["THOST_FTDC_PST_Order"] = '1' #开户授权人 defineDict["THOST_FTDC_PST_Open"] = '2' #资金调拨人 defineDict["THOST_FTDC_PST_Fund"] = '3' #结算单确认人 defineDict["THOST_FTDC_PST_Settlement"] = '4' #法人 defineDict["THOST_FTDC_PST_Company"] = '5' #法人代表 defineDict["THOST_FTDC_PST_Corporation"] = '6' #投资者联系人 defineDict["THOST_FTDC_PST_LinkMan"] = '7' #分户管理资产负责人 defineDict["THOST_FTDC_PST_Ledger"] = '8' #托(保)管人 defineDict["THOST_FTDC_PST_Trustee"] = '9' #托(保)管机构法人代表 defineDict["THOST_FTDC_PST_TrusteeCorporation"] = 'A' #托(保)管机构开户授权人 defineDict["THOST_FTDC_PST_TrusteeOpen"] = 'B' #托(保)管机构联系人 defineDict["THOST_FTDC_PST_TrusteeContact"] = 'C' #境外自然人参考证件 defineDict["THOST_FTDC_PST_ForeignerRefer"] = 'D' #法人代表参考证件 defineDict["THOST_FTDC_PST_CorporationRefer"] = 'E' typedefDict["TThostFtdcPersonTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcQueryInvestorRangeType是一个查询范围类型 #////////////////////////////////////////////////////////////////////// #所有 defineDict["THOST_FTDC_QIR_All"] = '1' #查询分类 defineDict["THOST_FTDC_QIR_Group"] = '2' #单一投资者 defineDict["THOST_FTDC_QIR_Single"] = '3' typedefDict["TThostFtdcQueryInvestorRangeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInvestorRiskStatusType是一个投资者风险状态类型 #////////////////////////////////////////////////////////////////////// #正常 defineDict["THOST_FTDC_IRS_Normal"] = '1' #警告 defineDict["THOST_FTDC_IRS_Warn"] = '2' #追保 defineDict["THOST_FTDC_IRS_Call"] = '3' #强平 defineDict["THOST_FTDC_IRS_Force"] = '4' #异常 defineDict["THOST_FTDC_IRS_Exception"] = '5' typedefDict["TThostFtdcInvestorRiskStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcLegIDType是一个单腿编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcLegIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcLegMultipleType是一个单腿乘数类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcLegMultipleType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcImplyLevelType是一个派生层数类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcImplyLevelType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcClearAccountType是一个结算账户类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcClearAccountType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrganNOType是一个结算账户类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOrganNOType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcClearbarchIDType是一个结算账户联行号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcClearbarchIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUserEventTypeType是一个用户事件类型类型 #////////////////////////////////////////////////////////////////////// #登录 defineDict["THOST_FTDC_UET_Login"] = '1' #登出 defineDict["THOST_FTDC_UET_Logout"] = '2' #交易成功 defineDict["THOST_FTDC_UET_Trading"] = '3' #交易失败 defineDict["THOST_FTDC_UET_TradingError"] = '4' #修改密码 defineDict["THOST_FTDC_UET_UpdatePassword"] = '5' #客户端认证 defineDict["THOST_FTDC_UET_Authenticate"] = '6' #其他 defineDict["THOST_FTDC_UET_Other"] = '9' typedefDict["TThostFtdcUserEventTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUserEventInfoType是一个用户事件信息类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUserEventInfoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCloseStyleType是一个平仓方式类型 #////////////////////////////////////////////////////////////////////// #先开先平 defineDict["THOST_FTDC_ICS_Close"] = '0' #先平今再平昨 defineDict["THOST_FTDC_ICS_CloseToday"] = '1' typedefDict["TThostFtdcCloseStyleType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcStatModeType是一个统计方式类型 #////////////////////////////////////////////////////////////////////// #---- defineDict["THOST_FTDC_SM_Non"] = '0' #按合约统计 defineDict["THOST_FTDC_SM_Instrument"] = '1' #按产品统计 defineDict["THOST_FTDC_SM_Product"] = '2' #按投资者统计 defineDict["THOST_FTDC_SM_Investor"] = '3' typedefDict["TThostFtdcStatModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcParkedOrderStatusType是一个预埋单状态类型 #////////////////////////////////////////////////////////////////////// #未发送 defineDict["THOST_FTDC_PAOS_NotSend"] = '1' #已发送 defineDict["THOST_FTDC_PAOS_Send"] = '2' #已删除 defineDict["THOST_FTDC_PAOS_Deleted"] = '3' typedefDict["TThostFtdcParkedOrderStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcParkedOrderIDType是一个预埋报单编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcParkedOrderIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcParkedOrderActionIDType是一个预埋撤单编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcParkedOrderActionIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcVirDealStatusType是一个处理状态类型 #////////////////////////////////////////////////////////////////////// #正在处理 defineDict["THOST_FTDC_VDS_Dealing"] = '1' #处理成功 defineDict["THOST_FTDC_VDS_DeaclSucceed"] = '2' typedefDict["TThostFtdcVirDealStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrgSystemIDType是一个原有系统代码类型 #////////////////////////////////////////////////////////////////////// #综合交易平台 defineDict["THOST_FTDC_ORGS_Standard"] = '0' #易盛系统 defineDict["THOST_FTDC_ORGS_ESunny"] = '1' #金仕达V6系统 defineDict["THOST_FTDC_ORGS_KingStarV6"] = '2' typedefDict["TThostFtdcOrgSystemIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcVirTradeStatusType是一个交易状态类型 #////////////////////////////////////////////////////////////////////// #正常处理中 defineDict["THOST_FTDC_VTS_NaturalDeal"] = '0' #成功结束 defineDict["THOST_FTDC_VTS_SucceedEnd"] = '1' #失败结束 defineDict["THOST_FTDC_VTS_FailedEND"] = '2' #异常中 defineDict["THOST_FTDC_VTS_Exception"] = '3' #已人工异常处理 defineDict["THOST_FTDC_VTS_ManualDeal"] = '4' #通讯异常 ,请人工处理 defineDict["THOST_FTDC_VTS_MesException"] = '5' #系统出错,请人工处理 defineDict["THOST_FTDC_VTS_SysException"] = '6' typedefDict["TThostFtdcVirTradeStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcVirBankAccTypeType是一个银行帐户类型类型 #////////////////////////////////////////////////////////////////////// #存折 defineDict["THOST_FTDC_VBAT_BankBook"] = '1' #储蓄卡 defineDict["THOST_FTDC_VBAT_BankCard"] = '2' #信用卡 defineDict["THOST_FTDC_VBAT_CreditCard"] = '3' typedefDict["TThostFtdcVirBankAccTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcVirementStatusType是一个银行帐户类型类型 #////////////////////////////////////////////////////////////////////// #正常 defineDict["THOST_FTDC_VMS_Natural"] = '0' #销户 defineDict["THOST_FTDC_VMS_Canceled"] = '9' typedefDict["TThostFtdcVirementStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcVirementAvailAbilityType是一个有效标志类型 #////////////////////////////////////////////////////////////////////// #未确认 defineDict["THOST_FTDC_VAA_NoAvailAbility"] = '0' #有效 defineDict["THOST_FTDC_VAA_AvailAbility"] = '1' #冲正 defineDict["THOST_FTDC_VAA_Repeal"] = '2' typedefDict["TThostFtdcVirementAvailAbilityType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcVirementTradeCodeType是一个交易代码类型 #////////////////////////////////////////////////////////////////////// #银行发起银行资金转期货 defineDict["THOST_FTDC_VTC_BankBankToFuture"] = '102001' #银行发起期货资金转银行 defineDict["THOST_FTDC_VTC_BankFutureToBank"] = '102002' #期货发起银行资金转期货 defineDict["THOST_FTDC_VTC_FutureBankToFuture"] = '202001' #期货发起期货资金转银行 defineDict["THOST_FTDC_VTC_FutureFutureToBank"] = '202002' typedefDict["TThostFtdcVirementTradeCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPhotoTypeNameType是一个影像类型名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPhotoTypeNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPhotoTypeIDType是一个影像类型代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPhotoTypeIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPhotoNameType是一个影像名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPhotoNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTopicIDType是一个主题代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTopicIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcReportTypeIDType是一个交易报告类型标识类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcReportTypeIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCharacterIDType是一个交易特征代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCharacterIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLParamIDType是一个参数代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLParamIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLInvestorTypeType是一个投资者类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLInvestorTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLIdCardTypeType是一个证件类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLIdCardTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLTradeDirectType是一个资金进出方向类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLTradeDirectType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLTradeModelType是一个资金进出方式类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLTradeModelType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLParamIDType是一个参数代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLParamIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLOpParamValueType是一个业务参数代码值类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLOpParamValueType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcAMLCustomerCardTypeType是一个客户身份证件/证明文件类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLCustomerCardTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLInstitutionNameType是一个金融机构网点名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLInstitutionNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLDistrictIDType是一个金融机构网点所在地区行政区划代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLDistrictIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLRelationShipType是一个金融机构网点与大额交易的关系类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLRelationShipType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLInstitutionTypeType是一个金融机构网点代码类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLInstitutionTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLInstitutionIDType是一个金融机构网点代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLInstitutionIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLAccountTypeType是一个账户类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLAccountTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLTradingTypeType是一个交易方式类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLTradingTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLTransactClassType是一个涉外收支交易分类与代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLTransactClassType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLCapitalIOType是一个资金收付标识类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLCapitalIOType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLSiteType是一个交易地点类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLSiteType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLCapitalPurposeType是一个资金用途类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLCapitalPurposeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLReportTypeType是一个报文类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLReportTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLSerialNoType是一个编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLSerialNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLStatusType是一个状态类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLGenStatusType是一个Aml生成方式类型 #////////////////////////////////////////////////////////////////////// #程序生成 defineDict["THOST_FTDC_GEN_Program"] = '0' #人工生成 defineDict["THOST_FTDC_GEN_HandWork"] = '1' typedefDict["TThostFtdcAMLGenStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLSeqCodeType是一个业务标识号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLSeqCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLFileNameType是一个AML文件名类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLFileNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLMoneyType是一个反洗钱资金类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLMoneyType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcAMLFileAmountType是一个反洗钱资金类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLFileAmountType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcCFMMCKeyType是一个密钥类型(保证金监管)类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCFMMCKeyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCFMMCKeyKindType是一个动态密钥类别(保证金监管)类型 #////////////////////////////////////////////////////////////////////// #主动请求更新 defineDict["THOST_FTDC_CFMMCKK_REQUEST"] = 'R' #CFMMC自动更新 defineDict["THOST_FTDC_CFMMCKK_AUTO"] = 'A' #CFMMC手动更新 defineDict["THOST_FTDC_CFMMCKK_MANUAL"] = 'M' typedefDict["TThostFtdcCFMMCKeyKindType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLReportNameType是一个报文名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAMLReportNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcIndividualNameType是一个个人姓名类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcIndividualNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCurrencyIDType是一个币种代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCurrencyIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCustNumberType是一个客户编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCustNumberType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrganCodeType是一个机构编码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOrganCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrganNameType是一个机构名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOrganNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSuperOrganCodeType是一个上级机构编码,即期货公司总部、银行总行类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSuperOrganCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSubBranchIDType是一个分支机构类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSubBranchIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSubBranchNameType是一个分支机构名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSubBranchNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBranchNetCodeType是一个机构网点号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBranchNetCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBranchNetNameType是一个机构网点名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBranchNetNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrganFlagType是一个机构标识类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOrganFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankCodingForFutureType是一个银行对期货公司的编码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankCodingForFutureType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankReturnCodeType是一个银行对返回码的定义类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankReturnCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPlateReturnCodeType是一个银期转帐平台对返回码的定义类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPlateReturnCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankSubBranchIDType是一个银行分支机构编码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankSubBranchIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFutureBranchIDType是一个期货分支机构编码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFutureBranchIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcReturnCodeType是一个返回代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcReturnCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOperatorCodeType是一个操作员类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOperatorCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcClearDepIDType是一个机构结算帐户机构号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcClearDepIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcClearBrchIDType是一个机构结算帐户联行号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcClearBrchIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcClearNameType是一个机构结算帐户名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcClearNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankAccountNameType是一个银行帐户名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankAccountNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInvDepIDType是一个机构投资人账号机构号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInvDepIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInvBrchIDType是一个机构投资人联行号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInvBrchIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMessageFormatVersionType是一个信息格式版本类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcMessageFormatVersionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDigestType是一个摘要类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDigestType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAuthenticDataType是一个认证数据类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAuthenticDataType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPasswordKeyType是一个密钥类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPasswordKeyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFutureAccountNameType是一个期货帐户名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFutureAccountNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMobilePhoneType是一个手机类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcMobilePhoneType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFutureMainKeyType是一个期货公司主密钥类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFutureMainKeyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFutureWorkKeyType是一个期货公司工作密钥类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFutureWorkKeyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFutureTransKeyType是一个期货公司传输密钥类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFutureTransKeyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankMainKeyType是一个银行主密钥类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankMainKeyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankWorkKeyType是一个银行工作密钥类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankWorkKeyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankTransKeyType是一个银行传输密钥类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankTransKeyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankServerDescriptionType是一个银行服务器描述信息类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankServerDescriptionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAddInfoType是一个附加信息类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAddInfoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDescrInfoForReturnCodeType是一个返回码描述类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDescrInfoForReturnCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCountryCodeType是一个国家代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCountryCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSerialType是一个流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSerialType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcPlateSerialType是一个平台流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPlateSerialType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcBankSerialType是一个银行流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankSerialType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCorrectSerialType是一个被冲正交易流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCorrectSerialType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcFutureSerialType是一个期货公司流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFutureSerialType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcApplicationIDType是一个应用标识类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcApplicationIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcBankProxyIDType是一个银行代理标识类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankProxyIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcFBTCoreIDType是一个银期转帐核心系统标识类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBTCoreIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcServerPortType是一个服务端口号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcServerPortType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcRepealedTimesType是一个已经冲正次数类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRepealedTimesType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcRepealTimeIntervalType是一个冲正时间间隔类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRepealTimeIntervalType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcTotalTimesType是一个每日累计转帐次数类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTotalTimesType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcFBTRequestIDType是一个请求ID类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBTRequestIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcTIDType是一个交易ID类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcTradeAmountType是一个交易金额(元)类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTradeAmountType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcCustFeeType是一个应收客户费用(元)类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCustFeeType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcFutureFeeType是一个应收期货公司费用(元)类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFutureFeeType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcSingleMaxAmtType是一个单笔最高限额类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSingleMaxAmtType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcSingleMinAmtType是一个单笔最低限额类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSingleMinAmtType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcTotalAmtType是一个每日累计转帐额度类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTotalAmtType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcCertificationTypeType是一个证件类型类型 #////////////////////////////////////////////////////////////////////// #身份证 defineDict["THOST_FTDC_CFT_IDCard"] = '0' #护照 defineDict["THOST_FTDC_CFT_Passport"] = '1' #军官证 defineDict["THOST_FTDC_CFT_OfficerIDCard"] = '2' #士兵证 defineDict["THOST_FTDC_CFT_SoldierIDCard"] = '3' #回乡证 defineDict["THOST_FTDC_CFT_HomeComingCard"] = '4' #户口簿 defineDict["THOST_FTDC_CFT_HouseholdRegister"] = '5' #营业执照号 defineDict["THOST_FTDC_CFT_LicenseNo"] = '6' #组织机构代码证 defineDict["THOST_FTDC_CFT_InstitutionCodeCard"] = '7' #临时营业执照号 defineDict["THOST_FTDC_CFT_TempLicenseNo"] = '8' #民办非企业登记证书 defineDict["THOST_FTDC_CFT_NoEnterpriseLicenseNo"] = '9' #其他证件 defineDict["THOST_FTDC_CFT_OtherCard"] = 'x' #主管部门批文 defineDict["THOST_FTDC_CFT_SuperDepAgree"] = 'a' typedefDict["TThostFtdcCertificationTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFileBusinessCodeType是一个文件业务功能类型 #////////////////////////////////////////////////////////////////////// #其他 defineDict["THOST_FTDC_FBC_Others"] = '0' #转账交易明细对账 defineDict["THOST_FTDC_FBC_TransferDetails"] = '1' #客户账户状态对账 defineDict["THOST_FTDC_FBC_CustAccStatus"] = '2' #账户类交易明细对账 defineDict["THOST_FTDC_FBC_AccountTradeDetails"] = '3' #期货账户信息变更明细对账 defineDict["THOST_FTDC_FBC_FutureAccountChangeInfoDetails"] = '4' #客户资金台账余额明细对账 defineDict["THOST_FTDC_FBC_CustMoneyDetail"] = '5' #客户销户结息明细对账 defineDict["THOST_FTDC_FBC_CustCancelAccountInfo"] = '6' #客户资金余额对账结果 defineDict["THOST_FTDC_FBC_CustMoneyResult"] = '7' #其它对账异常结果文件 defineDict["THOST_FTDC_FBC_OthersExceptionResult"] = '8' #客户结息净额明细 defineDict["THOST_FTDC_FBC_CustInterestNetMoneyDetails"] = '9' #客户资金交收明细 defineDict["THOST_FTDC_FBC_CustMoneySendAndReceiveDetails"] = 'a' #法人存管银行资金交收汇总 defineDict["THOST_FTDC_FBC_CorporationMoneyTotal"] = 'b' #主体间资金交收汇总 defineDict["THOST_FTDC_FBC_MainbodyMoneyTotal"] = 'c' #总分平衡监管数据 defineDict["THOST_FTDC_FBC_MainPartMonitorData"] = 'd' #存管银行备付金余额 defineDict["THOST_FTDC_FBC_PreparationMoney"] = 'e' #协办存管银行资金监管数据 defineDict["THOST_FTDC_FBC_BankMoneyMonitorData"] = 'f' typedefDict["TThostFtdcFileBusinessCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCashExchangeCodeType是一个汇钞标志类型 #////////////////////////////////////////////////////////////////////// #汇 defineDict["THOST_FTDC_CEC_Exchange"] = '1' #钞 defineDict["THOST_FTDC_CEC_Cash"] = '2' typedefDict["TThostFtdcCashExchangeCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcYesNoIndicatorType是一个是或否标识类型 #////////////////////////////////////////////////////////////////////// #是 defineDict["THOST_FTDC_YNI_Yes"] = '0' #否 defineDict["THOST_FTDC_YNI_No"] = '1' typedefDict["TThostFtdcYesNoIndicatorType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBanlanceTypeType是一个余额类型类型 #////////////////////////////////////////////////////////////////////// #当前余额 defineDict["THOST_FTDC_BLT_CurrentMoney"] = '0' #可用余额 defineDict["THOST_FTDC_BLT_UsableMoney"] = '1' #可取余额 defineDict["THOST_FTDC_BLT_FetchableMoney"] = '2' #冻结余额 defineDict["THOST_FTDC_BLT_FreezeMoney"] = '3' typedefDict["TThostFtdcBanlanceTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcGenderType是一个性别类型 #////////////////////////////////////////////////////////////////////// #未知状态 defineDict["THOST_FTDC_GD_Unknown"] = '0' #男 defineDict["THOST_FTDC_GD_Male"] = '1' #女 defineDict["THOST_FTDC_GD_Female"] = '2' typedefDict["TThostFtdcGenderType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFeePayFlagType是一个费用支付标志类型 #////////////////////////////////////////////////////////////////////// #由受益方支付费用 defineDict["THOST_FTDC_FPF_BEN"] = '0' #由发送方支付费用 defineDict["THOST_FTDC_FPF_OUR"] = '1' #由发送方支付发起的费用,受益方支付接受的费用 defineDict["THOST_FTDC_FPF_SHA"] = '2' typedefDict["TThostFtdcFeePayFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPassWordKeyTypeType是一个密钥类型类型 #////////////////////////////////////////////////////////////////////// #交换密钥 defineDict["THOST_FTDC_PWKT_ExchangeKey"] = '0' #密码密钥 defineDict["THOST_FTDC_PWKT_PassWordKey"] = '1' #MAC密钥 defineDict["THOST_FTDC_PWKT_MACKey"] = '2' #报文密钥 defineDict["THOST_FTDC_PWKT_MessageKey"] = '3' typedefDict["TThostFtdcPassWordKeyTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBTPassWordTypeType是一个密码类型类型 #////////////////////////////////////////////////////////////////////// #查询 defineDict["THOST_FTDC_PWT_Query"] = '0' #取款 defineDict["THOST_FTDC_PWT_Fetch"] = '1' #转帐 defineDict["THOST_FTDC_PWT_Transfer"] = '2' #交易 defineDict["THOST_FTDC_PWT_Trade"] = '3' typedefDict["TThostFtdcFBTPassWordTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBTEncryModeType是一个加密方式类型 #////////////////////////////////////////////////////////////////////// #不加密 defineDict["THOST_FTDC_EM_NoEncry"] = '0' #DES defineDict["THOST_FTDC_EM_DES"] = '1' #3DES defineDict["THOST_FTDC_EM_3DES"] = '2' typedefDict["TThostFtdcFBTEncryModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankRepealFlagType是一个银行冲正标志类型 #////////////////////////////////////////////////////////////////////// #银行无需自动冲正 defineDict["THOST_FTDC_BRF_BankNotNeedRepeal"] = '0' #银行待自动冲正 defineDict["THOST_FTDC_BRF_BankWaitingRepeal"] = '1' #银行已自动冲正 defineDict["THOST_FTDC_BRF_BankBeenRepealed"] = '2' typedefDict["TThostFtdcBankRepealFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBrokerRepealFlagType是一个期商冲正标志类型 #////////////////////////////////////////////////////////////////////// #期商无需自动冲正 defineDict["THOST_FTDC_BRORF_BrokerNotNeedRepeal"] = '0' #期商待自动冲正 defineDict["THOST_FTDC_BRORF_BrokerWaitingRepeal"] = '1' #期商已自动冲正 defineDict["THOST_FTDC_BRORF_BrokerBeenRepealed"] = '2' typedefDict["TThostFtdcBrokerRepealFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInstitutionTypeType是一个机构类别类型 #////////////////////////////////////////////////////////////////////// #银行 defineDict["THOST_FTDC_TS_Bank"] = '0' #期商 defineDict["THOST_FTDC_TS_Future"] = '1' #券商 defineDict["THOST_FTDC_TS_Store"] = '2' typedefDict["TThostFtdcInstitutionTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcLastFragmentType是一个最后分片标志类型 #////////////////////////////////////////////////////////////////////// #是最后分片 defineDict["THOST_FTDC_LF_Yes"] = '0' #不是最后分片 defineDict["THOST_FTDC_LF_No"] = '1' typedefDict["TThostFtdcLastFragmentType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankAccStatusType是一个银行账户状态类型 #////////////////////////////////////////////////////////////////////// #正常 defineDict["THOST_FTDC_BAS_Normal"] = '0' #冻结 defineDict["THOST_FTDC_BAS_Freeze"] = '1' #挂失 defineDict["THOST_FTDC_BAS_ReportLoss"] = '2' typedefDict["TThostFtdcBankAccStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMoneyAccountStatusType是一个资金账户状态类型 #////////////////////////////////////////////////////////////////////// #正常 defineDict["THOST_FTDC_MAS_Normal"] = '0' #销户 defineDict["THOST_FTDC_MAS_Cancel"] = '1' typedefDict["TThostFtdcMoneyAccountStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcManageStatusType是一个存管状态类型 #////////////////////////////////////////////////////////////////////// #指定存管 defineDict["THOST_FTDC_MSS_Point"] = '0' #预指定 defineDict["THOST_FTDC_MSS_PrePoint"] = '1' #撤销指定 defineDict["THOST_FTDC_MSS_CancelPoint"] = '2' typedefDict["TThostFtdcManageStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSystemTypeType是一个应用系统类型类型 #////////////////////////////////////////////////////////////////////// #银期转帐 defineDict["THOST_FTDC_SYT_FutureBankTransfer"] = '0' #银证转帐 defineDict["THOST_FTDC_SYT_StockBankTransfer"] = '1' #第三方存管 defineDict["THOST_FTDC_SYT_TheThirdPartStore"] = '2' typedefDict["TThostFtdcSystemTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTxnEndFlagType是一个银期转帐划转结果标志类型 #////////////////////////////////////////////////////////////////////// #正常处理中 defineDict["THOST_FTDC_TEF_NormalProcessing"] = '0' #成功结束 defineDict["THOST_FTDC_TEF_Success"] = '1' #失败结束 defineDict["THOST_FTDC_TEF_Failed"] = '2' #异常中 defineDict["THOST_FTDC_TEF_Abnormal"] = '3' #已人工异常处理 defineDict["THOST_FTDC_TEF_ManualProcessedForException"] = '4' #通讯异常 ,请人工处理 defineDict["THOST_FTDC_TEF_CommuFailedNeedManualProcess"] = '5' #系统出错,请人工处理 defineDict["THOST_FTDC_TEF_SysErrorNeedManualProcess"] = '6' typedefDict["TThostFtdcTxnEndFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcProcessStatusType是一个银期转帐服务处理状态类型 #////////////////////////////////////////////////////////////////////// #未处理 defineDict["THOST_FTDC_PSS_NotProcess"] = '0' #开始处理 defineDict["THOST_FTDC_PSS_StartProcess"] = '1' #处理完成 defineDict["THOST_FTDC_PSS_Finished"] = '2' typedefDict["TThostFtdcProcessStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCustTypeType是一个客户类型类型 #////////////////////////////////////////////////////////////////////// #自然人 defineDict["THOST_FTDC_CUSTT_Person"] = '0' #机构户 defineDict["THOST_FTDC_CUSTT_Institution"] = '1' typedefDict["TThostFtdcCustTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBTTransferDirectionType是一个银期转帐方向类型 #////////////////////////////////////////////////////////////////////// #入金,银行转期货 defineDict["THOST_FTDC_FBTTD_FromBankToFuture"] = '1' #出金,期货转银行 defineDict["THOST_FTDC_FBTTD_FromFutureToBank"] = '2' typedefDict["TThostFtdcFBTTransferDirectionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOpenOrDestroyType是一个开销户类别类型 #////////////////////////////////////////////////////////////////////// #开户 defineDict["THOST_FTDC_OOD_Open"] = '1' #销户 defineDict["THOST_FTDC_OOD_Destroy"] = '0' typedefDict["TThostFtdcOpenOrDestroyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAvailabilityFlagType是一个有效标志类型 #////////////////////////////////////////////////////////////////////// #未确认 defineDict["THOST_FTDC_AVAF_Invalid"] = '0' #有效 defineDict["THOST_FTDC_AVAF_Valid"] = '1' #冲正 defineDict["THOST_FTDC_AVAF_Repeal"] = '2' typedefDict["TThostFtdcAvailabilityFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrganTypeType是一个机构类型类型 #////////////////////////////////////////////////////////////////////// #银行代理 defineDict["THOST_FTDC_OT_Bank"] = '1' #交易前置 defineDict["THOST_FTDC_OT_Future"] = '2' #银期转帐平台管理 defineDict["THOST_FTDC_OT_PlateForm"] = '9' typedefDict["TThostFtdcOrganTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrganLevelType是一个机构级别类型 #////////////////////////////////////////////////////////////////////// #银行总行或期商总部 defineDict["THOST_FTDC_OL_HeadQuarters"] = '1' #银行分中心或期货公司营业部 defineDict["THOST_FTDC_OL_Branch"] = '2' typedefDict["TThostFtdcOrganLevelType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcProtocalIDType是一个协议类型类型 #////////////////////////////////////////////////////////////////////// #期商协议 defineDict["THOST_FTDC_PID_FutureProtocal"] = '0' #工行协议 defineDict["THOST_FTDC_PID_ICBCProtocal"] = '1' #农行协议 defineDict["THOST_FTDC_PID_ABCProtocal"] = '2' #中国银行协议 defineDict["THOST_FTDC_PID_CBCProtocal"] = '3' #建行协议 defineDict["THOST_FTDC_PID_CCBProtocal"] = '4' #交行协议 defineDict["THOST_FTDC_PID_BOCOMProtocal"] = '5' #银期转帐平台协议 defineDict["THOST_FTDC_PID_FBTPlateFormProtocal"] = 'X' typedefDict["TThostFtdcProtocalIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcConnectModeType是一个套接字连接方式类型 #////////////////////////////////////////////////////////////////////// #短连接 defineDict["THOST_FTDC_CM_ShortConnect"] = '0' #长连接 defineDict["THOST_FTDC_CM_LongConnect"] = '1' typedefDict["TThostFtdcConnectModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSyncModeType是一个套接字通信方式类型 #////////////////////////////////////////////////////////////////////// #异步 defineDict["THOST_FTDC_SRM_ASync"] = '0' #同步 defineDict["THOST_FTDC_SRM_Sync"] = '1' typedefDict["TThostFtdcSyncModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankAccTypeType是一个银行帐号类型类型 #////////////////////////////////////////////////////////////////////// #银行存折 defineDict["THOST_FTDC_BAT_BankBook"] = '1' #储蓄卡 defineDict["THOST_FTDC_BAT_SavingCard"] = '2' #信用卡 defineDict["THOST_FTDC_BAT_CreditCard"] = '3' typedefDict["TThostFtdcBankAccTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFutureAccTypeType是一个期货公司帐号类型类型 #////////////////////////////////////////////////////////////////////// #银行存折 defineDict["THOST_FTDC_FAT_BankBook"] = '1' #储蓄卡 defineDict["THOST_FTDC_FAT_SavingCard"] = '2' #信用卡 defineDict["THOST_FTDC_FAT_CreditCard"] = '3' typedefDict["TThostFtdcFutureAccTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOrganStatusType是一个接入机构状态类型 #////////////////////////////////////////////////////////////////////// #启用 defineDict["THOST_FTDC_OS_Ready"] = '0' #签到 defineDict["THOST_FTDC_OS_CheckIn"] = '1' #签退 defineDict["THOST_FTDC_OS_CheckOut"] = '2' #对帐文件到达 defineDict["THOST_FTDC_OS_CheckFileArrived"] = '3' #对帐 defineDict["THOST_FTDC_OS_CheckDetail"] = '4' #日终清理 defineDict["THOST_FTDC_OS_DayEndClean"] = '5' #注销 defineDict["THOST_FTDC_OS_Invalid"] = '9' typedefDict["TThostFtdcOrganStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCCBFeeModeType是一个建行收费模式类型 #////////////////////////////////////////////////////////////////////// #按金额扣收 defineDict["THOST_FTDC_CCBFM_ByAmount"] = '1' #按月扣收 defineDict["THOST_FTDC_CCBFM_ByMonth"] = '2' typedefDict["TThostFtdcCCBFeeModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCommApiTypeType是一个通讯API类型类型 #////////////////////////////////////////////////////////////////////// #客户端 defineDict["THOST_FTDC_CAPIT_Client"] = '1' #服务端 defineDict["THOST_FTDC_CAPIT_Server"] = '2' #交易系统的UserApi defineDict["THOST_FTDC_CAPIT_UserApi"] = '3' typedefDict["TThostFtdcCommApiTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcServiceIDType是一个服务编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcServiceIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcServiceLineNoType是一个服务线路编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcServiceLineNoType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcServiceNameType是一个服务名类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcServiceNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcLinkStatusType是一个连接状态类型 #////////////////////////////////////////////////////////////////////// #已经连接 defineDict["THOST_FTDC_LS_Connected"] = '1' #没有连接 defineDict["THOST_FTDC_LS_Disconnected"] = '2' typedefDict["TThostFtdcLinkStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCommApiPointerType是一个通讯API指针类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCommApiPointerType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcPwdFlagType是一个密码核对标志类型 #////////////////////////////////////////////////////////////////////// #不核对 defineDict["THOST_FTDC_BPWDF_NoCheck"] = '0' #明文核对 defineDict["THOST_FTDC_BPWDF_BlankCheck"] = '1' #密文核对 defineDict["THOST_FTDC_BPWDF_EncryptCheck"] = '2' typedefDict["TThostFtdcPwdFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSecuAccTypeType是一个期货帐号类型类型 #////////////////////////////////////////////////////////////////////// #资金帐号 defineDict["THOST_FTDC_SAT_AccountID"] = '1' #资金卡号 defineDict["THOST_FTDC_SAT_CardID"] = '2' #上海股东帐号 defineDict["THOST_FTDC_SAT_SHStockholderID"] = '3' #深圳股东帐号 defineDict["THOST_FTDC_SAT_SZStockholderID"] = '4' typedefDict["TThostFtdcSecuAccTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTransferStatusType是一个转账交易状态类型 #////////////////////////////////////////////////////////////////////// #正常 defineDict["THOST_FTDC_TRFS_Normal"] = '0' #被冲正 defineDict["THOST_FTDC_TRFS_Repealed"] = '1' typedefDict["TThostFtdcTransferStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSponsorTypeType是一个发起方类型 #////////////////////////////////////////////////////////////////////// #期商 defineDict["THOST_FTDC_SPTYPE_Broker"] = '0' #银行 defineDict["THOST_FTDC_SPTYPE_Bank"] = '1' typedefDict["TThostFtdcSponsorTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcReqRspTypeType是一个请求响应类别类型 #////////////////////////////////////////////////////////////////////// #请求 defineDict["THOST_FTDC_REQRSP_Request"] = '0' #响应 defineDict["THOST_FTDC_REQRSP_Response"] = '1' typedefDict["TThostFtdcReqRspTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBTUserEventTypeType是一个银期转帐用户事件类型类型 #////////////////////////////////////////////////////////////////////// #签到 defineDict["THOST_FTDC_FBTUET_SignIn"] = '0' #银行转期货 defineDict["THOST_FTDC_FBTUET_FromBankToFuture"] = '1' #期货转银行 defineDict["THOST_FTDC_FBTUET_FromFutureToBank"] = '2' #开户 defineDict["THOST_FTDC_FBTUET_OpenAccount"] = '3' #销户 defineDict["THOST_FTDC_FBTUET_CancelAccount"] = '4' #变更银行账户 defineDict["THOST_FTDC_FBTUET_ChangeAccount"] = '5' #冲正银行转期货 defineDict["THOST_FTDC_FBTUET_RepealFromBankToFuture"] = '6' #冲正期货转银行 defineDict["THOST_FTDC_FBTUET_RepealFromFutureToBank"] = '7' #查询银行账户 defineDict["THOST_FTDC_FBTUET_QueryBankAccount"] = '8' #查询期货账户 defineDict["THOST_FTDC_FBTUET_QueryFutureAccount"] = '9' #签退 defineDict["THOST_FTDC_FBTUET_SignOut"] = 'A' #密钥同步 defineDict["THOST_FTDC_FBTUET_SyncKey"] = 'B' #其他 defineDict["THOST_FTDC_FBTUET_Other"] = 'Z' typedefDict["TThostFtdcFBTUserEventTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankIDByBankType是一个银行自己的编码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankIDByBankType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankOperNoType是一个银行操作员号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankOperNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankCustNoType是一个银行客户号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankCustNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDBOPSeqNoType是一个递增的序列号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDBOPSeqNoType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcTableNameType是一个FBT表名类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTableNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPKNameType是一个FBT表操作主键名类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPKNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPKValueType是一个FBT表操作主键值类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPKValueType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDBOperationType是一个记录操作类型类型 #////////////////////////////////////////////////////////////////////// #插入 defineDict["THOST_FTDC_DBOP_Insert"] = '0' #更新 defineDict["THOST_FTDC_DBOP_Update"] = '1' #删除 defineDict["THOST_FTDC_DBOP_Delete"] = '2' typedefDict["TThostFtdcDBOperationType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSyncFlagType是一个同步标记类型 #////////////////////////////////////////////////////////////////////// #已同步 defineDict["THOST_FTDC_SYNF_Yes"] = '0' #未同步 defineDict["THOST_FTDC_SYNF_No"] = '1' typedefDict["TThostFtdcSyncFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTargetIDType是一个同步目标编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTargetIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSyncTypeType是一个同步类型类型 #////////////////////////////////////////////////////////////////////// #一次同步 defineDict["THOST_FTDC_SYNT_OneOffSync"] = '0' #定时同步 defineDict["THOST_FTDC_SYNT_TimerSync"] = '1' #定时完全同步 defineDict["THOST_FTDC_SYNT_TimerFullSync"] = '2' typedefDict["TThostFtdcSyncTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBETimeType是一个各种换汇时间类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBETimeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEBankNoType是一个换汇银行行号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBEBankNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBECertNoType是一个换汇凭证号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBECertNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExDirectionType是一个换汇方向类型 #////////////////////////////////////////////////////////////////////// #结汇 defineDict["THOST_FTDC_FBEDIR_Settlement"] = '0' #售汇 defineDict["THOST_FTDC_FBEDIR_Sale"] = '1' typedefDict["TThostFtdcExDirectionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEBankAccountType是一个换汇银行账户类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBEBankAccountType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEBankAccountNameType是一个换汇银行账户名类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBEBankAccountNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEAmtType是一个各种换汇金额类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBEAmtType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcFBEBusinessTypeType是一个换汇业务类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBEBusinessTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEPostScriptType是一个换汇附言类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBEPostScriptType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBERemarkType是一个换汇备注类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBERemarkType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExRateType是一个换汇汇率类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcExRateType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcFBEResultFlagType是一个换汇成功标志类型 #////////////////////////////////////////////////////////////////////// #成功 defineDict["THOST_FTDC_FBERES_Success"] = '0' #账户余额不足 defineDict["THOST_FTDC_FBERES_InsufficientBalance"] = '1' #交易结果未知 defineDict["THOST_FTDC_FBERES_UnknownTrading"] = '8' #失败 defineDict["THOST_FTDC_FBERES_Fail"] = 'x' typedefDict["TThostFtdcFBEResultFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBERtnMsgType是一个换汇返回信息类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBERtnMsgType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEExtendMsgType是一个换汇扩展信息类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBEExtendMsgType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEBusinessSerialType是一个换汇记账流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBEBusinessSerialType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBESystemSerialType是一个换汇流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBESystemSerialType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBETotalExCntType是一个换汇交易总笔数类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBETotalExCntType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcFBEExchStatusType是一个换汇交易状态类型 #////////////////////////////////////////////////////////////////////// #正常 defineDict["THOST_FTDC_FBEES_Normal"] = '0' #交易重发 defineDict["THOST_FTDC_FBEES_ReExchange"] = '1' typedefDict["TThostFtdcFBEExchStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEFileFlagType是一个换汇文件标志类型 #////////////////////////////////////////////////////////////////////// #数据包 defineDict["THOST_FTDC_FBEFG_DataPackage"] = '0' #文件 defineDict["THOST_FTDC_FBEFG_File"] = '1' typedefDict["TThostFtdcFBEFileFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEAlreadyTradeType是一个换汇已交易标志类型 #////////////////////////////////////////////////////////////////////// #未交易 defineDict["THOST_FTDC_FBEAT_NotTrade"] = '0' #已交易 defineDict["THOST_FTDC_FBEAT_Trade"] = '1' typedefDict["TThostFtdcFBEAlreadyTradeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEOpenBankType是一个换汇账户开户行类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBEOpenBankType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEUserEventTypeType是一个银期换汇用户事件类型类型 #////////////////////////////////////////////////////////////////////// #签到 defineDict["THOST_FTDC_FBEUET_SignIn"] = '0' #换汇 defineDict["THOST_FTDC_FBEUET_Exchange"] = '1' #换汇重发 defineDict["THOST_FTDC_FBEUET_ReExchange"] = '2' #银行账户查询 defineDict["THOST_FTDC_FBEUET_QueryBankAccount"] = '3' #换汇明细查询 defineDict["THOST_FTDC_FBEUET_QueryExchDetial"] = '4' #换汇汇总查询 defineDict["THOST_FTDC_FBEUET_QueryExchSummary"] = '5' #换汇汇率查询 defineDict["THOST_FTDC_FBEUET_QueryExchRate"] = '6' #对账文件通知 defineDict["THOST_FTDC_FBEUET_CheckBankAccount"] = '7' #签退 defineDict["THOST_FTDC_FBEUET_SignOut"] = '8' #其他 defineDict["THOST_FTDC_FBEUET_Other"] = 'Z' typedefDict["TThostFtdcFBEUserEventTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEFileNameType是一个换汇相关文件名类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBEFileNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEBatchSerialType是一个换汇批次号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFBEBatchSerialType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBEReqFlagType是一个换汇发送标志类型 #////////////////////////////////////////////////////////////////////// #未处理 defineDict["THOST_FTDC_FBERF_UnProcessed"] = '0' #等待发送 defineDict["THOST_FTDC_FBERF_WaitSend"] = '1' #发送成功 defineDict["THOST_FTDC_FBERF_SendSuccess"] = '2' #发送失败 defineDict["THOST_FTDC_FBERF_SendFailed"] = '3' #等待重发 defineDict["THOST_FTDC_FBERF_WaitReSend"] = '4' typedefDict["TThostFtdcFBEReqFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcNotifyClassType是一个风险通知类型类型 #////////////////////////////////////////////////////////////////////// #正常 defineDict["THOST_FTDC_NC_NOERROR"] = '0' #警示 defineDict["THOST_FTDC_NC_Warn"] = '1' #追保 defineDict["THOST_FTDC_NC_Call"] = '2' #强平 defineDict["THOST_FTDC_NC_Force"] = '3' #穿仓 defineDict["THOST_FTDC_NC_CHUANCANG"] = '4' #异常 defineDict["THOST_FTDC_NC_Exception"] = '5' typedefDict["TThostFtdcNotifyClassType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRiskNofityInfoType是一个客户风险通知消息类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRiskNofityInfoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcForceCloseSceneIdType是一个强平场景编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcForceCloseSceneIdType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcForceCloseTypeType是一个强平单类型类型 #////////////////////////////////////////////////////////////////////// #手工强平 defineDict["THOST_FTDC_FCT_Manual"] = '0' #单一投资者辅助强平 defineDict["THOST_FTDC_FCT_Single"] = '1' #批量投资者辅助强平 defineDict["THOST_FTDC_FCT_Group"] = '2' typedefDict["TThostFtdcForceCloseTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInstrumentIDsType是一个多个产品代码,用+分隔,如cu+zn类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInstrumentIDsType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRiskNotifyMethodType是一个风险通知途径类型 #////////////////////////////////////////////////////////////////////// #系统通知 defineDict["THOST_FTDC_RNM_System"] = '0' #短信通知 defineDict["THOST_FTDC_RNM_SMS"] = '1' #邮件通知 defineDict["THOST_FTDC_RNM_EMail"] = '2' #人工通知 defineDict["THOST_FTDC_RNM_Manual"] = '3' typedefDict["TThostFtdcRiskNotifyMethodType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRiskNotifyStatusType是一个风险通知状态类型 #////////////////////////////////////////////////////////////////////// #未生成 defineDict["THOST_FTDC_RNS_NotGen"] = '0' #已生成未发送 defineDict["THOST_FTDC_RNS_Generated"] = '1' #发送失败 defineDict["THOST_FTDC_RNS_SendError"] = '2' #已发送未接收 defineDict["THOST_FTDC_RNS_SendOk"] = '3' #已接收未确认 defineDict["THOST_FTDC_RNS_Received"] = '4' #已确认 defineDict["THOST_FTDC_RNS_Confirmed"] = '5' typedefDict["TThostFtdcRiskNotifyStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRiskUserEventType是一个风控用户操作事件类型 #////////////////////////////////////////////////////////////////////// #导出数据 defineDict["THOST_FTDC_RUE_ExportData"] = '0' typedefDict["TThostFtdcRiskUserEventType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcParamIDType是一个参数代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcParamIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcParamNameType是一个参数名类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcParamNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcParamValueType是一个参数值类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcParamValueType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcConditionalOrderSortTypeType是一个条件单索引条件类型 #////////////////////////////////////////////////////////////////////// #使用最新价升序 defineDict["THOST_FTDC_COST_LastPriceAsc"] = '0' #使用最新价降序 defineDict["THOST_FTDC_COST_LastPriceDesc"] = '1' #使用卖价升序 defineDict["THOST_FTDC_COST_AskPriceAsc"] = '2' #使用卖价降序 defineDict["THOST_FTDC_COST_AskPriceDesc"] = '3' #使用买价升序 defineDict["THOST_FTDC_COST_BidPriceAsc"] = '4' #使用买价降序 defineDict["THOST_FTDC_COST_BidPriceDesc"] = '5' typedefDict["TThostFtdcConditionalOrderSortTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSendTypeType是一个报送状态类型 #////////////////////////////////////////////////////////////////////// #未发送 defineDict["THOST_FTDC_UOAST_NoSend"] = '0' #已发送 defineDict["THOST_FTDC_UOAST_Sended"] = '1' #已生成 defineDict["THOST_FTDC_UOAST_Generated"] = '2' #报送失败 defineDict["THOST_FTDC_UOAST_SendFail"] = '3' #接收成功 defineDict["THOST_FTDC_UOAST_Success"] = '4' #接收失败 defineDict["THOST_FTDC_UOAST_Fail"] = '5' #取消报送 defineDict["THOST_FTDC_UOAST_Cancel"] = '6' typedefDict["TThostFtdcSendTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcClientIDStatusType是一个交易编码状态类型 #////////////////////////////////////////////////////////////////////// #未申请 defineDict["THOST_FTDC_UOACS_NoApply"] = '1' #已提交申请 defineDict["THOST_FTDC_UOACS_Submited"] = '2' #已发送申请 defineDict["THOST_FTDC_UOACS_Sended"] = '3' #完成 defineDict["THOST_FTDC_UOACS_Success"] = '4' #拒绝 defineDict["THOST_FTDC_UOACS_Refuse"] = '5' #已撤销编码 defineDict["THOST_FTDC_UOACS_Cancel"] = '6' typedefDict["TThostFtdcClientIDStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcIndustryIDType是一个行业编码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcIndustryIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcQuestionIDType是一个特有信息编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcQuestionIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcQuestionContentType是一个特有信息说明类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcQuestionContentType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOptionIDType是一个选项编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOptionIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOptionContentType是一个选项说明类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOptionContentType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcQuestionTypeType是一个特有信息类型类型 #////////////////////////////////////////////////////////////////////// #单选 defineDict["THOST_FTDC_QT_Radio"] = '1' #多选 defineDict["THOST_FTDC_QT_Option"] = '2' #填空 defineDict["THOST_FTDC_QT_Blank"] = '3' typedefDict["TThostFtdcQuestionTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcProcessIDType是一个业务流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcProcessIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSeqNoType是一个流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSeqNoType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcUOAProcessStatusType是一个流程状态类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUOAProcessStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcProcessTypeType是一个流程功能类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcProcessTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBusinessTypeType是一个业务类型类型 #////////////////////////////////////////////////////////////////////// #请求 defineDict["THOST_FTDC_BT_Request"] = '1' #应答 defineDict["THOST_FTDC_BT_Response"] = '2' #通知 defineDict["THOST_FTDC_BT_Notice"] = '3' typedefDict["TThostFtdcBusinessTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCfmmcReturnCodeType是一个监控中心返回码类型 #////////////////////////////////////////////////////////////////////// #成功 defineDict["THOST_FTDC_CRC_Success"] = '0' #该客户已经有流程在处理中 defineDict["THOST_FTDC_CRC_Working"] = '1' #监控中客户资料检查失败 defineDict["THOST_FTDC_CRC_InfoFail"] = '2' #监控中实名制检查失败 defineDict["THOST_FTDC_CRC_IDCardFail"] = '3' #其他错误 defineDict["THOST_FTDC_CRC_OtherFail"] = '4' typedefDict["TThostFtdcCfmmcReturnCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExReturnCodeType是一个交易所返回码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcExReturnCodeType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcClientTypeType是一个客户类型类型 #////////////////////////////////////////////////////////////////////// #所有 defineDict["THOST_FTDC_CfMMCCT_All"] = '0' #个人 defineDict["THOST_FTDC_CfMMCCT_Person"] = '1' #单位 defineDict["THOST_FTDC_CfMMCCT_Company"] = '2' #其他 defineDict["THOST_FTDC_CfMMCCT_Other"] = '3' #特殊法人 defineDict["THOST_FTDC_CfMMCCT_SpecialOrgan"] = '4' #资管户 defineDict["THOST_FTDC_CfMMCCT_Asset"] = '5' typedefDict["TThostFtdcClientTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExchangeIDTypeType是一个交易所编号类型 #////////////////////////////////////////////////////////////////////// #上海期货交易所 defineDict["THOST_FTDC_EIDT_SHFE"] = 'S' #郑州商品交易所 defineDict["THOST_FTDC_EIDT_CZCE"] = 'Z' #大连商品交易所 defineDict["THOST_FTDC_EIDT_DCE"] = 'D' #中国金融期货交易所 defineDict["THOST_FTDC_EIDT_CFFEX"] = 'J' #上海国际能源交易中心股份有限公司 defineDict["THOST_FTDC_EIDT_INE"] = 'N' typedefDict["TThostFtdcExchangeIDTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExClientIDTypeType是一个交易编码类型类型 #////////////////////////////////////////////////////////////////////// #套保 defineDict["THOST_FTDC_ECIDT_Hedge"] = '1' #套利 defineDict["THOST_FTDC_ECIDT_Arbitrage"] = '2' #投机 defineDict["THOST_FTDC_ECIDT_Speculation"] = '3' typedefDict["TThostFtdcExClientIDTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcClientClassifyType是一个客户分类码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcClientClassifyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUOAOrganTypeType是一个单位性质类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUOAOrganTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUOACountryCodeType是一个国家代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUOACountryCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAreaCodeType是一个区号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAreaCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFuturesIDType是一个监控中心为客户分配的代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFuturesIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCffmcDateType是一个日期类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCffmcDateType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCffmcTimeType是一个时间类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCffmcTimeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcNocIDType是一个组织机构代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcNocIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUpdateFlagType是一个更新状态类型 #////////////////////////////////////////////////////////////////////// #未更新 defineDict["THOST_FTDC_UF_NoUpdate"] = '0' #更新全部信息成功 defineDict["THOST_FTDC_UF_Success"] = '1' #更新全部信息失败 defineDict["THOST_FTDC_UF_Fail"] = '2' #更新交易编码成功 defineDict["THOST_FTDC_UF_TCSuccess"] = '3' #更新交易编码失败 defineDict["THOST_FTDC_UF_TCFail"] = '4' #已丢弃 defineDict["THOST_FTDC_UF_Cancel"] = '5' typedefDict["TThostFtdcUpdateFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcApplyOperateIDType是一个申请动作类型 #////////////////////////////////////////////////////////////////////// #开户 defineDict["THOST_FTDC_AOID_OpenInvestor"] = '1' #修改身份信息 defineDict["THOST_FTDC_AOID_ModifyIDCard"] = '2' #修改一般信息 defineDict["THOST_FTDC_AOID_ModifyNoIDCard"] = '3' #申请交易编码 defineDict["THOST_FTDC_AOID_ApplyTradingCode"] = '4' #撤销交易编码 defineDict["THOST_FTDC_AOID_CancelTradingCode"] = '5' #销户 defineDict["THOST_FTDC_AOID_CancelInvestor"] = '6' #账户休眠 defineDict["THOST_FTDC_AOID_FreezeAccount"] = '8' #激活休眠账户 defineDict["THOST_FTDC_AOID_ActiveFreezeAccount"] = '9' typedefDict["TThostFtdcApplyOperateIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcApplyStatusIDType是一个申请状态类型 #////////////////////////////////////////////////////////////////////// #未补全 defineDict["THOST_FTDC_ASID_NoComplete"] = '1' #已提交 defineDict["THOST_FTDC_ASID_Submited"] = '2' #已审核 defineDict["THOST_FTDC_ASID_Checked"] = '3' #已拒绝 defineDict["THOST_FTDC_ASID_Refused"] = '4' #已删除 defineDict["THOST_FTDC_ASID_Deleted"] = '5' typedefDict["TThostFtdcApplyStatusIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSendMethodType是一个发送方式类型 #////////////////////////////////////////////////////////////////////// #文件发送 defineDict["THOST_FTDC_UOASM_ByAPI"] = '1' #电子发送 defineDict["THOST_FTDC_UOASM_ByFile"] = '2' typedefDict["TThostFtdcSendMethodType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcEventTypeType是一个业务操作类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcEventTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcEventModeType是一个操作方法类型 #////////////////////////////////////////////////////////////////////// #增加 defineDict["THOST_FTDC_EvM_ADD"] = '1' #修改 defineDict["THOST_FTDC_EvM_UPDATE"] = '2' #删除 defineDict["THOST_FTDC_EvM_DELETE"] = '3' #复核 defineDict["THOST_FTDC_EvM_CHECK"] = '4' #复制 defineDict["THOST_FTDC_EvM_COPY"] = '5' #注销 defineDict["THOST_FTDC_EvM_CANCEL"] = '6' #冲销 defineDict["THOST_FTDC_EvM_Reverse"] = '7' typedefDict["TThostFtdcEventModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUOAAutoSendType是一个统一开户申请自动发送类型 #////////////////////////////////////////////////////////////////////// #自动发送并接收 defineDict["THOST_FTDC_UOAA_ASR"] = '1' #自动发送,不自动接收 defineDict["THOST_FTDC_UOAA_ASNR"] = '2' #不自动发送,自动接收 defineDict["THOST_FTDC_UOAA_NSAR"] = '3' #不自动发送,也不自动接收 defineDict["THOST_FTDC_UOAA_NSR"] = '4' typedefDict["TThostFtdcUOAAutoSendType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcQueryDepthType是一个查询深度类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcQueryDepthType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcDataCenterIDType是一个数据中心代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDataCenterIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcFlowIDType是一个流程ID类型 #////////////////////////////////////////////////////////////////////// #投资者对应投资者组设置 defineDict["THOST_FTDC_EvM_InvestorGroupFlow"] = '1' #投资者手续费率设置 defineDict["THOST_FTDC_EvM_InvestorRate"] = '2' #投资者手续费率模板关系设置 defineDict["THOST_FTDC_EvM_InvestorCommRateModel"] = '3' typedefDict["TThostFtdcFlowIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCheckLevelType是一个复核级别类型 #////////////////////////////////////////////////////////////////////// #零级复核 defineDict["THOST_FTDC_CL_Zero"] = '0' #一级复核 defineDict["THOST_FTDC_CL_One"] = '1' #二级复核 defineDict["THOST_FTDC_CL_Two"] = '2' typedefDict["TThostFtdcCheckLevelType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCheckNoType是一个操作次数类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCheckNoType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcCheckStatusType是一个复核级别类型 #////////////////////////////////////////////////////////////////////// #未复核 defineDict["THOST_FTDC_CHS_Init"] = '0' #复核中 defineDict["THOST_FTDC_CHS_Checking"] = '1' #已复核 defineDict["THOST_FTDC_CHS_Checked"] = '2' #拒绝 defineDict["THOST_FTDC_CHS_Refuse"] = '3' #作废 defineDict["THOST_FTDC_CHS_Cancel"] = '4' typedefDict["TThostFtdcCheckStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUsedStatusType是一个生效状态类型 #////////////////////////////////////////////////////////////////////// #未生效 defineDict["THOST_FTDC_CHU_Unused"] = '0' #已生效 defineDict["THOST_FTDC_CHU_Used"] = '1' #生效失败 defineDict["THOST_FTDC_CHU_Fail"] = '2' typedefDict["TThostFtdcUsedStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRateTemplateNameType是一个模型名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRateTemplateNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPropertyStringType是一个用于查询的投资属性字段类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPropertyStringType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankAcountOriginType是一个账户来源类型 #////////////////////////////////////////////////////////////////////// #手工录入 defineDict["THOST_FTDC_BAO_ByAccProperty"] = '0' #银期转账 defineDict["THOST_FTDC_BAO_ByFBTransfer"] = '1' typedefDict["TThostFtdcBankAcountOriginType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMonthBillTradeSumType是一个结算单月报成交汇总方式类型 #////////////////////////////////////////////////////////////////////// #同日同合约 defineDict["THOST_FTDC_MBTS_ByInstrument"] = '0' #同日同合约同价格 defineDict["THOST_FTDC_MBTS_ByDayInsPrc"] = '1' #同合约 defineDict["THOST_FTDC_MBTS_ByDayIns"] = '2' typedefDict["TThostFtdcMonthBillTradeSumType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFBTTradeCodeEnumType是一个银期交易代码枚举类型 #////////////////////////////////////////////////////////////////////// #银行发起银行转期货 defineDict["THOST_FTDC_FTC_BankLaunchBankToBroker"] = '102001' #期货发起银行转期货 defineDict["THOST_FTDC_FTC_BrokerLaunchBankToBroker"] = '202001' #银行发起期货转银行 defineDict["THOST_FTDC_FTC_BankLaunchBrokerToBank"] = '102002' #期货发起期货转银行 defineDict["THOST_FTDC_FTC_BrokerLaunchBrokerToBank"] = '202002' typedefDict["TThostFtdcFBTTradeCodeEnumType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRateTemplateIDType是一个模型代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRateTemplateIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRiskRateType是一个风险度类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRiskRateType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTimestampType是一个时间戳类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTimestampType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcInvestorIDRuleNameType是一个号段规则名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInvestorIDRuleNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInvestorIDRuleExprType是一个号段规则表达式类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInvestorIDRuleExprType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcLastDriftType是一个上次OTP漂移值类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcLastDriftType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcLastSuccessType是一个上次OTP成功值类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcLastSuccessType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcAuthKeyType是一个令牌密钥类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAuthKeyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSerialNumberType是一个序列号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSerialNumberType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOTPTypeType是一个动态令牌类型类型 #////////////////////////////////////////////////////////////////////// #无动态令牌 defineDict["THOST_FTDC_OTP_NONE"] = '0' #时间令牌 defineDict["THOST_FTDC_OTP_TOTP"] = '1' typedefDict["TThostFtdcOTPTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOTPVendorsIDType是一个动态令牌提供商类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOTPVendorsIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOTPVendorsNameType是一个动态令牌提供商名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOTPVendorsNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOTPStatusType是一个动态令牌状态类型 #////////////////////////////////////////////////////////////////////// #未使用 defineDict["THOST_FTDC_OTPS_Unused"] = '0' #已使用 defineDict["THOST_FTDC_OTPS_Used"] = '1' #注销 defineDict["THOST_FTDC_OTPS_Disuse"] = '2' typedefDict["TThostFtdcOTPStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBrokerUserTypeType是一个经济公司用户类型类型 #////////////////////////////////////////////////////////////////////// #投资者 defineDict["THOST_FTDC_BUT_Investor"] = '1' #操作员 defineDict["THOST_FTDC_BUT_BrokerUser"] = '2' typedefDict["TThostFtdcBrokerUserTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFutureTypeType是一个期货类型类型 #////////////////////////////////////////////////////////////////////// #商品期货 defineDict["THOST_FTDC_FUTT_Commodity"] = '1' #金融期货 defineDict["THOST_FTDC_FUTT_Financial"] = '2' typedefDict["TThostFtdcFutureTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFundEventTypeType是一个资金管理操作类型类型 #////////////////////////////////////////////////////////////////////// #转账限额 defineDict["THOST_FTDC_FET_Restriction"] = '0' #当日转账限额 defineDict["THOST_FTDC_FET_TodayRestriction"] = '1' #期商流水 defineDict["THOST_FTDC_FET_Transfer"] = '2' #资金冻结 defineDict["THOST_FTDC_FET_Credit"] = '3' #投资者可提资金比例 defineDict["THOST_FTDC_FET_InvestorWithdrawAlm"] = '4' #单个银行帐户转账限额 defineDict["THOST_FTDC_FET_BankRestriction"] = '5' #银期签约账户 defineDict["THOST_FTDC_FET_Accountregister"] = '6' #交易所出入金 defineDict["THOST_FTDC_FET_ExchangeFundIO"] = '7' #投资者出入金 defineDict["THOST_FTDC_FET_InvestorFundIO"] = '8' typedefDict["TThostFtdcFundEventTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAccountSourceTypeType是一个资金账户来源类型 #////////////////////////////////////////////////////////////////////// #银期同步 defineDict["THOST_FTDC_AST_FBTransfer"] = '0' #手工录入 defineDict["THOST_FTDC_AST_ManualEntry"] = '1' typedefDict["TThostFtdcAccountSourceTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCodeSourceTypeType是一个交易编码来源类型 #////////////////////////////////////////////////////////////////////// #统一开户(已规范) defineDict["THOST_FTDC_CST_UnifyAccount"] = '0' #手工录入(未规范) defineDict["THOST_FTDC_CST_ManualEntry"] = '1' typedefDict["TThostFtdcCodeSourceTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUserRangeType是一个操作员范围类型 #////////////////////////////////////////////////////////////////////// #所有 defineDict["THOST_FTDC_UR_All"] = '0' #单一操作员 defineDict["THOST_FTDC_UR_Single"] = '1' typedefDict["TThostFtdcUserRangeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTimeSpanType是一个时间跨度类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTimeSpanType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcImportSequenceIDType是一个动态令牌导入批次编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcImportSequenceIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcByGroupType是一个交易统计表按客户统计方式类型 #////////////////////////////////////////////////////////////////////// #按投资者统计 defineDict["THOST_FTDC_BG_Investor"] = '2' #按类统计 defineDict["THOST_FTDC_BG_Group"] = '1' typedefDict["TThostFtdcByGroupType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTradeSumStatModeType是一个交易统计表按范围统计方式类型 #////////////////////////////////////////////////////////////////////// #按合约统计 defineDict["THOST_FTDC_TSSM_Instrument"] = '1' #按产品统计 defineDict["THOST_FTDC_TSSM_Product"] = '2' #按交易所统计 defineDict["THOST_FTDC_TSSM_Exchange"] = '3' typedefDict["TThostFtdcTradeSumStatModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcComTypeType是一个组合成交类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcComTypeType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcUserProductIDType是一个产品标识类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUserProductIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUserProductNameType是一个产品名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUserProductNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUserProductMemoType是一个产品说明类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUserProductMemoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCCancelFlagType是一个新增或变更标志类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCCancelFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCDateType是一个日期类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCDateType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCInvestorNameType是一个客户名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCInvestorNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCOpenInvestorNameType是一个客户名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCOpenInvestorNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCInvestorIDType是一个客户代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCInvestorIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCIdentifiedCardNoType是一个证件号码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCIdentifiedCardNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCClientIDType是一个交易编码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCClientIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCBankFlagType是一个银行标识类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCBankFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCBankAccountType是一个银行账户类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCBankAccountType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCOpenNameType是一个开户人类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCOpenNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCMemoType是一个说明类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCMemoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCTimeType是一个时间类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCTimeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCTradeIDType是一个成交流水号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCTradeIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCExchangeInstIDType是一个合约代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCExchangeInstIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCMortgageNameType是一个质押品名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCMortgageNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCReasonType是一个事由类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCReasonType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcIsSettlementType是一个是否为非结算会员类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcIsSettlementType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCMoneyType是一个资金类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCMoneyType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCPriceType是一个价格类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCPriceType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCOptionsTypeType是一个期权类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCOptionsTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCStrikePriceType是一个执行价类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCStrikePriceType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCTargetProductIDType是一个标的品种类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCTargetProductIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCTargetInstrIDType是一个标的合约类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCTargetInstrIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCommModelNameType是一个手续费率模板名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCommModelNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCommModelMemoType是一个手续费率模板备注类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCommModelMemoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExprSetModeType是一个日期表达式设置类型类型 #////////////////////////////////////////////////////////////////////// #相对已有规则设置 defineDict["THOST_FTDC_ESM_Relative"] = '1' #典型设置 defineDict["THOST_FTDC_ESM_Typical"] = '2' typedefDict["TThostFtdcExprSetModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRateInvestorRangeType是一个投资者范围类型 #////////////////////////////////////////////////////////////////////// #公司标准 defineDict["THOST_FTDC_RIR_All"] = '1' #模板 defineDict["THOST_FTDC_RIR_Model"] = '2' #单一投资者 defineDict["THOST_FTDC_RIR_Single"] = '3' typedefDict["TThostFtdcRateInvestorRangeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAgentBrokerIDType是一个代理经纪公司代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAgentBrokerIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDRIdentityIDType是一个交易中心代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDRIdentityIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcDRIdentityNameType是一个交易中心名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDRIdentityNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDBLinkIDType是一个DBLink标识号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDBLinkIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSyncDataStatusType是一个主次用系统数据同步状态类型 #////////////////////////////////////////////////////////////////////// #未同步 defineDict["THOST_FTDC_SDS_Initialize"] = '0' #同步中 defineDict["THOST_FTDC_SDS_Settlementing"] = '1' #已同步 defineDict["THOST_FTDC_SDS_Settlemented"] = '2' typedefDict["TThostFtdcSyncDataStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTradeSourceType是一个成交来源类型 #////////////////////////////////////////////////////////////////////// #来自交易所普通回报 defineDict["THOST_FTDC_TSRC_NORMAL"] = '0' #来自查询 defineDict["THOST_FTDC_TSRC_QUERY"] = '1' typedefDict["TThostFtdcTradeSourceType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFlexStatModeType是一个产品合约统计方式类型 #////////////////////////////////////////////////////////////////////// #产品统计 defineDict["THOST_FTDC_FSM_Product"] = '1' #交易所统计 defineDict["THOST_FTDC_FSM_Exchange"] = '2' #统计所有 defineDict["THOST_FTDC_FSM_All"] = '3' typedefDict["TThostFtdcFlexStatModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcByInvestorRangeType是一个投资者范围统计方式类型 #////////////////////////////////////////////////////////////////////// #属性统计 defineDict["THOST_FTDC_BIR_Property"] = '1' #统计所有 defineDict["THOST_FTDC_BIR_All"] = '2' typedefDict["TThostFtdcByInvestorRangeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSRiskRateType是一个风险度类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSRiskRateType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSequenceNo12Type是一个序号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSequenceNo12Type"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcPropertyInvestorRangeType是一个投资者范围类型 #////////////////////////////////////////////////////////////////////// #所有 defineDict["THOST_FTDC_PIR_All"] = '1' #投资者属性 defineDict["THOST_FTDC_PIR_Property"] = '2' #单一投资者 defineDict["THOST_FTDC_PIR_Single"] = '3' typedefDict["TThostFtdcPropertyInvestorRangeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFileStatusType是一个文件状态类型 #////////////////////////////////////////////////////////////////////// #未生成 defineDict["THOST_FTDC_FIS_NoCreate"] = '0' #已生成 defineDict["THOST_FTDC_FIS_Created"] = '1' #生成失败 defineDict["THOST_FTDC_FIS_Failed"] = '2' typedefDict["TThostFtdcFileStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFileGenStyleType是一个文件生成方式类型 #////////////////////////////////////////////////////////////////////// #下发 defineDict["THOST_FTDC_FGS_FileTransmit"] = '0' #生成 defineDict["THOST_FTDC_FGS_FileGen"] = '1' typedefDict["TThostFtdcFileGenStyleType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSysOperModeType是一个系统日志操作方法类型 #////////////////////////////////////////////////////////////////////// #增加 defineDict["THOST_FTDC_SoM_Add"] = '1' #修改 defineDict["THOST_FTDC_SoM_Update"] = '2' #删除 defineDict["THOST_FTDC_SoM_Delete"] = '3' #复制 defineDict["THOST_FTDC_SoM_Copy"] = '4' #激活 defineDict["THOST_FTDC_SoM_AcTive"] = '5' #注销 defineDict["THOST_FTDC_SoM_CanCel"] = '6' #重置 defineDict["THOST_FTDC_SoM_ReSet"] = '7' typedefDict["TThostFtdcSysOperModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSysOperTypeType是一个系统日志操作类型类型 #////////////////////////////////////////////////////////////////////// #修改操作员密码 defineDict["THOST_FTDC_SoT_UpdatePassword"] = '0' #操作员组织架构关系 defineDict["THOST_FTDC_SoT_UserDepartment"] = '1' #角色管理 defineDict["THOST_FTDC_SoT_RoleManager"] = '2' #角色功能设置 defineDict["THOST_FTDC_SoT_RoleFunction"] = '3' #基础参数设置 defineDict["THOST_FTDC_SoT_BaseParam"] = '4' #设置操作员 defineDict["THOST_FTDC_SoT_SetUserID"] = '5' #用户角色设置 defineDict["THOST_FTDC_SoT_SetUserRole"] = '6' #用户IP限制 defineDict["THOST_FTDC_SoT_UserIpRestriction"] = '7' #组织架构管理 defineDict["THOST_FTDC_SoT_DepartmentManager"] = '8' #组织架构向查询分类复制 defineDict["THOST_FTDC_SoT_DepartmentCopy"] = '9' #交易编码管理 defineDict["THOST_FTDC_SoT_Tradingcode"] = 'A' #投资者状态维护 defineDict["THOST_FTDC_SoT_InvestorStatus"] = 'B' #投资者权限管理 defineDict["THOST_FTDC_SoT_InvestorAuthority"] = 'C' #属性设置 defineDict["THOST_FTDC_SoT_PropertySet"] = 'D' #重置投资者密码 defineDict["THOST_FTDC_SoT_ReSetInvestorPasswd"] = 'E' #投资者个性信息维护 defineDict["THOST_FTDC_SoT_InvestorPersonalityInfo"] = 'F' typedefDict["TThostFtdcSysOperTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCDataQueyTypeType是一个上报数据查询类型类型 #////////////////////////////////////////////////////////////////////// #查询当前交易日报送的数据 defineDict["THOST_FTDC_CSRCQ_Current"] = '0' #查询历史报送的代理经纪公司的数据 defineDict["THOST_FTDC_CSRCQ_History"] = '1' typedefDict["TThostFtdcCSRCDataQueyTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFreezeStatusType是一个休眠状态类型 #////////////////////////////////////////////////////////////////////// #活跃 defineDict["THOST_FTDC_FRS_Normal"] = '1' #休眠 defineDict["THOST_FTDC_FRS_Freeze"] = '0' typedefDict["TThostFtdcFreezeStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcStandardStatusType是一个规范状态类型 #////////////////////////////////////////////////////////////////////// #已规范 defineDict["THOST_FTDC_STST_Standard"] = '0' #未规范 defineDict["THOST_FTDC_STST_NonStandard"] = '1' typedefDict["TThostFtdcStandardStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCFreezeStatusType是一个休眠状态类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCFreezeStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRightParamTypeType是一个配置类型类型 #////////////////////////////////////////////////////////////////////// #休眠户 defineDict["THOST_FTDC_RPT_Freeze"] = '1' #激活休眠户 defineDict["THOST_FTDC_RPT_FreezeActive"] = '2' #开仓权限限制 defineDict["THOST_FTDC_RPT_OpenLimit"] = '3' #解除开仓权限限制 defineDict["THOST_FTDC_RPT_RelieveOpenLimit"] = '4' typedefDict["TThostFtdcRightParamTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRightTemplateIDType是一个模板代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRightTemplateIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRightTemplateNameType是一个模板名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRightTemplateNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDataStatusType是一个反洗钱审核表数据状态类型 #////////////////////////////////////////////////////////////////////// #正常 defineDict["THOST_FTDC_AMLDS_Normal"] = '0' #已删除 defineDict["THOST_FTDC_AMLDS_Deleted"] = '1' typedefDict["TThostFtdcDataStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAMLCheckStatusType是一个审核状态类型 #////////////////////////////////////////////////////////////////////// #未复核 defineDict["THOST_FTDC_AMLCHS_Init"] = '0' #复核中 defineDict["THOST_FTDC_AMLCHS_Checking"] = '1' #已复核 defineDict["THOST_FTDC_AMLCHS_Checked"] = '2' #拒绝上报 defineDict["THOST_FTDC_AMLCHS_RefuseReport"] = '3' typedefDict["TThostFtdcAMLCheckStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAmlDateTypeType是一个日期类型类型 #////////////////////////////////////////////////////////////////////// #检查日期 defineDict["THOST_FTDC_AMLDT_DrawDay"] = '0' #发生日期 defineDict["THOST_FTDC_AMLDT_TouchDay"] = '1' typedefDict["TThostFtdcAmlDateTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAmlCheckLevelType是一个审核级别类型 #////////////////////////////////////////////////////////////////////// #零级审核 defineDict["THOST_FTDC_AMLCL_CheckLevel0"] = '0' #一级审核 defineDict["THOST_FTDC_AMLCL_CheckLevel1"] = '1' #二级审核 defineDict["THOST_FTDC_AMLCL_CheckLevel2"] = '2' #三级审核 defineDict["THOST_FTDC_AMLCL_CheckLevel3"] = '3' typedefDict["TThostFtdcAmlCheckLevelType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAmlCheckFlowType是一个反洗钱数据抽取审核流程类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAmlCheckFlowType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDataTypeType是一个数据类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDataTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExportFileTypeType是一个导出文件类型类型 #////////////////////////////////////////////////////////////////////// #CSV defineDict["THOST_FTDC_EFT_CSV"] = '0' #Excel defineDict["THOST_FTDC_EFT_EXCEL"] = '1' #DBF defineDict["THOST_FTDC_EFT_DBF"] = '2' typedefDict["TThostFtdcExportFileTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSettleManagerTypeType是一个结算配置类型类型 #////////////////////////////////////////////////////////////////////// #结算前准备 defineDict["THOST_FTDC_SMT_Before"] = '1' #结算 defineDict["THOST_FTDC_SMT_Settlement"] = '2' #结算后核对 defineDict["THOST_FTDC_SMT_After"] = '3' #结算后处理 defineDict["THOST_FTDC_SMT_Settlemented"] = '4' typedefDict["TThostFtdcSettleManagerTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSettleManagerIDType是一个结算配置代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSettleManagerIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSettleManagerNameType是一个结算配置名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSettleManagerNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSettleManagerLevelType是一个结算配置等级类型 #////////////////////////////////////////////////////////////////////// #必要 defineDict["THOST_FTDC_SML_Must"] = '1' #警告 defineDict["THOST_FTDC_SML_Alarm"] = '2' #提示 defineDict["THOST_FTDC_SML_Prompt"] = '3' #不检查 defineDict["THOST_FTDC_SML_Ignore"] = '4' typedefDict["TThostFtdcSettleManagerLevelType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSettleManagerGroupType是一个模块分组类型 #////////////////////////////////////////////////////////////////////// #交易所核对 defineDict["THOST_FTDC_SMG_Exhcange"] = '1' #内部核对 defineDict["THOST_FTDC_SMG_ASP"] = '2' #上报数据核对 defineDict["THOST_FTDC_SMG_CSRC"] = '3' typedefDict["TThostFtdcSettleManagerGroupType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCheckResultMemoType是一个核对结果说明类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCheckResultMemoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFunctionUrlType是一个功能链接类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcFunctionUrlType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAuthInfoType是一个客户端认证信息类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAuthInfoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAuthCodeType是一个客户端认证码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAuthCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcLimitUseTypeType是一个保值额度使用类型类型 #////////////////////////////////////////////////////////////////////// #可重复使用 defineDict["THOST_FTDC_LUT_Repeatable"] = '1' #不可重复使用 defineDict["THOST_FTDC_LUT_Unrepeatable"] = '2' typedefDict["TThostFtdcLimitUseTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDataResourceType是一个数据来源类型 #////////////////////////////////////////////////////////////////////// #本系统 defineDict["THOST_FTDC_DAR_Settle"] = '1' #交易所 defineDict["THOST_FTDC_DAR_Exchange"] = '2' #报送数据 defineDict["THOST_FTDC_DAR_CSRC"] = '3' typedefDict["TThostFtdcDataResourceType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMarginTypeType是一个保证金类型类型 #////////////////////////////////////////////////////////////////////// #交易所保证金率 defineDict["THOST_FTDC_MGT_ExchMarginRate"] = '0' #投资者保证金率 defineDict["THOST_FTDC_MGT_InstrMarginRate"] = '1' #投资者交易保证金率 defineDict["THOST_FTDC_MGT_InstrMarginRateTrade"] = '2' typedefDict["TThostFtdcMarginTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcActiveTypeType是一个生效类型类型 #////////////////////////////////////////////////////////////////////// #仅当日生效 defineDict["THOST_FTDC_ACT_Intraday"] = '1' #长期生效 defineDict["THOST_FTDC_ACT_Long"] = '2' typedefDict["TThostFtdcActiveTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMarginRateTypeType是一个冲突保证金率类型类型 #////////////////////////////////////////////////////////////////////// #交易所保证金率 defineDict["THOST_FTDC_MRT_Exchange"] = '1' #投资者保证金率 defineDict["THOST_FTDC_MRT_Investor"] = '2' #投资者交易保证金率 defineDict["THOST_FTDC_MRT_InvestorTrade"] = '3' typedefDict["TThostFtdcMarginRateTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBackUpStatusType是一个备份数据状态类型 #////////////////////////////////////////////////////////////////////// #未生成备份数据 defineDict["THOST_FTDC_BUS_UnBak"] = '0' #备份数据生成中 defineDict["THOST_FTDC_BUS_BakUp"] = '1' #已生成备份数据 defineDict["THOST_FTDC_BUS_BakUped"] = '2' #备份数据失败 defineDict["THOST_FTDC_BUS_BakFail"] = '3' typedefDict["TThostFtdcBackUpStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInitSettlementType是一个结算初始化状态类型 #////////////////////////////////////////////////////////////////////// #结算初始化未开始 defineDict["THOST_FTDC_SIS_UnInitialize"] = '0' #结算初始化中 defineDict["THOST_FTDC_SIS_Initialize"] = '1' #结算初始化完成 defineDict["THOST_FTDC_SIS_Initialized"] = '2' typedefDict["TThostFtdcInitSettlementType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcReportStatusType是一个报表数据生成状态类型 #////////////////////////////////////////////////////////////////////// #未生成报表数据 defineDict["THOST_FTDC_SRS_NoCreate"] = '0' #报表数据生成中 defineDict["THOST_FTDC_SRS_Create"] = '1' #已生成报表数据 defineDict["THOST_FTDC_SRS_Created"] = '2' #生成报表数据失败 defineDict["THOST_FTDC_SRS_CreateFail"] = '3' typedefDict["TThostFtdcReportStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSaveStatusType是一个数据归档状态类型 #////////////////////////////////////////////////////////////////////// #归档未完成 defineDict["THOST_FTDC_SSS_UnSaveData"] = '0' #归档完成 defineDict["THOST_FTDC_SSS_SaveDatad"] = '1' typedefDict["TThostFtdcSaveStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSettArchiveStatusType是一个结算确认数据归档状态类型 #////////////////////////////////////////////////////////////////////// #未归档数据 defineDict["THOST_FTDC_SAS_UnArchived"] = '0' #数据归档中 defineDict["THOST_FTDC_SAS_Archiving"] = '1' #已归档数据 defineDict["THOST_FTDC_SAS_Archived"] = '2' #归档数据失败 defineDict["THOST_FTDC_SAS_ArchiveFail"] = '3' typedefDict["TThostFtdcSettArchiveStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCTPTypeType是一个CTP交易系统类型类型 #////////////////////////////////////////////////////////////////////// #未知类型 defineDict["THOST_FTDC_CTPT_Unkown"] = '0' #主中心 defineDict["THOST_FTDC_CTPT_MainCenter"] = '1' #备中心 defineDict["THOST_FTDC_CTPT_BackUp"] = '2' typedefDict["TThostFtdcCTPTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcToolIDType是一个工具代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcToolIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcToolNameType是一个工具名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcToolNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCloseDealTypeType是一个平仓处理类型类型 #////////////////////////////////////////////////////////////////////// #正常 defineDict["THOST_FTDC_CDT_Normal"] = '0' #投机平仓优先 defineDict["THOST_FTDC_CDT_SpecFirst"] = '1' typedefDict["TThostFtdcCloseDealTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcMortgageFundUseRangeType是一个货币质押资金可用范围类型 #////////////////////////////////////////////////////////////////////// #不能使用 defineDict["THOST_FTDC_MFUR_None"] = '0' #用于保证金 defineDict["THOST_FTDC_MFUR_Margin"] = '1' #用于手续费、盈亏、保证金 defineDict["THOST_FTDC_MFUR_All"] = '2' typedefDict["TThostFtdcMortgageFundUseRangeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCurrencyUnitType是一个币种单位数量类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCurrencyUnitType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcExchangeRateType是一个汇率类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcExchangeRateType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcSpecProductTypeType是一个特殊产品类型类型 #////////////////////////////////////////////////////////////////////// #郑商所套保产品 defineDict["THOST_FTDC_SPT_CzceHedge"] = '1' #货币质押产品 defineDict["THOST_FTDC_SPT_IneForeignCurrency"] = '2' #大连短线开平仓产品 defineDict["THOST_FTDC_SPT_DceOpenClose"] = '3' typedefDict["TThostFtdcSpecProductTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFundMortgageTypeType是一个货币质押类型类型 #////////////////////////////////////////////////////////////////////// #质押 defineDict["THOST_FTDC_FMT_Mortgage"] = '1' #解质 defineDict["THOST_FTDC_FMT_Redemption"] = '2' typedefDict["TThostFtdcFundMortgageTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAccountSettlementParamIDType是一个投资者账户结算参数代码类型 #////////////////////////////////////////////////////////////////////// #基础保证金 defineDict["THOST_FTDC_ASPI_BaseMargin"] = '1' #最低权益标准 defineDict["THOST_FTDC_ASPI_LowestInterest"] = '2' typedefDict["TThostFtdcAccountSettlementParamIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCurrencyNameType是一个币种名称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCurrencyNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCurrencySignType是一个币种符号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCurrencySignType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFundMortDirectionType是一个货币质押方向类型 #////////////////////////////////////////////////////////////////////// #货币质入 defineDict["THOST_FTDC_FMD_In"] = '1' #货币质出 defineDict["THOST_FTDC_FMD_Out"] = '2' typedefDict["TThostFtdcFundMortDirectionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBusinessClassType是一个换汇类别类型 #////////////////////////////////////////////////////////////////////// #盈利 defineDict["THOST_FTDC_BT_Profit"] = '0' #亏损 defineDict["THOST_FTDC_BT_Loss"] = '1' #其他 defineDict["THOST_FTDC_BT_Other"] = 'Z' typedefDict["TThostFtdcBusinessClassType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSwapSourceTypeType是一个换汇数据来源类型 #////////////////////////////////////////////////////////////////////// #手工 defineDict["THOST_FTDC_SST_Manual"] = '0' #自动生成 defineDict["THOST_FTDC_SST_Automatic"] = '1' typedefDict["TThostFtdcSwapSourceTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCurrExDirectionType是一个换汇类型类型 #////////////////////////////////////////////////////////////////////// #结汇 defineDict["THOST_FTDC_CED_Settlement"] = '0' #售汇 defineDict["THOST_FTDC_CED_Sale"] = '1' typedefDict["TThostFtdcCurrExDirectionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCurrencySwapStatusType是一个申请状态类型 #////////////////////////////////////////////////////////////////////// #已录入 defineDict["THOST_FTDC_CSS_Entry"] = '1' #已审核 defineDict["THOST_FTDC_CSS_Approve"] = '2' #已拒绝 defineDict["THOST_FTDC_CSS_Refuse"] = '3' #已撤销 defineDict["THOST_FTDC_CSS_Revoke"] = '4' #已发送 defineDict["THOST_FTDC_CSS_Send"] = '5' #换汇成功 defineDict["THOST_FTDC_CSS_Success"] = '6' #换汇失败 defineDict["THOST_FTDC_CSS_Failure"] = '7' typedefDict["TThostFtdcCurrencySwapStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCurrExchCertNoType是一个凭证号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCurrExchCertNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBatchSerialNoType是一个批次号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBatchSerialNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcReqFlagType是一个换汇发送标志类型 #////////////////////////////////////////////////////////////////////// #未发送 defineDict["THOST_FTDC_REQF_NoSend"] = '0' #发送成功 defineDict["THOST_FTDC_REQF_SendSuccess"] = '1' #发送失败 defineDict["THOST_FTDC_REQF_SendFailed"] = '2' #等待重发 defineDict["THOST_FTDC_REQF_WaitReSend"] = '3' typedefDict["TThostFtdcReqFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcResFlagType是一个换汇返回成功标志类型 #////////////////////////////////////////////////////////////////////// #成功 defineDict["THOST_FTDC_RESF_Success"] = '0' #账户余额不足 defineDict["THOST_FTDC_RESF_InsuffiCient"] = '1' #交易结果未知 defineDict["THOST_FTDC_RESF_UnKnown"] = '8' typedefDict["TThostFtdcResFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPageControlType是一个换汇页面控制类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPageControlType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcRecordCountType是一个记录数类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcRecordCountType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcCurrencySwapMemoType是一个换汇需确认信息类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCurrencySwapMemoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExStatusType是一个修改状态类型 #////////////////////////////////////////////////////////////////////// #修改前 defineDict["THOST_FTDC_EXS_Before"] = '0' #修改后 defineDict["THOST_FTDC_EXS_After"] = '1' typedefDict["TThostFtdcExStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcClientRegionType是一个开户客户地域类型 #////////////////////////////////////////////////////////////////////// #国内客户 defineDict["THOST_FTDC_CR_Domestic"] = '1' #港澳台客户 defineDict["THOST_FTDC_CR_GMT"] = '2' #国外客户 defineDict["THOST_FTDC_CR_Foreign"] = '3' typedefDict["TThostFtdcClientRegionType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcWorkPlaceType是一个工作单位类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcWorkPlaceType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBusinessPeriodType是一个经营期限类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBusinessPeriodType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcWebSiteType是一个网址类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcWebSiteType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUOAIdCardTypeType是一个统一开户证件类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUOAIdCardTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcClientModeType是一个开户模式类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcClientModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInvestorFullNameType是一个投资者全称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInvestorFullNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUOABrokerIDType是一个境外中介机构ID类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUOABrokerIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUOAZipCodeType是一个邮政编码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUOAZipCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUOAEMailType是一个电子邮箱类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUOAEMailType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOldCityType是一个城市类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcOldCityType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCorporateIdentifiedCardNoType是一个法人代表证件号码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCorporateIdentifiedCardNoType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcHasBoardType是一个是否有董事会类型 #////////////////////////////////////////////////////////////////////// #没有 defineDict["THOST_FTDC_HB_No"] = '0' #有 defineDict["THOST_FTDC_HB_Yes"] = '1' typedefDict["TThostFtdcHasBoardType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcStartModeType是一个启动模式类型 #////////////////////////////////////////////////////////////////////// #正常 defineDict["THOST_FTDC_SM_Normal"] = '1' #应急 defineDict["THOST_FTDC_SM_Emerge"] = '2' #恢复 defineDict["THOST_FTDC_SM_Restore"] = '3' typedefDict["TThostFtdcStartModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcTemplateTypeType是一个模型类型类型 #////////////////////////////////////////////////////////////////////// #全量 defineDict["THOST_FTDC_TPT_Full"] = '1' #增量 defineDict["THOST_FTDC_TPT_Increment"] = '2' #备份 defineDict["THOST_FTDC_TPT_BackUp"] = '3' typedefDict["TThostFtdcTemplateTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcLoginModeType是一个登录模式类型 #////////////////////////////////////////////////////////////////////// #交易 defineDict["THOST_FTDC_LM_Trade"] = '0' #转账 defineDict["THOST_FTDC_LM_Transfer"] = '1' typedefDict["TThostFtdcLoginModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPromptTypeType是一个日历提示类型类型 #////////////////////////////////////////////////////////////////////// #合约上下市 defineDict["THOST_FTDC_CPT_Instrument"] = '1' #保证金分段生效 defineDict["THOST_FTDC_CPT_Margin"] = '2' typedefDict["TThostFtdcPromptTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcLedgerManageIDType是一个分户管理资产编码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcLedgerManageIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInvestVarietyType是一个投资品种类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInvestVarietyType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBankAccountTypeType是一个账户类别类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBankAccountTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcLedgerManageBankType是一个开户银行类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcLedgerManageBankType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCffexDepartmentNameType是一个开户营业部类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCffexDepartmentNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCffexDepartmentCodeType是一个营业部代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCffexDepartmentCodeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcHasTrusteeType是一个是否有托管人类型 #////////////////////////////////////////////////////////////////////// #有 defineDict["THOST_FTDC_HT_Yes"] = '1' #没有 defineDict["THOST_FTDC_HT_No"] = '0' typedefDict["TThostFtdcHasTrusteeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCMemo1Type是一个说明类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCMemo1Type"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAssetmgrCFullNameType是一个代理资产管理业务的期货公司全称类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAssetmgrCFullNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAssetmgrApprovalNOType是一个资产管理业务批文号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAssetmgrApprovalNOType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAssetmgrMgrNameType是一个资产管理业务负责人姓名类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAssetmgrMgrNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAmTypeType是一个机构类型类型 #////////////////////////////////////////////////////////////////////// #银行 defineDict["THOST_FTDC_AMT_Bank"] = '1' #证券公司 defineDict["THOST_FTDC_AMT_Securities"] = '2' #基金公司 defineDict["THOST_FTDC_AMT_Fund"] = '3' #保险公司 defineDict["THOST_FTDC_AMT_Insurance"] = '4' #信托公司 defineDict["THOST_FTDC_AMT_Trust"] = '5' #其他 defineDict["THOST_FTDC_AMT_Other"] = '9' typedefDict["TThostFtdcAmTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCAmTypeType是一个机构类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCAmTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCFundIOTypeType是一个出入金类型类型 #////////////////////////////////////////////////////////////////////// #出入金 defineDict["THOST_FTDC_CFIOT_FundIO"] = '0' #银期换汇 defineDict["THOST_FTDC_CFIOT_SwapCurrency"] = '1' typedefDict["TThostFtdcCSRCFundIOTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCusAccountTypeType是一个结算账户类型类型 #////////////////////////////////////////////////////////////////////// #期货结算账户 defineDict["THOST_FTDC_CAT_Futures"] = '1' #纯期货资管业务下的资管结算账户 defineDict["THOST_FTDC_CAT_AssetmgrFuture"] = '2' #综合类资管业务下的期货资管托管账户 defineDict["THOST_FTDC_CAT_AssetmgrTrustee"] = '3' #综合类资管业务下的资金中转账户 defineDict["THOST_FTDC_CAT_AssetmgrTransfer"] = '4' typedefDict["TThostFtdcCusAccountTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCNationalType是一个国籍类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCNationalType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCSRCSecAgentIDType是一个二级代理ID类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCSRCSecAgentIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcLanguageTypeType是一个通知语言类型类型 #////////////////////////////////////////////////////////////////////// #中文 defineDict["THOST_FTDC_LT_Chinese"] = '1' #英文 defineDict["THOST_FTDC_LT_English"] = '2' typedefDict["TThostFtdcLanguageTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAmAccountType是一个投资账户类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcAmAccountType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAssetmgrClientTypeType是一个资产管理客户类型类型 #////////////////////////////////////////////////////////////////////// #个人资管客户 defineDict["THOST_FTDC_AMCT_Person"] = '1' #单位资管客户 defineDict["THOST_FTDC_AMCT_Organ"] = '2' #特殊单位资管客户 defineDict["THOST_FTDC_AMCT_SpecialOrgan"] = '4' typedefDict["TThostFtdcAssetmgrClientTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcAssetmgrTypeType是一个投资类型类型 #////////////////////////////////////////////////////////////////////// #期货类 defineDict["THOST_FTDC_ASST_Futures"] = '3' #综合类 defineDict["THOST_FTDC_ASST_SpecialOrgan"] = '4' typedefDict["TThostFtdcAssetmgrTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcUOMType是一个计量单位类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcUOMType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSHFEInstLifePhaseType是一个上期所合约生命周期状态类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSHFEInstLifePhaseType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSHFEProductClassType是一个产品类型类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSHFEProductClassType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcPriceDecimalType是一个价格小数位类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcPriceDecimalType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcInTheMoneyFlagType是一个平值期权标志类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcInTheMoneyFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCheckInstrTypeType是一个合约比较类型类型 #////////////////////////////////////////////////////////////////////// #合约交易所不存在 defineDict["THOST_FTDC_CIT_HasExch"] = '0' #合约本系统不存在 defineDict["THOST_FTDC_CIT_HasATP"] = '1' #合约比较不一致 defineDict["THOST_FTDC_CIT_HasDiff"] = '2' typedefDict["TThostFtdcCheckInstrTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDeliveryTypeType是一个交割类型类型 #////////////////////////////////////////////////////////////////////// #手工交割 defineDict["THOST_FTDC_DT_HandDeliv"] = '1' #到期交割 defineDict["THOST_FTDC_DT_PersonDeliv"] = '2' typedefDict["TThostFtdcDeliveryTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBigMoneyType是一个资金类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcBigMoneyType"] = "float" #////////////////////////////////////////////////////////////////////// #TFtdcMaxMarginSideAlgorithmType是一个大额单边保证金算法类型 #////////////////////////////////////////////////////////////////////// #不使用大额单边保证金算法 defineDict["THOST_FTDC_MMSA_NO"] = '0' #使用大额单边保证金算法 defineDict["THOST_FTDC_MMSA_YES"] = '1' typedefDict["TThostFtdcMaxMarginSideAlgorithmType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDAClientTypeType是一个资产管理客户类型类型 #////////////////////////////////////////////////////////////////////// #自然人 defineDict["THOST_FTDC_CACT_Person"] = '0' #法人 defineDict["THOST_FTDC_CACT_Company"] = '1' #其他 defineDict["THOST_FTDC_CACT_Other"] = '2' typedefDict["TThostFtdcDAClientTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCombinInstrIDType是一个套利合约代码类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCombinInstrIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCombinSettlePriceType是一个各腿结算价类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcCombinSettlePriceType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDCEPriorityType是一个优先级类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcDCEPriorityType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcTradeGroupIDType是一个成交组号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcTradeGroupIDType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcIsCheckPrepaType是一个是否校验开户可用资金类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcIsCheckPrepaType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcUOAAssetmgrTypeType是一个投资类型类型 #////////////////////////////////////////////////////////////////////// #期货类 defineDict["THOST_FTDC_UOAAT_Futures"] = '1' #综合类 defineDict["THOST_FTDC_UOAAT_SpecialOrgan"] = '2' typedefDict["TThostFtdcUOAAssetmgrTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDirectionEnType是一个买卖方向类型 #////////////////////////////////////////////////////////////////////// #Buy defineDict["THOST_FTDC_DEN_Buy"] = '0' #Sell defineDict["THOST_FTDC_DEN_Sell"] = '1' typedefDict["TThostFtdcDirectionEnType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOffsetFlagEnType是一个开平标志类型 #////////////////////////////////////////////////////////////////////// #Position Opening defineDict["THOST_FTDC_OFEN_Open"] = '0' #Position Close defineDict["THOST_FTDC_OFEN_Close"] = '1' #Forced Liquidation defineDict["THOST_FTDC_OFEN_ForceClose"] = '2' #Close Today defineDict["THOST_FTDC_OFEN_CloseToday"] = '3' #Close Prev. defineDict["THOST_FTDC_OFEN_CloseYesterday"] = '4' #Forced Reduction defineDict["THOST_FTDC_OFEN_ForceOff"] = '5' #Local Forced Liquidation defineDict["THOST_FTDC_OFEN_LocalForceClose"] = '6' typedefDict["TThostFtdcOffsetFlagEnType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcHedgeFlagEnType是一个投机套保标志类型 #////////////////////////////////////////////////////////////////////// #Speculation defineDict["THOST_FTDC_HFEN_Speculation"] = '1' #Arbitrage defineDict["THOST_FTDC_HFEN_Arbitrage"] = '2' #Hedge defineDict["THOST_FTDC_HFEN_Hedge"] = '3' typedefDict["TThostFtdcHedgeFlagEnType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFundIOTypeEnType是一个出入金类型类型 #////////////////////////////////////////////////////////////////////// #Deposit/Withdrawal defineDict["THOST_FTDC_FIOTEN_FundIO"] = '1' #Bank-Futures Transfer defineDict["THOST_FTDC_FIOTEN_Transfer"] = '2' #Bank-Futures FX Exchange defineDict["THOST_FTDC_FIOTEN_SwapCurrency"] = '3' typedefDict["TThostFtdcFundIOTypeEnType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFundTypeEnType是一个资金类型类型 #////////////////////////////////////////////////////////////////////// #Bank Deposit defineDict["THOST_FTDC_FTEN_Deposite"] = '1' #Payment/Fee defineDict["THOST_FTDC_FTEN_ItemFund"] = '2' #Brokerage Adj defineDict["THOST_FTDC_FTEN_Company"] = '3' #Internal Transfer defineDict["THOST_FTDC_FTEN_InnerTransfer"] = '4' typedefDict["TThostFtdcFundTypeEnType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFundDirectionEnType是一个出入金方向类型 #////////////////////////////////////////////////////////////////////// #Deposit defineDict["THOST_FTDC_FDEN_In"] = '1' #Withdrawal defineDict["THOST_FTDC_FDEN_Out"] = '2' typedefDict["TThostFtdcFundDirectionEnType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcFundMortDirectionEnType是一个货币质押方向类型 #////////////////////////////////////////////////////////////////////// #Pledge defineDict["THOST_FTDC_FMDEN_In"] = '1' #Redemption defineDict["THOST_FTDC_FMDEN_Out"] = '2' typedefDict["TThostFtdcFundMortDirectionEnType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSwapBusinessTypeType是一个换汇业务种类类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcSwapBusinessTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOptionsTypeType是一个期权类型类型 #////////////////////////////////////////////////////////////////////// #看涨 defineDict["THOST_FTDC_CP_CallOptions"] = '1' #看跌 defineDict["THOST_FTDC_CP_PutOptions"] = '2' typedefDict["TThostFtdcOptionsTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcStrikeModeType是一个执行方式类型 #////////////////////////////////////////////////////////////////////// #欧式 defineDict["THOST_FTDC_STM_Continental"] = '0' #美式 defineDict["THOST_FTDC_STM_American"] = '1' #百慕大 defineDict["THOST_FTDC_STM_Bermuda"] = '2' typedefDict["TThostFtdcStrikeModeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcStrikeTypeType是一个执行类型类型 #////////////////////////////////////////////////////////////////////// #自身对冲 defineDict["THOST_FTDC_STT_Hedge"] = '0' #匹配执行 defineDict["THOST_FTDC_STT_Match"] = '1' typedefDict["TThostFtdcStrikeTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcApplyTypeType是一个中金所期权放弃执行申请类型类型 #////////////////////////////////////////////////////////////////////// #不执行数量 defineDict["THOST_FTDC_APPT_NotStrikeNum"] = '4' typedefDict["TThostFtdcApplyTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcGiveUpDataSourceType是一个放弃执行申请数据来源类型 #////////////////////////////////////////////////////////////////////// #系统生成 defineDict["THOST_FTDC_GUDS_Gen"] = '0' #手工添加 defineDict["THOST_FTDC_GUDS_Hand"] = '1' typedefDict["TThostFtdcGiveUpDataSourceType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExecOrderSysIDType是一个执行宣告系统编号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcExecOrderSysIDType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExecResultType是一个执行结果类型 #////////////////////////////////////////////////////////////////////// #没有执行 defineDict["THOST_FTDC_OER_NoExec"] = 'n' #已经取消 defineDict["THOST_FTDC_OER_Canceled"] = 'c' #执行成功 defineDict["THOST_FTDC_OER_OK"] = '0' #期权持仓不够 defineDict["THOST_FTDC_OER_NoPosition"] = '1' #资金不够 defineDict["THOST_FTDC_OER_NoDeposit"] = '2' #会员不存在 defineDict["THOST_FTDC_OER_NoParticipant"] = '3' #客户不存在 defineDict["THOST_FTDC_OER_NoClient"] = '4' #合约不存在 defineDict["THOST_FTDC_OER_NoInstrument"] = '6' #没有执行权限 defineDict["THOST_FTDC_OER_NoRight"] = '7' #不合理的数量 defineDict["THOST_FTDC_OER_InvalidVolume"] = '8' #没有足够的历史成交 defineDict["THOST_FTDC_OER_NoEnoughHistoryTrade"] = '9' #未知 defineDict["THOST_FTDC_OER_Unknown"] = 'a' typedefDict["TThostFtdcExecResultType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcStrikeSequenceType是一个执行序号类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcStrikeSequenceType"] = "int" #////////////////////////////////////////////////////////////////////// #TFtdcStrikeTimeType是一个执行时间类型 #////////////////////////////////////////////////////////////////////// typedefDict["TThostFtdcStrikeTimeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCombinationTypeType是一个组合类型类型 #////////////////////////////////////////////////////////////////////// #期货组合 defineDict["THOST_FTDC_COMBT_Future"] = '0' #垂直价差BUL defineDict["THOST_FTDC_COMBT_BUL"] = '1' #垂直价差BER defineDict["THOST_FTDC_COMBT_BER"] = '2' #跨式组合 defineDict["THOST_FTDC_COMBT_STD"] = '3' #宽跨式组合 defineDict["THOST_FTDC_COMBT_STG"] = '4' #备兑组合 defineDict["THOST_FTDC_COMBT_PRT"] = '5' typedefDict["TThostFtdcCombinationTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcOptionRoyaltyPriceTypeType是一个期权权利金价格类型类型 #////////////////////////////////////////////////////////////////////// #昨结算价 defineDict["THOST_FTDC_ORPT_PreSettlementPrice"] = '1' #开仓价 defineDict["THOST_FTDC_ORPT_OpenPrice"] = '4' typedefDict["TThostFtdcOptionRoyaltyPriceTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcBalanceAlgorithmType是一个权益算法类型 #////////////////////////////////////////////////////////////////////// #不计算期权市值盈亏 defineDict["THOST_FTDC_BLAG_Default"] = '1' #计算期权市值亏损 defineDict["THOST_FTDC_BLAG_IncludeOptValLost"] = '2' typedefDict["TThostFtdcBalanceAlgorithmType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcActionTypeType是一个执行类型类型 #////////////////////////////////////////////////////////////////////// #执行 defineDict["THOST_FTDC_ACTP_Exec"] = '1' #放弃 defineDict["THOST_FTDC_ACTP_Abandon"] = '2' typedefDict["TThostFtdcActionTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcForQuoteStatusType是一个询价状态类型 #////////////////////////////////////////////////////////////////////// #已经提交 defineDict["THOST_FTDC_FQST_Submitted"] = 'a' #已经接受 defineDict["THOST_FTDC_FQST_Accepted"] = 'b' #已经被拒绝 defineDict["THOST_FTDC_FQST_Rejected"] = 'c' typedefDict["TThostFtdcForQuoteStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcQuotStatusType是一个报价状态类型 #////////////////////////////////////////////////////////////////////// #未知 defineDict["THOST_FTDC_QTST_Unknown"] = 'a' #已经接受 defineDict["THOST_FTDC_QTST_Accepted"] = 'b' #已经撤销 defineDict["THOST_FTDC_QTST_Canceled"] = 'c' typedefDict["TThostFtdcQuotStatusType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcValueMethodType是一个取值方式类型 #////////////////////////////////////////////////////////////////////// #按绝对值 defineDict["THOST_FTDC_VM_Absolute"] = '0' #按比率 defineDict["THOST_FTDC_VM_Ratio"] = '1' typedefDict["TThostFtdcValueMethodType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExecOrderPositionFlagType是一个期权行权后是否保留期货头寸的标记类型 #////////////////////////////////////////////////////////////////////// #保留 defineDict["THOST_FTDC_EOPF_Reserve"] = '0' #不保留 defineDict["THOST_FTDC_EOPF_UnReserve"] = '1' typedefDict["TThostFtdcExecOrderPositionFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcExecOrderCloseFlagType是一个期权行权后生成的头寸是否自动平仓类型 #////////////////////////////////////////////////////////////////////// #自动平仓 defineDict["THOST_FTDC_EOCF_AutoClose"] = '0' #免于自动平仓 defineDict["THOST_FTDC_EOCF_NotToClose"] = '1' typedefDict["TThostFtdcExecOrderCloseFlagType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcProductTypeType是一个产品类型类型 #////////////////////////////////////////////////////////////////////// #期货 defineDict["THOST_FTDC_PTE_Futures"] = '1' #期权 defineDict["THOST_FTDC_PTE_Options"] = '2' typedefDict["TThostFtdcProductTypeType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCZCEUploadFileNameType是一个郑商所结算文件名类型 #////////////////////////////////////////////////////////////////////// #^\d{8}_zz_\d{4} defineDict["THOST_FTDC_CUFN_CUFN_O"] = 'O' #^\d{8}成交表 defineDict["THOST_FTDC_CUFN_CUFN_T"] = 'T' #^\d{8}单腿持仓表new defineDict["THOST_FTDC_CUFN_CUFN_P"] = 'P' #^\d{8}非平仓了结表 defineDict["THOST_FTDC_CUFN_CUFN_N"] = 'N' #^\d{8}平仓表 defineDict["THOST_FTDC_CUFN_CUFN_L"] = 'L' #^\d{8}资金表 defineDict["THOST_FTDC_CUFN_CUFN_F"] = 'F' #^\d{8}组合持仓表 defineDict["THOST_FTDC_CUFN_CUFN_C"] = 'C' #^\d{8}保证金参数表 defineDict["THOST_FTDC_CUFN_CUFN_M"] = 'M' typedefDict["TThostFtdcCZCEUploadFileNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcDCEUploadFileNameType是一个大商所结算文件名类型 #////////////////////////////////////////////////////////////////////// #^\d{8}_dl_\d{3} defineDict["THOST_FTDC_DUFN_DUFN_O"] = 'O' #^\d{8}_成交表 defineDict["THOST_FTDC_DUFN_DUFN_T"] = 'T' #^\d{8}_持仓表 defineDict["THOST_FTDC_DUFN_DUFN_P"] = 'P' #^\d{8}_资金结算表 defineDict["THOST_FTDC_DUFN_DUFN_F"] = 'F' #^\d{8}_优惠组合持仓明细表 defineDict["THOST_FTDC_DUFN_DUFN_C"] = 'C' #^\d{8}_持仓明细表 defineDict["THOST_FTDC_DUFN_DUFN_D"] = 'D' #^\d{8}_保证金参数表 defineDict["THOST_FTDC_DUFN_DUFN_M"] = 'M' #^\d{8}_期权执行表 defineDict["THOST_FTDC_DUFN_DUFN_S"] = 'S' typedefDict["TThostFtdcDCEUploadFileNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcSHFEUploadFileNameType是一个上期所结算文件名类型 #////////////////////////////////////////////////////////////////////// #^\d{4}_\d{8}_\d{8}_DailyFundChg defineDict["THOST_FTDC_SUFN_SUFN_O"] = 'O' #^\d{4}_\d{8}_\d{8}_Trade defineDict["THOST_FTDC_SUFN_SUFN_T"] = 'T' #^\d{4}_\d{8}_\d{8}_SettlementDetail defineDict["THOST_FTDC_SUFN_SUFN_P"] = 'P' #^\d{4}_\d{8}_\d{8}_Capital defineDict["THOST_FTDC_SUFN_SUFN_F"] = 'F' typedefDict["TThostFtdcSHFEUploadFileNameType"] = "string" #////////////////////////////////////////////////////////////////////// #TFtdcCFFEXUploadFileNameType是一个中金所结算文件名类型 #////////////////////////////////////////////////////////////////////// #^\d{4}_SG\d{1}_\d{8}_\d{1}_Trade defineDict["THOST_FTDC_CFUFN_SUFN_T"] = 'T' #^\d{4}_SG\d{1}_\d{8}_\d{1}_SettlementDetail defineDict["THOST_FTDC_CFUFN_SUFN_P"] = 'P' #^\d{4}_SG\d{1}_\d{8}_\d{1}_Capital defineDict["THOST_FTDC_CFUFN_SUFN_F"] = 'F' #^\d{4}_SG\d{1}_\d{8}_\d{1}_OptionExec defineDict["THOST_FTDC_CFUFN_SUFN_S"] = 'S' typedefDict["TThostFtdcCFFEXUploadFileNameType"] = "string"
mit
[ 3, 2644, 26, 9094, 13, 24, 199, 199, 9830, 275, 1052, 199, 12729, 275, 1052, 199, 199, 8426, 199, 17577, 2253, 8853, 245, 109, 9372, 10192, 22202, 27842, 120, 9360, 254, 199, 17577, 4627, 221, 22661, 19451, 116, 31350, 27328, 11825, 223, 6587, 108, 20916, 17087, 239, 20610, 199, 17577, 493, 377, 6724, 1899, 7394, 23516, 14, 72, 199, 17577, 19127, 7094, 107, 249, 17837, 232, 30998, 32041, 21341, 108, 24586, 6075, 97, 30026, 8106, 4344, 249, 30521, 22730, 10278, 199, 17577, 5570, 221, 199, 3, 7968, 614, 1690, 198, 14096, 114, 166, 117, 124, 6812, 233, 198, 198, 9051, 250, 29427, 119, 8400, 99, 29303, 199, 8426, 4388, 199, 8426, 199, 3, 13034, 2437, 424, 998, 13077, 22202, 13291, 30000, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 2437, 424, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 19042, 998, 13077, 23116, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 19042, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 24551, 13077, 29088, 10278, 199, 8426, 199, 12729, 905, 18217, 24551, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 14017, 33, 2501, 82, 13077, 24406, 16716, 223, 19012, 109, 10278, 199, 8426, 199, 12729, 905, 18217, 14017, 33, 2501, 82, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 14017, 985, 13077, 24406, 21434, 19012, 109, 10278, 199, 8426, 199, 12729, 905, 18217, 14017, 985, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 13188, 10083, 998, 13077, 24778, 21448, 22202, 8106, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 13188, 10083, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 4738, 2891, 13077, 27908, 12586, 244, 11428, 10278, 199, 8426, 199, 12729, 905, 18217, 4738, 2891, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 1262, 16448, 998, 13077, 27085, 30000, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 1262, 16448, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 28659, 13077, 22445, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 28659, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 6139, 13077, 26505, 8967, 10278, 199, 8426, 199, 12729, 905, 18217, 6139, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 3041, 998, 13077, 13291, 17637, 8967, 10278, 199, 8426, 199, 12729, 905, 18217, 3041, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 14915, 998, 13077, 24778, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 14915, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 21667, 998, 13077, 15280, 225, 11987, 119, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 21667, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 5884, 985, 13077, 6923, 101, 32531, 21434, 19012, 109, 10278, 199, 8426, 199, 12729, 905, 18217, 5884, 985, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 13188, 998, 13077, 22202, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 13188, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 13188, 985, 13077, 22202, 21434, 19012, 109, 10278, 199, 8426, 199, 12729, 905, 18217, 13188, 985, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 13188, 33, 2501, 82, 13077, 22202, 16716, 223, 19012, 109, 10278, 199, 8426, 199, 12729, 905, 18217, 13188, 33, 2501, 82, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 13188, 5318, 13077, 22202, 27044, 10278, 199, 8426, 199, 12729, 905, 18217, 13188, 5318, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 3399, 1476, 13077, 3399, 27340, 30899, 223, 10278, 199, 8426, 199, 12729, 905, 18217, 3399, 1476, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 3989, 998, 13077, 27842, 120, 9360, 254, 20804, 10278, 199, 8426, 199, 12729, 905, 18217, 3989, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 13188, 3697, 13077, 22202, 27289, 253, 17182, 101, 10278, 199, 8426, 199, 3, 17627, 97, 15280, 117, 199, 9830, 905, 11824, 63, 8797, 63, 11992, 63, 6241, 937, 275, 283, 16, 7, 199, 3, 13750, 118, 20466, 16888, 11112, 29319, 16888, 27908, 199, 9830, 905, 11824, 63, 8797, 63, 11992, 63, 8168, 4738, 2175, 17529, 937, 275, 283, 17, 7, 199, 199, 12729, 905, 18217, 13188, 3697, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 2506, 13077, 31502, 10278, 199, 8426, 199, 12729, 905, 18217, 2506, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 1366, 13077, 27381, 10278, 199, 8426, 199, 12729, 905, 18217, 1366, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 9551, 1366, 13077, 166, 244, 124, 27381, 10278, 199, 8426, 199, 12729, 905, 18217, 9551, 1366, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 14915, 985, 13077, 24778, 21434, 19012, 109, 10278, 199, 8426, 199, 12729, 905, 18217, 14915, 985, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 1084, 30198, 2448, 998, 13077, 21872, 21895, 32061, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 1084, 30198, 2448, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 4738, 11319, 998, 13077, 27908, 20804, 10278, 199, 8426, 199, 12729, 905, 18217, 4738, 11319, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 17529, 998, 13077, 16888, 11112, 20804, 10278, 199, 8426, 199, 12729, 905, 18217, 17529, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 3110, 804, 13077, 2846, 19580, 122, 5498, 98, 10278, 10278, 199, 8426, 199, 12729, 905, 18217, 3110, 804, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 14955, 13077, 1772, 27340, 30899, 223, 10278, 199, 8426, 199, 12729, 905, 18217, 14955, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 1772, 4313, 13077, 1772, 21341, 108, 6075, 97, 10278, 199, 8426, 199, 12729, 905, 18217, 1772, 4313, 804, 937, 275, 298, 442, 2, 199, 199, 8426, 199, 3 ]
[ 2644, 26, 9094, 13, 24, 199, 199, 9830, 275, 1052, 199, 12729, 275, 1052, 199, 199, 8426, 199, 17577, 2253, 8853, 245, 109, 9372, 10192, 22202, 27842, 120, 9360, 254, 199, 17577, 4627, 221, 22661, 19451, 116, 31350, 27328, 11825, 223, 6587, 108, 20916, 17087, 239, 20610, 199, 17577, 493, 377, 6724, 1899, 7394, 23516, 14, 72, 199, 17577, 19127, 7094, 107, 249, 17837, 232, 30998, 32041, 21341, 108, 24586, 6075, 97, 30026, 8106, 4344, 249, 30521, 22730, 10278, 199, 17577, 5570, 221, 199, 3, 7968, 614, 1690, 198, 14096, 114, 166, 117, 124, 6812, 233, 198, 198, 9051, 250, 29427, 119, 8400, 99, 29303, 199, 8426, 4388, 199, 8426, 199, 3, 13034, 2437, 424, 998, 13077, 22202, 13291, 30000, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 2437, 424, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 19042, 998, 13077, 23116, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 19042, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 24551, 13077, 29088, 10278, 199, 8426, 199, 12729, 905, 18217, 24551, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 14017, 33, 2501, 82, 13077, 24406, 16716, 223, 19012, 109, 10278, 199, 8426, 199, 12729, 905, 18217, 14017, 33, 2501, 82, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 14017, 985, 13077, 24406, 21434, 19012, 109, 10278, 199, 8426, 199, 12729, 905, 18217, 14017, 985, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 13188, 10083, 998, 13077, 24778, 21448, 22202, 8106, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 13188, 10083, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 4738, 2891, 13077, 27908, 12586, 244, 11428, 10278, 199, 8426, 199, 12729, 905, 18217, 4738, 2891, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 1262, 16448, 998, 13077, 27085, 30000, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 1262, 16448, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 28659, 13077, 22445, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 28659, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 6139, 13077, 26505, 8967, 10278, 199, 8426, 199, 12729, 905, 18217, 6139, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 3041, 998, 13077, 13291, 17637, 8967, 10278, 199, 8426, 199, 12729, 905, 18217, 3041, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 14915, 998, 13077, 24778, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 14915, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 21667, 998, 13077, 15280, 225, 11987, 119, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 21667, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 5884, 985, 13077, 6923, 101, 32531, 21434, 19012, 109, 10278, 199, 8426, 199, 12729, 905, 18217, 5884, 985, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 13188, 998, 13077, 22202, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 13188, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 13188, 985, 13077, 22202, 21434, 19012, 109, 10278, 199, 8426, 199, 12729, 905, 18217, 13188, 985, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 13188, 33, 2501, 82, 13077, 22202, 16716, 223, 19012, 109, 10278, 199, 8426, 199, 12729, 905, 18217, 13188, 33, 2501, 82, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 13188, 5318, 13077, 22202, 27044, 10278, 199, 8426, 199, 12729, 905, 18217, 13188, 5318, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 3399, 1476, 13077, 3399, 27340, 30899, 223, 10278, 199, 8426, 199, 12729, 905, 18217, 3399, 1476, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 3989, 998, 13077, 27842, 120, 9360, 254, 20804, 10278, 199, 8426, 199, 12729, 905, 18217, 3989, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 13188, 3697, 13077, 22202, 27289, 253, 17182, 101, 10278, 199, 8426, 199, 3, 17627, 97, 15280, 117, 199, 9830, 905, 11824, 63, 8797, 63, 11992, 63, 6241, 937, 275, 283, 16, 7, 199, 3, 13750, 118, 20466, 16888, 11112, 29319, 16888, 27908, 199, 9830, 905, 11824, 63, 8797, 63, 11992, 63, 8168, 4738, 2175, 17529, 937, 275, 283, 17, 7, 199, 199, 12729, 905, 18217, 13188, 3697, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 2506, 13077, 31502, 10278, 199, 8426, 199, 12729, 905, 18217, 2506, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 1366, 13077, 27381, 10278, 199, 8426, 199, 12729, 905, 18217, 1366, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 9551, 1366, 13077, 166, 244, 124, 27381, 10278, 199, 8426, 199, 12729, 905, 18217, 9551, 1366, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 14915, 985, 13077, 24778, 21434, 19012, 109, 10278, 199, 8426, 199, 12729, 905, 18217, 14915, 985, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 1084, 30198, 2448, 998, 13077, 21872, 21895, 32061, 10635, 10278, 199, 8426, 199, 12729, 905, 18217, 1084, 30198, 2448, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 4738, 11319, 998, 13077, 27908, 20804, 10278, 199, 8426, 199, 12729, 905, 18217, 4738, 11319, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 17529, 998, 13077, 16888, 11112, 20804, 10278, 199, 8426, 199, 12729, 905, 18217, 17529, 998, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 3110, 804, 13077, 2846, 19580, 122, 5498, 98, 10278, 10278, 199, 8426, 199, 12729, 905, 18217, 3110, 804, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 14955, 13077, 1772, 27340, 30899, 223, 10278, 199, 8426, 199, 12729, 905, 18217, 14955, 804, 937, 275, 298, 875, 2, 199, 199, 8426, 199, 3, 13034, 1772, 4313, 13077, 1772, 21341, 108, 6075, 97, 10278, 199, 8426, 199, 12729, 905, 18217, 1772, 4313, 804, 937, 275, 298, 442, 2, 199, 199, 8426, 199, 3, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
treveradams/connector-telephony
crm_phone/wizard/__init__.py
13
1035
# -*- coding: utf-8 -*- ############################################################################## # # CRM Phone module for OpenERP # Copyright (C) 2014 Alexis de Lattre <alexis@via.ecp.fr> # # 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 . import number_not_found from . import create_crm_phonecall
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 445, 11026, 27585, 859, 367, 7653, 199, 3, 259, 1898, 334, 35, 9, 6927, 22986, 374, 477, 491, 6796, 264, 665, 1895, 7291, 32, 12897, 14, 825, 80, 14, 4391, 30, 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, 1275, 492, 1329, 63, 1397, 63, 4214, 199, 504, 1275, 492, 1218, 63, 15213, 63, 9339, 1250, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 445, 11026, 27585, 859, 367, 7653, 199, 3, 259, 1898, 334, 35, 9, 6927, 22986, 374, 477, 491, 6796, 264, 665, 1895, 7291, 32, 12897, 14, 825, 80, 14, 4391, 30, 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, 1275, 492, 1329, 63, 1397, 63, 4214, 199, 504, 1275, 492, 1218, 63, 15213, 63, 9339, 1250, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
benfinke/ns_python
build/lib/nssrc/com/citrix/netscaler/nitro/resource/config/cs/csvserver_auditnslogpolicy_binding.py
3
14931
# # Copyright (c) 2008-2015 Citrix Systems, 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. # from nssrc.com.citrix.netscaler.nitro.resource.base.base_resource import base_resource from nssrc.com.citrix.netscaler.nitro.resource.base.base_resource import base_response from nssrc.com.citrix.netscaler.nitro.service.options import options from nssrc.com.citrix.netscaler.nitro.exception.nitro_exception import nitro_exception from nssrc.com.citrix.netscaler.nitro.util.nitro_util import nitro_util class csvserver_auditnslogpolicy_binding(base_resource) : """ Binding class showing the auditnslogpolicy that can be bound to csvserver. """ def __init__(self) : self._policyname = "" self._priority = 0 self._sc = "" self._name = "" self._targetlbvserver = "" self._gotopriorityexpression = "" self._bindpoint = "" self._invoke = False self._labeltype = "" self._labelname = "" self.___count = 0 @property def priority(self) : ur"""Priority for the policy. """ try : return self._priority except Exception as e: raise e @priority.setter def priority(self, priority) : ur"""Priority for the policy. """ try : self._priority = priority except Exception as e: raise e @property def bindpoint(self) : ur"""For a rewrite policy, the bind point to which to bind the policy. Note: This parameter applies only to rewrite policies, because content switching policies are evaluated only at request time. """ try : return self._bindpoint except Exception as e: raise e @bindpoint.setter def bindpoint(self, bindpoint) : ur"""For a rewrite policy, the bind point to which to bind the policy. Note: This parameter applies only to rewrite policies, because content switching policies are evaluated only at request time. """ try : self._bindpoint = bindpoint except Exception as e: raise e @property def policyname(self) : ur"""Policies bound to this vserver. """ try : return self._policyname except Exception as e: raise e @policyname.setter def policyname(self, policyname) : ur"""Policies bound to this vserver. """ try : self._policyname = policyname except Exception as e: raise e @property def labelname(self) : ur"""Name of the label to be invoked. """ try : return self._labelname except Exception as e: raise e @labelname.setter def labelname(self, labelname) : ur"""Name of the label to be invoked. """ try : self._labelname = labelname except Exception as e: raise e @property def name(self) : ur"""Name of the content switching virtual server to which the content switching policy applies.<br/>Minimum length = 1. """ try : return self._name except Exception as e: raise e @name.setter def name(self, name) : ur"""Name of the content switching virtual server to which the content switching policy applies.<br/>Minimum length = 1 """ try : self._name = name except Exception as e: raise e @property def gotopriorityexpression(self) : ur"""Expression or other value specifying the next policy to be evaluated if the current policy evaluates to TRUE. Specify one of the following values: * NEXT - Evaluate the policy with the next higher priority number. * END - End policy evaluation. * USE_INVOCATION_RESULT - Applicable if this policy invokes another policy label. If the final goto in the invoked policy label has a value of END, the evaluation stops. If the final goto is anything other than END, the current policy label performs a NEXT. * A default syntax expression that evaluates to a number. If you specify an expression, the number to which it evaluates determines the next policy to evaluate, as follows: * If the expression evaluates to a higher numbered priority, the policy with that priority is evaluated next. * If the expression evaluates to the priority of the current policy, the policy with the next higher numbered priority is evaluated next. * If the expression evaluates to a priority number that is numerically higher than the highest numbered priority, policy evaluation ends. An UNDEF event is triggered if: * The expression is invalid. * The expression evaluates to a priority number that is numerically lower than the current policy's priority. * The expression evaluates to a priority number that is between the current policy's priority number (say, 30) and the highest priority number (say, 100), but does not match any configured priority number (for example, the expression evaluates to the number 85). This example assumes that the priority number increments by 10 for every successive policy, and therefore a priority number of 85 does not exist in the policy label. """ try : return self._gotopriorityexpression except Exception as e: raise e @gotopriorityexpression.setter def gotopriorityexpression(self, gotopriorityexpression) : ur"""Expression or other value specifying the next policy to be evaluated if the current policy evaluates to TRUE. Specify one of the following values: * NEXT - Evaluate the policy with the next higher priority number. * END - End policy evaluation. * USE_INVOCATION_RESULT - Applicable if this policy invokes another policy label. If the final goto in the invoked policy label has a value of END, the evaluation stops. If the final goto is anything other than END, the current policy label performs a NEXT. * A default syntax expression that evaluates to a number. If you specify an expression, the number to which it evaluates determines the next policy to evaluate, as follows: * If the expression evaluates to a higher numbered priority, the policy with that priority is evaluated next. * If the expression evaluates to the priority of the current policy, the policy with the next higher numbered priority is evaluated next. * If the expression evaluates to a priority number that is numerically higher than the highest numbered priority, policy evaluation ends. An UNDEF event is triggered if: * The expression is invalid. * The expression evaluates to a priority number that is numerically lower than the current policy's priority. * The expression evaluates to a priority number that is between the current policy's priority number (say, 30) and the highest priority number (say, 100), but does not match any configured priority number (for example, the expression evaluates to the number 85). This example assumes that the priority number increments by 10 for every successive policy, and therefore a priority number of 85 does not exist in the policy label. """ try : self._gotopriorityexpression = gotopriorityexpression except Exception as e: raise e @property def targetlbvserver(self) : ur"""Name of the Load Balancing virtual server to which the content is switched, if policy rule is evaluated to be TRUE. Example: bind cs vs cs1 -policyname pol1 -priority 101 -targetLBVserver lb1 Note: Use this parameter only in case of Content Switching policy bind operations to a CS vserver. """ try : return self._targetlbvserver except Exception as e: raise e @targetlbvserver.setter def targetlbvserver(self, targetlbvserver) : ur"""Name of the Load Balancing virtual server to which the content is switched, if policy rule is evaluated to be TRUE. Example: bind cs vs cs1 -policyname pol1 -priority 101 -targetLBVserver lb1 Note: Use this parameter only in case of Content Switching policy bind operations to a CS vserver """ try : self._targetlbvserver = targetlbvserver except Exception as e: raise e @property def invoke(self) : ur"""Invoke a policy label if this policy's rule evaluates to TRUE (valid only for default-syntax policies such as application firewall, transform, integrated cache, rewrite, responder, and content switching). """ try : return self._invoke except Exception as e: raise e @invoke.setter def invoke(self, invoke) : ur"""Invoke a policy label if this policy's rule evaluates to TRUE (valid only for default-syntax policies such as application firewall, transform, integrated cache, rewrite, responder, and content switching). """ try : self._invoke = invoke except Exception as e: raise e @property def labeltype(self) : ur"""Type of label to be invoked. """ try : return self._labeltype except Exception as e: raise e @labeltype.setter def labeltype(self, labeltype) : ur"""Type of label to be invoked. """ try : self._labeltype = labeltype except Exception as e: raise e @property def sc(self) : ur"""The state of SureConnect the specified virtual server.<br/>Possible values = ON, OFF. """ try : return self._sc except Exception as e: raise e def _get_nitro_response(self, service, response) : ur""" converts nitro response into object and returns the object array in case of get request. """ try : result = service.payload_formatter.string_to_resource(csvserver_auditnslogpolicy_binding_response, response, self.__class__.__name__) if(result.errorcode != 0) : if (result.errorcode == 444) : service.clear_session(self) if result.severity : if (result.severity == "ERROR") : raise nitro_exception(result.errorcode, str(result.message), str(result.severity)) else : raise nitro_exception(result.errorcode, str(result.message), str(result.severity)) return result.csvserver_auditnslogpolicy_binding except Exception as e : raise e def _get_object_name(self) : ur""" Returns the value of object identifier argument """ try : if self.name is not None : return str(self.name) return None except Exception as e : raise e @classmethod def add(cls, client, resource) : try : if resource and type(resource) is not list : updateresource = csvserver_auditnslogpolicy_binding() updateresource.name = resource.name updateresource.policyname = resource.policyname updateresource.targetlbvserver = resource.targetlbvserver updateresource.priority = resource.priority updateresource.gotopriorityexpression = resource.gotopriorityexpression updateresource.bindpoint = resource.bindpoint updateresource.invoke = resource.invoke updateresource.labeltype = resource.labeltype updateresource.labelname = resource.labelname return updateresource.update_resource(client) else : if resource and len(resource) > 0 : updateresources = [csvserver_auditnslogpolicy_binding() for _ in range(len(resource))] for i in range(len(resource)) : updateresources[i].name = resource[i].name updateresources[i].policyname = resource[i].policyname updateresources[i].targetlbvserver = resource[i].targetlbvserver updateresources[i].priority = resource[i].priority updateresources[i].gotopriorityexpression = resource[i].gotopriorityexpression updateresources[i].bindpoint = resource[i].bindpoint updateresources[i].invoke = resource[i].invoke updateresources[i].labeltype = resource[i].labeltype updateresources[i].labelname = resource[i].labelname return cls.update_bulk_request(client, updateresources) except Exception as e : raise e @classmethod def delete(cls, client, resource) : try : if resource and type(resource) is not list : deleteresource = csvserver_auditnslogpolicy_binding() deleteresource.name = resource.name deleteresource.policyname = resource.policyname deleteresource.bindpoint = resource.bindpoint deleteresource.priority = resource.priority return deleteresource.delete_resource(client) else : if resource and len(resource) > 0 : deleteresources = [csvserver_auditnslogpolicy_binding() for _ in range(len(resource))] for i in range(len(resource)) : deleteresources[i].name = resource[i].name deleteresources[i].policyname = resource[i].policyname deleteresources[i].bindpoint = resource[i].bindpoint deleteresources[i].priority = resource[i].priority return cls.delete_bulk_request(client, deleteresources) except Exception as e : raise e @classmethod def get(cls, service, name) : ur""" Use this API to fetch csvserver_auditnslogpolicy_binding resources. """ try : obj = csvserver_auditnslogpolicy_binding() obj.name = name response = obj.get_resources(service) return response except Exception as e: raise e @classmethod def get_filtered(cls, service, name, filter_) : ur""" Use this API to fetch filtered set of csvserver_auditnslogpolicy_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = csvserver_auditnslogpolicy_binding() obj.name = name option_ = options() option_.filter = filter_ response = obj.getfiltered(service, option_) return response except Exception as e: raise e @classmethod def count(cls, service, name) : ur""" Use this API to count csvserver_auditnslogpolicy_binding resources configued on NetScaler. """ try : obj = csvserver_auditnslogpolicy_binding() obj.name = name option_ = options() option_.count = True response = obj.get_resources(service, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e: raise e @classmethod def count_filtered(cls, service, name, filter_) : ur""" Use this API to count the filtered set of csvserver_auditnslogpolicy_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = csvserver_auditnslogpolicy_binding() obj.name = name option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e: raise e class Sc: ON = "ON" OFF = "OFF" class Bindpoint: REQUEST = "REQUEST" RESPONSE = "RESPONSE" class Labeltype: reqvserver = "reqvserver" resvserver = "resvserver" policylabel = "policylabel" class csvserver_auditnslogpolicy_binding_response(base_response) : def __init__(self, length=1) : self.csvserver_auditnslogpolicy_binding = [] self.errorcode = 0 self.message = "" self.severity = "" self.sessionid = "" self.csvserver_auditnslogpolicy_binding = [csvserver_auditnslogpolicy_binding() for _ in range(length)]
apache-2.0
[ 3, 199, 3, 1898, 334, 67, 9, 9079, 13, 7806, 445, 390, 1904, 15285, 12, 3277, 14, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 531, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 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, 221, 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, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1927, 14, 1095, 14, 1095, 63, 1927, 492, 1300, 63, 1927, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1927, 14, 1095, 14, 1095, 63, 1927, 492, 1300, 63, 1310, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1364, 14, 1419, 492, 1511, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1971, 14, 18893, 63, 1971, 492, 20107, 63, 1971, 199, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1974, 14, 18893, 63, 1974, 492, 20107, 63, 1974, 199, 199, 533, 7392, 1000, 63, 14274, 561, 793, 3185, 63, 9140, 8, 1095, 63, 1927, 9, 520, 199, 198, 624, 22630, 316, 1021, 21207, 314, 13968, 561, 793, 3185, 626, 883, 506, 3914, 370, 7392, 1000, 14, 199, 198, 624, 199, 198, 318, 636, 826, 721, 277, 9, 520, 507, 198, 277, 423, 3185, 354, 275, 3087, 507, 198, 277, 423, 6693, 275, 378, 507, 198, 277, 423, 551, 275, 3087, 507, 198, 277, 423, 354, 275, 3087, 507, 198, 277, 423, 1375, 6374, 16120, 275, 3087, 507, 198, 277, 423, 7808, 21993, 3822, 5599, 275, 3087, 507, 198, 277, 423, 3409, 1403, 275, 3087, 507, 198, 277, 423, 15195, 275, 756, 507, 198, 277, 423, 1302, 466, 275, 3087, 507, 198, 277, 423, 1302, 354, 275, 3087, 507, 198, 277, 855, 63, 835, 275, 378, 421, 198, 32, 1829, 199, 198, 318, 7464, 8, 277, 9, 520, 507, 198, 300, 624, 14354, 367, 314, 4592, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 6693, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 6693, 14, 8345, 199, 198, 318, 7464, 8, 277, 12, 7464, 9, 520, 507, 198, 300, 624, 14354, 367, 314, 4592, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 277, 423, 6693, 275, 7464, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 5398, 1403, 8, 277, 9, 520, 507, 198, 300, 624, 1858, 282, 19913, 4592, 12, 314, 5398, 2376, 370, 1314, 370, 5398, 314, 4592, 14, 3390, 26, 961, 2725, 12966, 1454, 370, 19913, 14118, 12, 2952, 1564, 31620, 14118, 787, 13006, 1454, 737, 1056, 900, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 3409, 1403, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 3409, 1403, 14, 8345, 199, 198, 318, 5398, 1403, 8, 277, 12, 5398, 1403, 9, 520, 507, 198, 300, 624, 1858, 282, 19913, 4592, 12, 314, 5398, 2376, 370, 1314, 370, 5398, 314, 4592, 14, 3390, 26, 961, 2725, 12966, 1454, 370, 19913, 14118, 12, 2952, 1564, 31620, 14118, 787, 13006, 1454, 737, 1056, 900, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 277, 423, 3409, 1403, 275, 5398, 1403, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 4592, 354, 8, 277, 9, 520, 507, 198, 300, 624, 27079, 3914, 370, 642, 32398, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 3185, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 3185, 354, 14, 8345, 199, 198, 318, 4592, 354, 8, 277, 12, 4592, 354, 9, 520, 507, 198, 300, 624, 27079, 3914, 370, 642, 32398, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 277, 423, 3185, 354, 275, 4592, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 1768, 354, 8, 277, 9, 520, 507, 198, 300, 624, 985, 402, 314, 1768, 370, 506, 10302, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 1302, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1302, 354, 14, 8345, 199, 198, 318, 1768, 354, 8, 277, 12, 1768, 354, 9, 520, 507, 198, 300, 624, 985, 402, 314, 1768, 370, 506, 10302, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 277, 423, 1302, 354, 275, 1768, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 536, 8, 277, 9, 520, 507, 198, 300, 624, 985, 402, 314, 1564, 31620, 5791, 1654, 370, 1314, 314, 1564, 31620, 4592, 12966, 21455, 3289, 3133, 12092, 2582, 275, 221, 413, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 354, 14, 8345, 199, 198, 318, 536, 8, 277, 12, 536, 9, 520, 507, 198, 300, 624, 985, 402, 314, 1564, 31620, 5791, 1654, 370, 1314, 314, 1564, 31620, 4592, 12966, 21455, 3289, 3133, 12092, 2582, 275, 221, 413, 507, 198, 624, 507, 198, 893, 520, 686, 198, 277, 423, 354, 275, 536, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 4788, 21993, 3822, 5599 ]
[ 199, 3, 1898, 334, 67, 9, 9079, 13, 7806, 445, 390, 1904, 15285, 12, 3277, 14, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 531, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 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, 221, 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, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1927, 14, 1095, 14, 1095, 63, 1927, 492, 1300, 63, 1927, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1927, 14, 1095, 14, 1095, 63, 1927, 492, 1300, 63, 1310, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1364, 14, 1419, 492, 1511, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1971, 14, 18893, 63, 1971, 492, 20107, 63, 1971, 199, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1974, 14, 18893, 63, 1974, 492, 20107, 63, 1974, 199, 199, 533, 7392, 1000, 63, 14274, 561, 793, 3185, 63, 9140, 8, 1095, 63, 1927, 9, 520, 199, 198, 624, 22630, 316, 1021, 21207, 314, 13968, 561, 793, 3185, 626, 883, 506, 3914, 370, 7392, 1000, 14, 199, 198, 624, 199, 198, 318, 636, 826, 721, 277, 9, 520, 507, 198, 277, 423, 3185, 354, 275, 3087, 507, 198, 277, 423, 6693, 275, 378, 507, 198, 277, 423, 551, 275, 3087, 507, 198, 277, 423, 354, 275, 3087, 507, 198, 277, 423, 1375, 6374, 16120, 275, 3087, 507, 198, 277, 423, 7808, 21993, 3822, 5599, 275, 3087, 507, 198, 277, 423, 3409, 1403, 275, 3087, 507, 198, 277, 423, 15195, 275, 756, 507, 198, 277, 423, 1302, 466, 275, 3087, 507, 198, 277, 423, 1302, 354, 275, 3087, 507, 198, 277, 855, 63, 835, 275, 378, 421, 198, 32, 1829, 199, 198, 318, 7464, 8, 277, 9, 520, 507, 198, 300, 624, 14354, 367, 314, 4592, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 6693, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 6693, 14, 8345, 199, 198, 318, 7464, 8, 277, 12, 7464, 9, 520, 507, 198, 300, 624, 14354, 367, 314, 4592, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 277, 423, 6693, 275, 7464, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 5398, 1403, 8, 277, 9, 520, 507, 198, 300, 624, 1858, 282, 19913, 4592, 12, 314, 5398, 2376, 370, 1314, 370, 5398, 314, 4592, 14, 3390, 26, 961, 2725, 12966, 1454, 370, 19913, 14118, 12, 2952, 1564, 31620, 14118, 787, 13006, 1454, 737, 1056, 900, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 3409, 1403, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 3409, 1403, 14, 8345, 199, 198, 318, 5398, 1403, 8, 277, 12, 5398, 1403, 9, 520, 507, 198, 300, 624, 1858, 282, 19913, 4592, 12, 314, 5398, 2376, 370, 1314, 370, 5398, 314, 4592, 14, 3390, 26, 961, 2725, 12966, 1454, 370, 19913, 14118, 12, 2952, 1564, 31620, 14118, 787, 13006, 1454, 737, 1056, 900, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 277, 423, 3409, 1403, 275, 5398, 1403, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 4592, 354, 8, 277, 9, 520, 507, 198, 300, 624, 27079, 3914, 370, 642, 32398, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 3185, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 3185, 354, 14, 8345, 199, 198, 318, 4592, 354, 8, 277, 12, 4592, 354, 9, 520, 507, 198, 300, 624, 27079, 3914, 370, 642, 32398, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 277, 423, 3185, 354, 275, 4592, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 1768, 354, 8, 277, 9, 520, 507, 198, 300, 624, 985, 402, 314, 1768, 370, 506, 10302, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 1302, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1302, 354, 14, 8345, 199, 198, 318, 1768, 354, 8, 277, 12, 1768, 354, 9, 520, 507, 198, 300, 624, 985, 402, 314, 1768, 370, 506, 10302, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 277, 423, 1302, 354, 275, 1768, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 536, 8, 277, 9, 520, 507, 198, 300, 624, 985, 402, 314, 1564, 31620, 5791, 1654, 370, 1314, 314, 1564, 31620, 4592, 12966, 21455, 3289, 3133, 12092, 2582, 275, 221, 413, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 354, 14, 8345, 199, 198, 318, 536, 8, 277, 12, 536, 9, 520, 507, 198, 300, 624, 985, 402, 314, 1564, 31620, 5791, 1654, 370, 1314, 314, 1564, 31620, 4592, 12966, 21455, 3289, 3133, 12092, 2582, 275, 221, 413, 507, 198, 624, 507, 198, 893, 520, 686, 198, 277, 423, 354, 275, 536, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 4788, 21993, 3822, 5599, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
longde123/MultiversePlatform
server/src/multiverse/simpleclient/testclientgroups/group12.py
1
1820
# # The Multiverse Platform is made available under the MIT License. # # Copyright (c) 2012 The Multiverse Foundation # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation # files (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, # merge, publish, distribute, sublicense, and/or sell copies # of the Software, and to permit persons to whom the Software # is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE # OR OTHER DEALINGS IN THE SOFTWARE. # # from multiverse.mars import * from multiverse.mars.objects import * from multiverse.mars.util import * from multiverse.server.math import * from multiverse.server.events import * from multiverse.server.objects import * from multiverse.server.engine import * from multiverse.server.util import * from multiverse.msgsys import * from multiverse.simpleclient import * from java.lang import * # PlayerClient instance Log.debug("playerclient.py starting PlayerThread"); playerClient = PlayerClient("--zero_y --position (1800505,79698,73582) --square_side 100000") Log.debug("completed playerclient.py")
mit
[ 3, 199, 3, 221, 710, 6879, 2077, 16078, 365, 6326, 2808, 1334, 314, 10697, 844, 14, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 6029, 710, 6879, 2077, 2752, 199, 3, 199, 3, 221, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 221, 199, 3, 221, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 221, 199, 3, 221, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 221, 199, 3, 221, 5893, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 221, 199, 3, 221, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 221, 199, 3, 221, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 221, 199, 3, 221, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 221, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 221, 199, 3, 221, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 221, 199, 3, 221, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 221, 199, 3, 221, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 221, 199, 3, 221, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 221, 199, 3, 221, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 221, 199, 3, 221, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 221, 199, 3, 221, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 221, 199, 3, 221, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 221, 199, 3, 221, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 3, 199, 199, 504, 3510, 2077, 14, 77, 4291, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 1462, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 1974, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 3442, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 4368, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 1462, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 3908, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 1974, 492, 627, 199, 504, 3510, 2077, 14, 13429, 588, 492, 627, 199, 504, 3510, 2077, 14, 4129, 1258, 492, 627, 199, 504, 12120, 14, 4159, 492, 627, 199, 199, 3, 25610, 3041, 1256, 199, 199, 2445, 14, 1757, 480, 6147, 1258, 14, 647, 6617, 25610, 4436, 3547, 199, 199, 6147, 3041, 275, 25610, 3041, 6739, 4262, 63, 89, 1553, 3124, 334, 1085, 383, 13938, 12, 1965, 20983, 12, 31327, 2564, 9, 1553, 9646, 63, 2441, 25761, 531, 199, 199, 2445, 14, 1757, 480, 12634, 7748, 1258, 14, 647, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 221, 710, 6879, 2077, 16078, 365, 6326, 2808, 1334, 314, 10697, 844, 14, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 6029, 710, 6879, 2077, 2752, 199, 3, 199, 3, 221, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 221, 199, 3, 221, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 221, 199, 3, 221, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 221, 199, 3, 221, 5893, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 221, 199, 3, 221, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 221, 199, 3, 221, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 221, 199, 3, 221, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 221, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 221, 199, 3, 221, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 221, 199, 3, 221, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 221, 199, 3, 221, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 221, 199, 3, 221, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 221, 199, 3, 221, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 221, 199, 3, 221, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 221, 199, 3, 221, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 221, 199, 3, 221, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 221, 199, 3, 221, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 3, 199, 199, 504, 3510, 2077, 14, 77, 4291, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 1462, 492, 627, 199, 504, 3510, 2077, 14, 77, 4291, 14, 1974, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 3442, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 4368, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 1462, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 3908, 492, 627, 199, 504, 3510, 2077, 14, 1000, 14, 1974, 492, 627, 199, 504, 3510, 2077, 14, 13429, 588, 492, 627, 199, 504, 3510, 2077, 14, 4129, 1258, 492, 627, 199, 504, 12120, 14, 4159, 492, 627, 199, 199, 3, 25610, 3041, 1256, 199, 199, 2445, 14, 1757, 480, 6147, 1258, 14, 647, 6617, 25610, 4436, 3547, 199, 199, 6147, 3041, 275, 25610, 3041, 6739, 4262, 63, 89, 1553, 3124, 334, 1085, 383, 13938, 12, 1965, 20983, 12, 31327, 2564, 9, 1553, 9646, 63, 2441, 25761, 531, 199, 199, 2445, 14, 1757, 480, 12634, 7748, 1258, 14, 647, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
co-alliance/adr
sites/all/libraries/bookreader/BookReaderIA/datanode/BookReaderGetText.py
14
7045
#!/usr/bin/python # Copyright(c)2008-2010 Internet Archive. Software license AGPL version 3. # # This file is part of BookReader. # # BookReader 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. # # BookReader 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 BookReader. If not, see <http://www.gnu.org/licenses/>. # # The BookReader source is hosted at http://github.com/openlibrary/bookreader/ #watch out for blank lines (<LINE></LINE>) from lxml import etree import sys import re import json import re from windowed_iterator import windowed_iterator from diff_match_patch import diff_match_patch minWordsInBlock = 25 maxWordsInBlock = 50 # Header/Footer detection parameters # 'Window' of neighboring pages to check for similar text that may # mark headers / footers windowsize = 10 # Weights to assign to potential headers / footers. # len(weights) should be even. weights = (1.0, .75, .75, 1.0) # weights = (1.0, .75, .5, # .5, .75, 1.0) # allow potential headers/footers with this length difference max_length_difference = 4 dmp = diff_match_patch() dmp.Match_Distance = 2 # number of prepended characters allowed before match dmp.Match_Threshold = .5 # 0 to 1 ... higher => more fanciful matches, # slower execution. # minimum match score for a line to be considered a header or footer. min_score = .9 def guess_hfs(page, pages): """ Given a page and a 'windowed iterator' giving access to neighboring pages, return a dict containing likely header/footer lines on that page. A line is considered a likely header/footer if it's near the start/end of the page, and if it is textually similar the same line on neighboring pages. """ result = {} hf_candidates = get_hf_candidates(page) neighbor_info = {} for i in range(len(weights)): if hf_candidates[i] is None: continue score = 0 for neighbor_page in pages.neighbors(): if neighbor_page in neighbor_info: neighbor_candidates = neighbor_info[neighbor_page] else: neighbor_candidates = get_hf_candidates(neighbor_page) neighbor_info[neighbor_page] = neighbor_candidates if neighbor_candidates[i] is None: continue text = hf_candidates[i][1] neighbor_text = neighbor_candidates[i][1] if abs(len(text) - len(neighbor_text)) > max_length_difference: continue matchstart = dmp.match_main(hf_candidates[i][1], neighbor_candidates[i][1], 0) if matchstart != -1: score += weights[i] if score > min_score: result[hf_candidates[i][0]] = True break return result def simplify_line_text(line): text = etree.tostring(line, method='text', encoding=unicode).lower(); # collape numbers (roman too) to '@' so headers will be more # similar from page to page text = re.sub(r'[ivx\d]', r'@', text) text = re.sub(r'\s+', r' ', text) return text def get_hf_candidates(page): result = [] hfwin = len(weights) / 2 lines = [line for line in page.findall('.//LINE')] for i in range(hfwin) + range(-hfwin, 0): if abs(i) < len(lines): result.append((lines[i], simplify_line_text(lines[i]))) else: result.append(None) return result def main(args): path = args[0] pageNum = int(args[1]) callback = args[2] if not re.match('^/\d{1,2}/items/.+_djvu.xml$', path): sys.exit(-1); if ('ttsNextPageCB' != callback): callback = 'ttsStartCB' f = open(path) context = etree.iterparse(f, tag='OBJECT') def drop_event(iter): for event, page in iter: yield page pages = drop_event(context) def clear_page(page): page.clear() pages = windowed_iterator(pages, windowsize, clear_page) for i, page in enumerate(pages): if i == pageNum: break hfs = guess_hfs(page, pages) lines = page.findall('.//LINE') #print 'got %s .//lines' % len(lines) textBlocks = [] block = '' rects = [] numWords = 0 for line in lines: # skip headers/footers if line in hfs: continue top = sys.maxint left = sys.maxint right = -1 bottom = -1 numWordsInLine = 0 words = line.findall('.//WORD') #print 'at start of line, rects =' #print rects for word in words: numWordsInLine += 1 text = word.text #print 'got text ' + text coords = word.get('coords').split(',') #l,b,r,t coords = map(int, coords) if int(coords[0]) < left: left = coords[0] if coords[1] > bottom: bottom = coords[1] if coords[2] > right: right = coords[2] if coords[3] < top: top = coords[3] block += word.text + ' ' numWords += 1 if text.endswith('.') and (numWords>minWordsInBlock): #print 'end of block with numWords=%d' % numWords #print 'block = ' + block rects.append([left, bottom, right, top]) #textBlocks.append(block.strip()) rects.insert(0, block.strip()) textBlocks.append(rects) block = '' rects = [] numWords = 0 numWordsInLine = 0 top = sys.maxint left = sys.maxint right = -1 bottom = -1 #end of line if numWordsInLine > 0: rects.append([left, bottom, right, top]) if numWords>maxWordsInBlock: #textBlocks.append(block.strip()) rects.insert(0, block.strip()) textBlocks.append(rects) block = '' numWords = 0 rects = [] #print 'at end of line, rects =' #print rects if '' != block: #textBlocks.append(block.strip()) rects.insert(0, block.strip()) textBlocks.append(rects) print 'br.%s(%s);' % (callback, json.dumps(textBlocks)) if __name__ == '__main__': main(sys.argv[1:])
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 8, 67, 9, 9300, 13, 6542, 22026, 19521, 1912, 14, 2290, 4190, 437, 12006, 1015, 650, 14, 199, 3, 221, 199, 3, 961, 570, 365, 1777, 402, 8944, 5929, 14, 199, 3, 221, 199, 3, 258, 8944, 5929, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 258, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 258, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 258, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 258, 8944, 5929, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 258, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 258, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 258, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 258, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 258, 3180, 543, 8944, 5929, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 420, 199, 3, 258, 710, 8944, 5929, 1350, 365, 28311, 737, 1455, 921, 5031, 14, 957, 15, 1490, 4342, 15, 2706, 5503, 15, 421, 199, 3, 6821, 734, 367, 4596, 2385, 8642, 6174, 2957, 6174, 18956, 199, 199, 504, 14490, 492, 7559, 199, 646, 984, 199, 646, 295, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 4353, 379, 63, 5778, 492, 4353, 379, 63, 5778, 199, 504, 3915, 63, 1431, 63, 2068, 492, 3915, 63, 1431, 63, 2068, 199, 199, 827, 23759, 607, 3142, 275, 5661, 199, 988, 23759, 607, 3142, 275, 5238, 199, 199, 3, 10240, 15, 5686, 351, 15212, 2633, 199, 199, 3, 283, 4301, 7, 402, 1279, 4594, 6854, 6497, 370, 1104, 367, 8545, 1318, 626, 1443, 199, 3, 2216, 2323, 1182, 3925, 878, 199, 3806, 890, 275, 1616, 199, 199, 3, 2136, 2492, 370, 5090, 370, 12330, 2323, 1182, 3925, 878, 14, 199, 3, 822, 8, 4916, 9, 1077, 506, 2755, 14, 199, 4916, 275, 334, 17, 14, 16, 12, 1275, 2194, 12, 1779, 1275, 2194, 12, 413, 14, 16, 9, 199, 3, 4931, 275, 334, 17, 14, 16, 12, 1275, 2194, 12, 1275, 21, 12, 199, 3, 3322, 1275, 21, 12, 1275, 2194, 12, 413, 14, 16, 9, 199, 199, 3, 2040, 12330, 2323, 15, 1421, 878, 543, 642, 2582, 8865, 199, 988, 63, 1267, 63, 9196, 275, 841, 199, 199, 10930, 275, 3915, 63, 1431, 63, 2068, 342, 199, 10930, 14, 4486, 63, 10076, 275, 499, 327, 1329, 402, 20247, 4110, 4370, 2544, 1336, 199, 10930, 14, 4486, 63, 12109, 275, 1275, 21, 327, 378, 370, 413, 2263, 10948, 9265, 1655, 13758, 559, 1893, 4450, 12, 586, 327, 26200, 6451, 14, 199, 199, 3, 7481, 1336, 5396, 367, 282, 1004, 370, 506, 8652, 282, 1406, 503, 14178, 14, 199, 827, 63, 3397, 275, 1275, 25, 421, 199, 318, 9519, 63, 72, 2319, 8, 1606, 12, 6497, 304, 272, 408, 9138, 282, 2034, 436, 282, 283, 3806, 379, 6122, 7, 15131, 2879, 370, 1279, 4594, 6854, 272, 6497, 12, 372, 282, 1211, 3035, 12060, 1406, 15, 12781, 2385, 641, 626, 2034, 14, 339, 437, 1004, 365, 8652, 282, 12060, 1406, 15, 12781, 340, 652, 1159, 17429, 314, 272, 1343, 15, 500, 402, 314, 2034, 12, 436, 340, 652, 365, 1318, 3163, 8545, 314, 2011, 272, 1004, 641, 1279, 4594, 6854, 6497, 14, 272, 408, 2286, 754, 275, 1052, 2286, 394, 70, 63, 16389, 275, 664, 63, 9188, 63, 16389, 8, 1606, 9, 272, 15503, 63, 815, 275, 1052, 272, 367, 284, 315, 1425, 8, 552, 8, 4916, 2298, 267, 340, 394, 70, 63, 16389, 59, 73, 61, 365, 488, 26, 288, 1980, 267, 5396, 275, 378, 267, 367, 15503, 63, 1606, 315, 6497, 14, 11113, 837, 288, 340, 15503, 63, 1606, 315, 15503, 63, 815, 26, 355, 15503, 63, 16389, 275, 15503, 63, 815, 59, 13881, 63, 1606, 61, 288, 587, 26, 355, 15503, 63, 16389, 275, 664, 63, 9188, 63, 16389, 8, 13881, 63, 1606, 9, 355, 15503, 63, 815, 59, 13881, 63, 1606, 61, 275, 15503, 63, 16389, 288, 340, 15503, 63, 16389, 59, 73, 61, 365, 488, 26, 355, 1980, 288, 1318, 275, 394, 70, 63, 16389, 59, 73, 1527, 17, 61, 288, 15503, 63, 505, 275, 15503, 63, 16389, 59, 73, 1527, 17, 61, 288, 340, 2853, 8, 552, 8, 505, 9, 446, 822, 8, 13881, 63, 505, 430, 690, 1390, 63, 1267, 63, 9196, 26, 355, 1980, 7846, 1336, 928, 275, 14605, 14, 1431, 63, 973, 8, 9188, 63, 16389, 59, 73, 1527, 17, 467, 3147, 15503, 63, 16389, 59, 73, 1527, 17, 467, 378, 9, 288, 340, 1336, 928, 1137, 446, 17, 26, 355, 5396, 847, 4931, 59, 73, 61, 288, 340, 5396, 690, 1748, 63, 3397, 26, 355, 754, 59, 9188, 63, 16389, 59, 73, 1527, 16, 2677, 275, 715, 355, 2059, 272, 372, 754, 13359, 199, 318, 15037, 63, 604, 63, 505, 8, 604, 304, 272, 1318, 275, 7559, 14, 14028, 8, 604, 12, 1083, 534, 505, 297, 2644, 29, 2975, 680, 2325, 7303, 272, 327, 1048, 416, 321, 5579, 334, 20971, 4634, 9, 370, 22143, 880, 2323, 911, 506, 1655, 272, 327, 8545, 687, 2034, 370, 2034, 272, 1318, 275, 295, 14, 954, 8, 82, 3894, 1003, 88, 60, 68, 4300, 519, 20812, 297, 1318, 9, 272, 1318, 275, 295, 14, 954, 8, 82, 1154, 83, 7386, 519, 7, 1656, 1318, 9, 272, 372, 1318, 421, 199, 318, 664, 63, 9188, 63, 16389, 8, 1606, 304, 272, 754, 275, 942, 272, 394, 70, 2676, 275, 822, 8, 4916, 9, 1182, 499, 272, 2385, 275, 359, 604, 367, 1004, 315, 2034, 14, 6452, 29995, 6174, 5440, 272, 367, 284, 315, 1425, 8, 9188, 2676, 9, 435, 1425, 2801, 9188, 2676, 12, 378, 304, 267, 340, 2853, 8, 73, 9, 665, 822, 8, 1278, 304, 288, 754, 14, 740, 1332, 1278, 59, 73, 467, 15037, 63, 604, 63, 505, 8, 1278, 59 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 8, 67, 9, 9300, 13, 6542, 22026, 19521, 1912, 14, 2290, 4190, 437, 12006, 1015, 650, 14, 199, 3, 221, 199, 3, 961, 570, 365, 1777, 402, 8944, 5929, 14, 199, 3, 221, 199, 3, 258, 8944, 5929, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 258, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 258, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 258, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 258, 8944, 5929, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 258, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 258, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 258, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 258, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 258, 3180, 543, 8944, 5929, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 420, 199, 3, 258, 710, 8944, 5929, 1350, 365, 28311, 737, 1455, 921, 5031, 14, 957, 15, 1490, 4342, 15, 2706, 5503, 15, 421, 199, 3, 6821, 734, 367, 4596, 2385, 8642, 6174, 2957, 6174, 18956, 199, 199, 504, 14490, 492, 7559, 199, 646, 984, 199, 646, 295, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 4353, 379, 63, 5778, 492, 4353, 379, 63, 5778, 199, 504, 3915, 63, 1431, 63, 2068, 492, 3915, 63, 1431, 63, 2068, 199, 199, 827, 23759, 607, 3142, 275, 5661, 199, 988, 23759, 607, 3142, 275, 5238, 199, 199, 3, 10240, 15, 5686, 351, 15212, 2633, 199, 199, 3, 283, 4301, 7, 402, 1279, 4594, 6854, 6497, 370, 1104, 367, 8545, 1318, 626, 1443, 199, 3, 2216, 2323, 1182, 3925, 878, 199, 3806, 890, 275, 1616, 199, 199, 3, 2136, 2492, 370, 5090, 370, 12330, 2323, 1182, 3925, 878, 14, 199, 3, 822, 8, 4916, 9, 1077, 506, 2755, 14, 199, 4916, 275, 334, 17, 14, 16, 12, 1275, 2194, 12, 1779, 1275, 2194, 12, 413, 14, 16, 9, 199, 3, 4931, 275, 334, 17, 14, 16, 12, 1275, 2194, 12, 1275, 21, 12, 199, 3, 3322, 1275, 21, 12, 1275, 2194, 12, 413, 14, 16, 9, 199, 199, 3, 2040, 12330, 2323, 15, 1421, 878, 543, 642, 2582, 8865, 199, 988, 63, 1267, 63, 9196, 275, 841, 199, 199, 10930, 275, 3915, 63, 1431, 63, 2068, 342, 199, 10930, 14, 4486, 63, 10076, 275, 499, 327, 1329, 402, 20247, 4110, 4370, 2544, 1336, 199, 10930, 14, 4486, 63, 12109, 275, 1275, 21, 327, 378, 370, 413, 2263, 10948, 9265, 1655, 13758, 559, 1893, 4450, 12, 586, 327, 26200, 6451, 14, 199, 199, 3, 7481, 1336, 5396, 367, 282, 1004, 370, 506, 8652, 282, 1406, 503, 14178, 14, 199, 827, 63, 3397, 275, 1275, 25, 421, 199, 318, 9519, 63, 72, 2319, 8, 1606, 12, 6497, 304, 272, 408, 9138, 282, 2034, 436, 282, 283, 3806, 379, 6122, 7, 15131, 2879, 370, 1279, 4594, 6854, 272, 6497, 12, 372, 282, 1211, 3035, 12060, 1406, 15, 12781, 2385, 641, 626, 2034, 14, 339, 437, 1004, 365, 8652, 282, 12060, 1406, 15, 12781, 340, 652, 1159, 17429, 314, 272, 1343, 15, 500, 402, 314, 2034, 12, 436, 340, 652, 365, 1318, 3163, 8545, 314, 2011, 272, 1004, 641, 1279, 4594, 6854, 6497, 14, 272, 408, 2286, 754, 275, 1052, 2286, 394, 70, 63, 16389, 275, 664, 63, 9188, 63, 16389, 8, 1606, 9, 272, 15503, 63, 815, 275, 1052, 272, 367, 284, 315, 1425, 8, 552, 8, 4916, 2298, 267, 340, 394, 70, 63, 16389, 59, 73, 61, 365, 488, 26, 288, 1980, 267, 5396, 275, 378, 267, 367, 15503, 63, 1606, 315, 6497, 14, 11113, 837, 288, 340, 15503, 63, 1606, 315, 15503, 63, 815, 26, 355, 15503, 63, 16389, 275, 15503, 63, 815, 59, 13881, 63, 1606, 61, 288, 587, 26, 355, 15503, 63, 16389, 275, 664, 63, 9188, 63, 16389, 8, 13881, 63, 1606, 9, 355, 15503, 63, 815, 59, 13881, 63, 1606, 61, 275, 15503, 63, 16389, 288, 340, 15503, 63, 16389, 59, 73, 61, 365, 488, 26, 355, 1980, 288, 1318, 275, 394, 70, 63, 16389, 59, 73, 1527, 17, 61, 288, 15503, 63, 505, 275, 15503, 63, 16389, 59, 73, 1527, 17, 61, 288, 340, 2853, 8, 552, 8, 505, 9, 446, 822, 8, 13881, 63, 505, 430, 690, 1390, 63, 1267, 63, 9196, 26, 355, 1980, 7846, 1336, 928, 275, 14605, 14, 1431, 63, 973, 8, 9188, 63, 16389, 59, 73, 1527, 17, 467, 3147, 15503, 63, 16389, 59, 73, 1527, 17, 467, 378, 9, 288, 340, 1336, 928, 1137, 446, 17, 26, 355, 5396, 847, 4931, 59, 73, 61, 288, 340, 5396, 690, 1748, 63, 3397, 26, 355, 754, 59, 9188, 63, 16389, 59, 73, 1527, 16, 2677, 275, 715, 355, 2059, 272, 372, 754, 13359, 199, 318, 15037, 63, 604, 63, 505, 8, 604, 304, 272, 1318, 275, 7559, 14, 14028, 8, 604, 12, 1083, 534, 505, 297, 2644, 29, 2975, 680, 2325, 7303, 272, 327, 1048, 416, 321, 5579, 334, 20971, 4634, 9, 370, 22143, 880, 2323, 911, 506, 1655, 272, 327, 8545, 687, 2034, 370, 2034, 272, 1318, 275, 295, 14, 954, 8, 82, 3894, 1003, 88, 60, 68, 4300, 519, 20812, 297, 1318, 9, 272, 1318, 275, 295, 14, 954, 8, 82, 1154, 83, 7386, 519, 7, 1656, 1318, 9, 272, 372, 1318, 421, 199, 318, 664, 63, 9188, 63, 16389, 8, 1606, 304, 272, 754, 275, 942, 272, 394, 70, 2676, 275, 822, 8, 4916, 9, 1182, 499, 272, 2385, 275, 359, 604, 367, 1004, 315, 2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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 ]
spawnedc/MeCanBlog
django/contrib/comments/moderation.py
246
13528
""" A generic comment-moderation system which allows configuration of moderation options on a per-model basis. To use, do two things: 1. Create or import a subclass of ``CommentModerator`` defining the options you want. 2. Import ``moderator`` from this module and register one or more models, passing the models and the ``CommentModerator`` options class you want to use. Example ------- First, we define a simple model class which might represent entries in a Weblog:: from django.db import models class Entry(models.Model): title = models.CharField(maxlength=250) body = models.TextField() pub_date = models.DateField() enable_comments = models.BooleanField() Then we create a ``CommentModerator`` subclass specifying some moderation options:: from django.contrib.comments.moderation import CommentModerator, moderator class EntryModerator(CommentModerator): email_notification = True enable_field = 'enable_comments' And finally register it for moderation:: moderator.register(Entry, EntryModerator) This sample class would apply two moderation steps to each new comment submitted on an Entry: * If the entry's ``enable_comments`` field is set to ``False``, the comment will be rejected (immediately deleted). * If the comment is successfully posted, an email notification of the comment will be sent to site staff. For a full list of built-in moderation options and other configurability, see the documentation for the ``CommentModerator`` class. """ import datetime from django.conf import settings from django.core.mail import send_mail from django.contrib.comments import signals from django.db.models.base import ModelBase from django.template import Context, loader from django.contrib import comments from django.contrib.sites.models import Site class AlreadyModerated(Exception): """ Raised when a model which is already registered for moderation is attempting to be registered again. """ pass class NotModerated(Exception): """ Raised when a model which is not registered for moderation is attempting to be unregistered. """ pass class CommentModerator(object): """ Encapsulates comment-moderation options for a given model. This class is not designed to be used directly, since it doesn't enable any of the available moderation options. Instead, subclass it and override attributes to enable different options:: ``auto_close_field`` If this is set to the name of a ``DateField`` or ``DateTimeField`` on the model for which comments are being moderated, new comments for objects of that model will be disallowed (immediately deleted) when a certain number of days have passed after the date specified in that field. Must be used in conjunction with ``close_after``, which specifies the number of days past which comments should be disallowed. Default value is ``None``. ``auto_moderate_field`` Like ``auto_close_field``, but instead of outright deleting new comments when the requisite number of days have elapsed, it will simply set the ``is_public`` field of new comments to ``False`` before saving them. Must be used in conjunction with ``moderate_after``, which specifies the number of days past which comments should be moderated. Default value is ``None``. ``close_after`` If ``auto_close_field`` is used, this must specify the number of days past the value of the field specified by ``auto_close_field`` after which new comments for an object should be disallowed. Default value is ``None``. ``email_notification`` If ``True``, any new comment on an object of this model which survives moderation will generate an email to site staff. Default value is ``False``. ``enable_field`` If this is set to the name of a ``BooleanField`` on the model for which comments are being moderated, new comments on objects of that model will be disallowed (immediately deleted) whenever the value of that field is ``False`` on the object the comment would be attached to. Default value is ``None``. ``moderate_after`` If ``auto_moderate_field`` is used, this must specify the number of days past the value of the field specified by ``auto_moderate_field`` after which new comments for an object should be marked non-public. Default value is ``None``. Most common moderation needs can be covered by changing these attributes, but further customization can be obtained by subclassing and overriding the following methods. Each method will be called with three arguments: ``comment``, which is the comment being submitted, ``content_object``, which is the object the comment will be attached to, and ``request``, which is the ``HttpRequest`` in which the comment is being submitted:: ``allow`` Should return ``True`` if the comment should be allowed to post on the content object, and ``False`` otherwise (in which case the comment will be immediately deleted). ``email`` If email notification of the new comment should be sent to site staff or moderators, this method is responsible for sending the email. ``moderate`` Should return ``True`` if the comment should be moderated (in which case its ``is_public`` field will be set to ``False`` before saving), and ``False`` otherwise (in which case the ``is_public`` field will not be changed). Subclasses which want to introspect the model for which comments are being moderated can do so through the attribute ``_model``, which will be the model class. """ auto_close_field = None auto_moderate_field = None close_after = None email_notification = False enable_field = None moderate_after = None def __init__(self, model): self._model = model def _get_delta(self, now, then): """ Internal helper which will return a ``datetime.timedelta`` representing the time between ``now`` and ``then``. Assumes ``now`` is a ``datetime.date`` or ``datetime.datetime`` later than ``then``. If ``now`` and ``then`` are not of the same type due to one of them being a ``datetime.date`` and the other being a ``datetime.datetime``, both will be coerced to ``datetime.date`` before calculating the delta. """ if now.__class__ is not then.__class__: now = datetime.date(now.year, now.month, now.day) then = datetime.date(then.year, then.month, then.day) if now < then: raise ValueError("Cannot determine moderation rules because date field is set to a value in the future") return now - then def allow(self, comment, content_object, request): """ Determine whether a given comment is allowed to be posted on a given object. Return ``True`` if the comment should be allowed, ``False otherwise. """ if self.enable_field: if not getattr(content_object, self.enable_field): return False if self.auto_close_field and self.close_after is not None: close_after_date = getattr(content_object, self.auto_close_field) if close_after_date is not None and self._get_delta(datetime.datetime.now(), close_after_date).days >= self.close_after: return False return True def moderate(self, comment, content_object, request): """ Determine whether a given comment on a given object should be allowed to show up immediately, or should be marked non-public and await approval. Return ``True`` if the comment should be moderated (marked non-public), ``False`` otherwise. """ if self.auto_moderate_field and self.moderate_after is not None: moderate_after_date = getattr(content_object, self.auto_moderate_field) if moderate_after_date is not None and self._get_delta(datetime.datetime.now(), moderate_after_date).days >= self.moderate_after: return True return False def email(self, comment, content_object, request): """ Send email notification of a new comment to site staff when email notifications have been requested. """ if not self.email_notification: return recipient_list = [manager_tuple[1] for manager_tuple in settings.MANAGERS] t = loader.get_template('comments/comment_notification_email.txt') c = Context({ 'comment': comment, 'content_object': content_object }) subject = '[%s] New comment posted on "%s"' % (Site.objects.get_current().name, content_object) message = t.render(c) send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True) class Moderator(object): """ Handles moderation of a set of models. An instance of this class will maintain a list of one or more models registered for comment moderation, and their associated moderation classes, and apply moderation to all incoming comments. To register a model, obtain an instance of ``Moderator`` (this module exports one as ``moderator``), and call its ``register`` method, passing the model class and a moderation class (which should be a subclass of ``CommentModerator``). Note that both of these should be the actual classes, not instances of the classes. To cease moderation for a model, call the ``unregister`` method, passing the model class. For convenience, both ``register`` and ``unregister`` can also accept a list of model classes in place of a single model; this allows easier registration of multiple models with the same ``CommentModerator`` class. The actual moderation is applied in two phases: one prior to saving a new comment, and the other immediately after saving. The pre-save moderation may mark a comment as non-public or mark it to be removed; the post-save moderation may delete a comment which was disallowed (there is currently no way to prevent the comment being saved once before removal) and, if the comment is still around, will send any notification emails the comment generated. """ def __init__(self): self._registry = {} self.connect() def connect(self): """ Hook up the moderation methods to pre- and post-save signals from the comment models. """ signals.comment_will_be_posted.connect(self.pre_save_moderation, sender=comments.get_model()) signals.comment_was_posted.connect(self.post_save_moderation, sender=comments.get_model()) def register(self, model_or_iterable, moderation_class): """ Register a model or a list of models for comment moderation, using a particular moderation class. Raise ``AlreadyModerated`` if any of the models are already registered. """ if isinstance(model_or_iterable, ModelBase): model_or_iterable = [model_or_iterable] for model in model_or_iterable: if model in self._registry: raise AlreadyModerated("The model '%s' is already being moderated" % model._meta.module_name) self._registry[model] = moderation_class(model) def unregister(self, model_or_iterable): """ Remove a model or a list of models from the list of models whose comments will be moderated. Raise ``NotModerated`` if any of the models are not currently registered for moderation. """ 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 NotModerated("The model '%s' is not currently being moderated" % model._meta.module_name) del self._registry[model] def pre_save_moderation(self, sender, comment, request, **kwargs): """ Apply any necessary pre-save moderation steps to new comments. """ model = comment.content_type.model_class() if model not in self._registry: return content_object = comment.content_object moderation_class = self._registry[model] # Comment will be disallowed outright (HTTP 403 response) if not moderation_class.allow(comment, content_object, request): return False if moderation_class.moderate(comment, content_object, request): comment.is_public = False def post_save_moderation(self, sender, comment, request, **kwargs): """ Apply any necessary post-save moderation steps to new comments. """ model = comment.content_type.model_class() if model not in self._registry: return self._registry[model].email(comment, comment.content_object, request) # Import this instance in your own code to use in registering # your models for moderation. moderator = Moderator()
bsd-3-clause
[ 624, 199, 33, 7809, 3721, 13, 632, 1754, 2656, 1314, 6127, 2897, 402, 199, 632, 1754, 1511, 641, 282, 1126, 13, 1238, 5597, 14, 199, 199, 1378, 675, 12, 886, 2877, 7645, 26, 199, 199, 17, 14, 2790, 503, 492, 282, 5516, 402, 1124, 7488, 1385, 9043, 1040, 12669, 314, 2043, 1511, 1265, 2934, 14, 199, 199, 18, 14, 3161, 1124, 25597, 1040, 687, 642, 859, 436, 2274, 1373, 503, 1655, 2043, 1709, 12, 9476, 314, 1709, 436, 314, 1124, 7488, 1385, 9043, 1040, 1511, 2043, 1021, 1265, 2934, 370, 675, 14, 421, 199, 9846, 199, 12797, 199, 199, 7147, 12, 781, 5627, 282, 3486, 1402, 1021, 1314, 5594, 2954, 4811, 315, 199, 65, 6001, 793, 447, 339, 687, 1639, 14, 697, 492, 1709, 339, 1021, 11855, 8, 992, 14, 1685, 304, 267, 2538, 275, 1709, 14, 2183, 8, 988, 1267, 29, 7991, 9, 267, 2396, 275, 1709, 14, 6254, 342, 267, 7974, 63, 602, 275, 1709, 14, 14071, 342, 267, 4756, 63, 6223, 275, 1709, 14, 5036, 342, 199, 199, 28226, 781, 1218, 282, 1124, 7488, 1385, 9043, 1040, 5516, 9176, 2005, 199, 632, 1754, 1511, 447, 339, 687, 1639, 14, 2828, 14, 6223, 14, 632, 1754, 492, 6819, 1385, 9043, 12, 818, 9043, 339, 1021, 11855, 1385, 9043, 8, 7488, 1385, 9043, 304, 267, 3031, 63, 6761, 275, 715, 267, 4756, 63, 698, 275, 283, 4296, 63, 6223, 7, 199, 199, 3325, 3753, 2274, 652, 367, 818, 1754, 447, 339, 818, 9043, 14, 2683, 8, 3900, 12, 11855, 1385, 9043, 9, 199, 199, 2765, 2690, 1021, 3955, 4838, 2877, 818, 1754, 7124, 370, 1924, 892, 199, 3349, 16930, 641, 376, 11855, 26, 199, 199, 10, 982, 314, 2397, 1159, 1124, 4296, 63, 6223, 1040, 901, 365, 663, 370, 1124, 797, 4542, 314, 523, 3721, 911, 506, 18935, 334, 20250, 590, 5463, 680, 199, 199, 10, 982, 314, 3721, 365, 8792, 22752, 12, 376, 3031, 6955, 402, 314, 523, 3721, 911, 506, 4847, 370, 4770, 12622, 14, 199, 199, 1858, 282, 2615, 769, 402, 6137, 13, 262, 818, 1754, 1511, 436, 1163, 199, 888, 300, 3616, 12, 1937, 314, 3794, 367, 314, 1124, 7488, 1385, 9043, 1040, 199, 533, 14, 199, 199, 624, 199, 199, 646, 2197, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1198, 492, 3222, 63, 1198, 199, 504, 1639, 14, 2828, 14, 6223, 492, 10166, 199, 504, 1639, 14, 697, 14, 992, 14, 1095, 492, 5822, 1563, 199, 504, 1639, 14, 1160, 492, 9470, 12, 5077, 199, 504, 1639, 14, 2828, 492, 6786, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 199, 533, 21086, 1385, 12601, 8, 1726, 304, 272, 408, 272, 24997, 1380, 282, 1402, 1314, 365, 2575, 7264, 367, 818, 1754, 365, 272, 19595, 370, 506, 7264, 4020, 14, 339, 408, 272, 986, 199, 199, 533, 2832, 1385, 12601, 8, 1726, 304, 272, 408, 272, 24997, 1380, 282, 1402, 1314, 365, 440, 7264, 367, 818, 1754, 365, 272, 19595, 370, 506, 625, 11616, 14, 339, 408, 272, 986, 199, 199, 533, 6819, 1385, 9043, 8, 785, 304, 272, 408, 272, 3447, 12029, 15409, 3721, 13, 632, 1754, 1511, 367, 282, 1627, 1402, 14, 339, 961, 1021, 365, 440, 19829, 370, 506, 1202, 5370, 12, 3967, 652, 3181, 1133, 272, 4756, 1263, 402, 314, 2808, 818, 1754, 1511, 14, 15345, 12, 5516, 272, 652, 436, 4278, 3004, 370, 4756, 3365, 1511, 447, 339, 1124, 2495, 63, 1600, 63, 698, 1040, 267, 982, 642, 365, 663, 370, 314, 536, 402, 282, 1124, 14071, 1040, 503, 267, 1124, 4626, 1040, 641, 314, 1402, 367, 1314, 6786, 787, 267, 3769, 818, 12601, 12, 892, 6786, 367, 2251, 402, 626, 1402, 267, 911, 506, 30994, 334, 20250, 590, 5463, 9, 1380, 282, 9842, 267, 1329, 402, 7609, 1172, 3032, 2410, 314, 1434, 2013, 315, 267, 626, 901, 14, 9498, 506, 1202, 315, 22888, 543, 267, 1124, 1600, 63, 4399, 4542, 1314, 9314, 314, 1329, 402, 7609, 13541, 267, 1314, 6786, 1077, 506, 30994, 14, 3758, 574, 365, 267, 1124, 403, 4345, 339, 1124, 2495, 63, 632, 1866, 63, 698, 1040, 267, 16485, 1124, 2495, 63, 1600, 63, 698, 4542, 1325, 3140, 402, 734, 1019, 267, 13794, 892, 6786, 1380, 314, 295, 783, 2124, 1329, 402, 7609, 267, 1172, 14439, 12, 652, 911, 9329, 663, 314, 1124, 374, 63, 3455, 1040, 901, 267, 402, 892, 6786, 370, 1124, 797, 1040, 2544, 13369, 3062, 14, 9498, 506, 267, 1202, 315, 22888, 543, 1124, 632, 1866, 63, 4399, 4542, 1314, 267, 9314, 314, 1329, 402, 7609, 13541, 1314, 6786, 1077, 506, 267, 818, 12601, 14, 3758, 574, 365, 1124, 403, 4345, 339, 1124, 1600, 63, 4399, 1040, 267, 982, 1124, 2495, 63, 1600, 63, 698, 1040, 365, 1202, 12, 642, 1471, 4165, 314, 267, 1329, 402, 7609, 13541, 314, 574, 402, 314, 901, 2013, 701, 267, 1124, 2495, 63, 1600, 63, 698, 1040, 2410, 1314, 892, 6786, 367, 376, 267, 909, 1077, 506, 30994, 14, 3758, 574, 365, 1124, 403, 4345, 339, 1124, 2123, 63, 6761, 1040, 267, 982, 1124, 549, 4542, 1263, 892, 3721, 641, 376, 909, 402, 642, 1402, 267, 1314, 6296, 433, 2310, 818, 1754, 911, 3550, 376, 3031, 370, 4770, 267, 12622, 14, 3758, 574, 365, 1124, 797, 4345, 339, 1124, 4296, 63, 698, 1040, 267, 982, 642, 365, 663, 370, 314, 536, 402, 282, 1124, 5036, 1040, 641, 314, 267, 1402, 367, 1314, 6786, 787, 3769, 818, 12601, 12, 892, 6786, 267, 641, 2251, 402, 626, 1402, 911, 506, 30994, 334, 20250, 590, 267, 5463, 9, 18119, 314, 574, 402, 626, 901, 365, 1124, 797, 1040, 641, 267, 314, 909, 314, 3721, 3955, 506, 10102, 370, 14, 3758, 574, 267, 365, 1124, 403, 4345, 339, 1124, 632, 1866, 63, 4399, 1040, 267, 982, 1124, 2495, 63, 632, 1866, 63, 698, 1040, 365, 1202, 12, 642, 1471, 4165, 314, 1329, 267, 402, 7609, 13541, 314, 574, 402, 314, 901, 2013, 701, 267, 1124, 2495, 63, 632, 1866, 63, 698, 1040, 2410, 1314, 892, 6786, 367, 376, 267, 909, 1077, 506, 11584, 2222, 13, 3455, 14, 3758, 574, 365, 267, 1124, 403, 4345, 339, 17536, 2863, 818, 1754, 4839, 883, 506, 24295 ]
[ 199, 33, 7809, 3721, 13, 632, 1754, 2656, 1314, 6127, 2897, 402, 199, 632, 1754, 1511, 641, 282, 1126, 13, 1238, 5597, 14, 199, 199, 1378, 675, 12, 886, 2877, 7645, 26, 199, 199, 17, 14, 2790, 503, 492, 282, 5516, 402, 1124, 7488, 1385, 9043, 1040, 12669, 314, 2043, 1511, 1265, 2934, 14, 199, 199, 18, 14, 3161, 1124, 25597, 1040, 687, 642, 859, 436, 2274, 1373, 503, 1655, 2043, 1709, 12, 9476, 314, 1709, 436, 314, 1124, 7488, 1385, 9043, 1040, 1511, 2043, 1021, 1265, 2934, 370, 675, 14, 421, 199, 9846, 199, 12797, 199, 199, 7147, 12, 781, 5627, 282, 3486, 1402, 1021, 1314, 5594, 2954, 4811, 315, 199, 65, 6001, 793, 447, 339, 687, 1639, 14, 697, 492, 1709, 339, 1021, 11855, 8, 992, 14, 1685, 304, 267, 2538, 275, 1709, 14, 2183, 8, 988, 1267, 29, 7991, 9, 267, 2396, 275, 1709, 14, 6254, 342, 267, 7974, 63, 602, 275, 1709, 14, 14071, 342, 267, 4756, 63, 6223, 275, 1709, 14, 5036, 342, 199, 199, 28226, 781, 1218, 282, 1124, 7488, 1385, 9043, 1040, 5516, 9176, 2005, 199, 632, 1754, 1511, 447, 339, 687, 1639, 14, 2828, 14, 6223, 14, 632, 1754, 492, 6819, 1385, 9043, 12, 818, 9043, 339, 1021, 11855, 1385, 9043, 8, 7488, 1385, 9043, 304, 267, 3031, 63, 6761, 275, 715, 267, 4756, 63, 698, 275, 283, 4296, 63, 6223, 7, 199, 199, 3325, 3753, 2274, 652, 367, 818, 1754, 447, 339, 818, 9043, 14, 2683, 8, 3900, 12, 11855, 1385, 9043, 9, 199, 199, 2765, 2690, 1021, 3955, 4838, 2877, 818, 1754, 7124, 370, 1924, 892, 199, 3349, 16930, 641, 376, 11855, 26, 199, 199, 10, 982, 314, 2397, 1159, 1124, 4296, 63, 6223, 1040, 901, 365, 663, 370, 1124, 797, 4542, 314, 523, 3721, 911, 506, 18935, 334, 20250, 590, 5463, 680, 199, 199, 10, 982, 314, 3721, 365, 8792, 22752, 12, 376, 3031, 6955, 402, 314, 523, 3721, 911, 506, 4847, 370, 4770, 12622, 14, 199, 199, 1858, 282, 2615, 769, 402, 6137, 13, 262, 818, 1754, 1511, 436, 1163, 199, 888, 300, 3616, 12, 1937, 314, 3794, 367, 314, 1124, 7488, 1385, 9043, 1040, 199, 533, 14, 199, 199, 624, 199, 199, 646, 2197, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1198, 492, 3222, 63, 1198, 199, 504, 1639, 14, 2828, 14, 6223, 492, 10166, 199, 504, 1639, 14, 697, 14, 992, 14, 1095, 492, 5822, 1563, 199, 504, 1639, 14, 1160, 492, 9470, 12, 5077, 199, 504, 1639, 14, 2828, 492, 6786, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 199, 533, 21086, 1385, 12601, 8, 1726, 304, 272, 408, 272, 24997, 1380, 282, 1402, 1314, 365, 2575, 7264, 367, 818, 1754, 365, 272, 19595, 370, 506, 7264, 4020, 14, 339, 408, 272, 986, 199, 199, 533, 2832, 1385, 12601, 8, 1726, 304, 272, 408, 272, 24997, 1380, 282, 1402, 1314, 365, 440, 7264, 367, 818, 1754, 365, 272, 19595, 370, 506, 625, 11616, 14, 339, 408, 272, 986, 199, 199, 533, 6819, 1385, 9043, 8, 785, 304, 272, 408, 272, 3447, 12029, 15409, 3721, 13, 632, 1754, 1511, 367, 282, 1627, 1402, 14, 339, 961, 1021, 365, 440, 19829, 370, 506, 1202, 5370, 12, 3967, 652, 3181, 1133, 272, 4756, 1263, 402, 314, 2808, 818, 1754, 1511, 14, 15345, 12, 5516, 272, 652, 436, 4278, 3004, 370, 4756, 3365, 1511, 447, 339, 1124, 2495, 63, 1600, 63, 698, 1040, 267, 982, 642, 365, 663, 370, 314, 536, 402, 282, 1124, 14071, 1040, 503, 267, 1124, 4626, 1040, 641, 314, 1402, 367, 1314, 6786, 787, 267, 3769, 818, 12601, 12, 892, 6786, 367, 2251, 402, 626, 1402, 267, 911, 506, 30994, 334, 20250, 590, 5463, 9, 1380, 282, 9842, 267, 1329, 402, 7609, 1172, 3032, 2410, 314, 1434, 2013, 315, 267, 626, 901, 14, 9498, 506, 1202, 315, 22888, 543, 267, 1124, 1600, 63, 4399, 4542, 1314, 9314, 314, 1329, 402, 7609, 13541, 267, 1314, 6786, 1077, 506, 30994, 14, 3758, 574, 365, 267, 1124, 403, 4345, 339, 1124, 2495, 63, 632, 1866, 63, 698, 1040, 267, 16485, 1124, 2495, 63, 1600, 63, 698, 4542, 1325, 3140, 402, 734, 1019, 267, 13794, 892, 6786, 1380, 314, 295, 783, 2124, 1329, 402, 7609, 267, 1172, 14439, 12, 652, 911, 9329, 663, 314, 1124, 374, 63, 3455, 1040, 901, 267, 402, 892, 6786, 370, 1124, 797, 1040, 2544, 13369, 3062, 14, 9498, 506, 267, 1202, 315, 22888, 543, 1124, 632, 1866, 63, 4399, 4542, 1314, 267, 9314, 314, 1329, 402, 7609, 13541, 1314, 6786, 1077, 506, 267, 818, 12601, 14, 3758, 574, 365, 1124, 403, 4345, 339, 1124, 1600, 63, 4399, 1040, 267, 982, 1124, 2495, 63, 1600, 63, 698, 1040, 365, 1202, 12, 642, 1471, 4165, 314, 267, 1329, 402, 7609, 13541, 314, 574, 402, 314, 901, 2013, 701, 267, 1124, 2495, 63, 1600, 63, 698, 1040, 2410, 1314, 892, 6786, 367, 376, 267, 909, 1077, 506, 30994, 14, 3758, 574, 365, 1124, 403, 4345, 339, 1124, 2123, 63, 6761, 1040, 267, 982, 1124, 549, 4542, 1263, 892, 3721, 641, 376, 909, 402, 642, 1402, 267, 1314, 6296, 433, 2310, 818, 1754, 911, 3550, 376, 3031, 370, 4770, 267, 12622, 14, 3758, 574, 365, 1124, 797, 4345, 339, 1124, 4296, 63, 698, 1040, 267, 982, 642, 365, 663, 370, 314, 536, 402, 282, 1124, 5036, 1040, 641, 314, 267, 1402, 367, 1314, 6786, 787, 3769, 818, 12601, 12, 892, 6786, 267, 641, 2251, 402, 626, 1402, 911, 506, 30994, 334, 20250, 590, 267, 5463, 9, 18119, 314, 574, 402, 626, 901, 365, 1124, 797, 1040, 641, 267, 314, 909, 314, 3721, 3955, 506, 10102, 370, 14, 3758, 574, 267, 365, 1124, 403, 4345, 339, 1124, 632, 1866, 63, 4399, 1040, 267, 982, 1124, 2495, 63, 632, 1866, 63, 698, 1040, 365, 1202, 12, 642, 1471, 4165, 314, 1329, 267, 402, 7609, 13541, 314, 574, 402, 314, 901, 2013, 701, 267, 1124, 2495, 63, 632, 1866, 63, 698, 1040, 2410, 1314, 892, 6786, 367, 376, 267, 909, 1077, 506, 11584, 2222, 13, 3455, 14, 3758, 574, 365, 267, 1124, 403, 4345, 339, 17536, 2863, 818, 1754, 4839, 883, 506, 24295, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
escattone/kuma
kuma/api/v1/tests/test_plus.py
1
4264
import json import pytest from kuma.core.urlresolvers import reverse from kuma.plus.models import LandingPageSurvey @pytest.mark.django_db def test_ping_landing_page_survey_happy_path(client, settings): # This sets the needed session cookie variant_url = reverse("api.v1.plus.landing_page_variant") response = client.get(variant_url) assert response.status_code == 200 variant = response.json()["variant"] url = reverse("api.v1.plus.landing_page_survey") response = client.get(url, HTTP_CLOUDFRONT_VIEWER_COUNTRY_NAME="Antartica") assert response.status_code == 200 (result,) = LandingPageSurvey.objects.all() assert result.variant == variant assert not result.email assert not result.response assert result.geo_information == "Antartica" # Now fill it with an email response = client.post( url, {"uuid": str(result.uuid), "email": " peterbe@example.com "}, ) assert response.status_code == 200 (result,) = LandingPageSurvey.objects.all() assert result.variant == variant assert result.email == "peterbe@example.com" assert not result.response # Now fill it with a response response = client.post( url, { "uuid": str(result.uuid), "response": json.dumps({"price": "perfect"}), }, ) assert response.status_code == 200 (result,) = LandingPageSurvey.objects.all() assert result.variant == variant assert result.email == "peterbe@example.com" assert result.response == json.dumps({"price": "perfect"}) @pytest.mark.django_db def test_ping_landing_page_survey_bad_request(client): url = reverse("api.v1.plus.landing_page_survey") # No ?variant=... response = client.get(url) assert response.status_code == 400 # This sets the needed session cookie variant_url = reverse("api.v1.plus.landing_page_variant") response = client.get(variant_url) assert response.status_code == 200 # Not a valid UUID response = client.get(url, {"uuid": "xxx"}) assert response.status_code == 400 # Not a recognized UUID response = client.get(url, {"uuid": "88f7a689-454a-4647-99bf-d62fa66da24a"}) assert response.status_code == 404 @pytest.mark.django_db def test_ping_landing_page_survey_reuse_uuid(client): # This sets the needed session cookie variant_url = reverse("api.v1.plus.landing_page_variant") response = client.get(variant_url) assert response.status_code == 200 url = reverse("api.v1.plus.landing_page_survey") response1 = client.get(url, HTTP_CLOUDFRONT_VIEWER_COUNTRY_NAME="Sweden") assert response1.status_code == 200 assert LandingPageSurvey.objects.all().count() == 1 response2 = client.get( url, {"uuid": response1.json()["uuid"]}, HTTP_CLOUDFRONT_VIEWER_COUNTRY_NAME="USA", ) assert response2.json()["uuid"] == response1.json()["uuid"] assert LandingPageSurvey.objects.all().count() == 1 @pytest.mark.django_db def test_ping_landing_page_survey_authenticated(user_client, wiki_user): # This sets the needed session cookie variant_url = reverse("api.v1.plus.landing_page_variant") response = user_client.get(variant_url) assert response.status_code == 200 url = reverse("api.v1.plus.landing_page_survey") response = user_client.get(url) assert response.status_code == 200 (result,) = LandingPageSurvey.objects.all() assert result.user == wiki_user @pytest.mark.django_db def test_landing_page_variant_happy_path(client, settings): # Note `settings.PLUS_VARIANTS` is set in `kuma.settings.pytest` url = reverse("api.v1.plus.landing_page_variant") response = client.get(url) assert response.status_code == 200 first_time = response.json() assert first_time["variant"] > 0 assert first_time["variant"] <= len(settings.PLUS_VARIANTS) assert first_time["price"] in settings.PLUS_VARIANTS # It should stick no matter how many times you run it for _ in range(10): response = client.get(url) assert response.status_code == 200 assert response.json()["variant"] == first_time["variant"] assert response.json()["price"] == first_time["price"]
mpl-2.0
[ 646, 2022, 199, 199, 646, 4613, 199, 199, 504, 1022, 85, 391, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1022, 85, 391, 14, 6666, 14, 992, 492, 491, 460, 316, 3276, 30188, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 4073, 63, 9688, 316, 63, 1606, 63, 10625, 63, 72, 18869, 63, 515, 8, 1258, 12, 2202, 304, 272, 327, 961, 5951, 314, 4346, 2351, 5494, 272, 9854, 63, 633, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 8759, 531, 272, 1177, 275, 1890, 14, 362, 8, 8759, 63, 633, 9, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 272, 9854, 275, 1177, 14, 1001, 22957, 8759, 937, 339, 1166, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 10625, 531, 272, 1177, 275, 1890, 14, 362, 8, 633, 12, 3101, 63, 29495, 5372, 5994, 63, 12058, 540, 63, 30263, 63, 2339, 628, 31935, 285, 15922, 531, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 272, 334, 1099, 4258, 275, 491, 460, 316, 3276, 30188, 14, 1462, 14, 452, 342, 272, 702, 754, 14, 8759, 508, 9854, 272, 702, 440, 754, 14, 2123, 272, 702, 440, 754, 14, 1310, 272, 702, 754, 14, 6721, 63, 11697, 508, 298, 31935, 285, 15922, 2, 339, 327, 7356, 5554, 652, 543, 376, 3031, 272, 1177, 275, 1890, 14, 1932, 8, 267, 1166, 12, 267, 2420, 2580, 582, 620, 8, 1099, 14, 2580, 395, 298, 2123, 582, 298, 4837, 351, 1235, 32, 2694, 14, 957, 221, 298, 1386, 272, 776, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 272, 334, 1099, 4258, 275, 491, 460, 316, 3276, 30188, 14, 1462, 14, 452, 342, 272, 702, 754, 14, 8759, 508, 9854, 272, 702, 754, 14, 2123, 508, 298, 321, 351, 1235, 32, 2694, 14, 957, 2, 272, 702, 440, 754, 14, 1310, 339, 327, 7356, 5554, 652, 543, 282, 1177, 272, 1177, 275, 1890, 14, 1932, 8, 267, 1166, 12, 267, 469, 288, 298, 2580, 582, 620, 8, 1099, 14, 2580, 395, 288, 298, 1310, 582, 2022, 14, 4180, 6333, 4777, 582, 298, 9452, 449, 5593, 267, 1660, 272, 776, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 272, 334, 1099, 4258, 275, 491, 460, 316, 3276, 30188, 14, 1462, 14, 452, 342, 272, 702, 754, 14, 8759, 508, 9854, 272, 702, 754, 14, 2123, 508, 298, 321, 351, 1235, 32, 2694, 14, 957, 2, 272, 702, 754, 14, 1310, 508, 2022, 14, 4180, 6333, 4777, 582, 298, 9452, 449, 5984, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 4073, 63, 9688, 316, 63, 1606, 63, 10625, 63, 4087, 63, 1069, 8, 1258, 304, 272, 1166, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 10625, 531, 339, 327, 3091, 5805, 8759, 29, 1396, 272, 1177, 275, 1890, 14, 362, 8, 633, 9, 272, 702, 1177, 14, 1205, 63, 600, 508, 8290, 339, 327, 961, 5951, 314, 4346, 2351, 5494, 272, 9854, 63, 633, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 8759, 531, 272, 1177, 275, 1890, 14, 362, 8, 8759, 63, 633, 9, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 339, 327, 2832, 282, 1686, 11134, 272, 1177, 275, 1890, 14, 362, 8, 633, 12, 2420, 2580, 582, 298, 10013, 5984, 272, 702, 1177, 14, 1205, 63, 600, 508, 8290, 339, 327, 2832, 282, 18054, 11134, 272, 1177, 275, 1890, 14, 362, 8, 633, 12, 2420, 2580, 582, 298, 1299, 70, 23, 65, 29114, 13, 12383, 65, 13, 20, 8557, 13, 1020, 4361, 13, 68, 2789, 667, 1272, 983, 1194, 65, 5984, 272, 702, 1177, 14, 1205, 63, 600, 508, 7901, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 4073, 63, 9688, 316, 63, 1606, 63, 10625, 63, 15712, 63, 2580, 8, 1258, 304, 272, 327, 961, 5951, 314, 4346, 2351, 5494, 272, 9854, 63, 633, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 8759, 531, 272, 1177, 275, 1890, 14, 362, 8, 8759, 63, 633, 9, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 339, 1166, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 10625, 531, 272, 1177, 17, 275, 1890, 14, 362, 8, 633, 12, 3101, 63, 29495, 5372, 5994, 63, 12058, 540, 63, 30263, 63, 2339, 628, 51, 1129, 848, 531, 272, 702, 1177, 17, 14, 1205, 63, 600, 508, 1926, 272, 702, 491, 460, 316, 3276, 30188, 14, 1462, 14, 452, 1252, 835, 342, 508, 413, 272, 1177, 18, 275, 1890, 14, 362, 8, 267, 1166, 12, 267, 2420, 2580, 582, 1177, 17, 14, 1001, 22957, 2580, 19057, 267, 3101, 63, 29495, 5372, 5994, 63, 12058, 540, 63, 30263, 63, 2339, 628, 1668, 33, 401, 272, 776, 272, 702, 1177, 18, 14, 1001, 22957, 2580, 937, 508, 1177, 17, 14, 1001, 22957, 2580, 937, 272, 702, 491, 460, 316, 3276, 30188, 14, 1462, 14, 452, 1252, 835, 342, 508, 413, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 4073, 63, 9688, 316, 63, 1606, 63, 10625, 63, 12177, 8, 751, 63, 1258, 12, 17195, 63, 751, 304, 272, 327, 961, 5951, 314, 4346, 2351, 5494, 272, 9854, 63, 633, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 8759, 531, 272, 1177, 275, 922, 63, 1258, 14, 362, 8, 8759, 63, 633, 9, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 339, 1166, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 10625, 531, 272, 1177, 275, 922, 63, 1258, 14, 362, 8, 633, 9, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 272, 334, 1099, 4258, 275, 491, 460, 316, 3276, 30188, 14, 1462, 14, 452, 342, 272, 702, 754, 14, 751, 508, 17195, 63, 751, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 9688, 316, 63, 1606, 63, 8759 ]
[ 2022, 199, 199, 646, 4613, 199, 199, 504, 1022, 85, 391, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1022, 85, 391, 14, 6666, 14, 992, 492, 491, 460, 316, 3276, 30188, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 4073, 63, 9688, 316, 63, 1606, 63, 10625, 63, 72, 18869, 63, 515, 8, 1258, 12, 2202, 304, 272, 327, 961, 5951, 314, 4346, 2351, 5494, 272, 9854, 63, 633, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 8759, 531, 272, 1177, 275, 1890, 14, 362, 8, 8759, 63, 633, 9, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 272, 9854, 275, 1177, 14, 1001, 22957, 8759, 937, 339, 1166, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 10625, 531, 272, 1177, 275, 1890, 14, 362, 8, 633, 12, 3101, 63, 29495, 5372, 5994, 63, 12058, 540, 63, 30263, 63, 2339, 628, 31935, 285, 15922, 531, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 272, 334, 1099, 4258, 275, 491, 460, 316, 3276, 30188, 14, 1462, 14, 452, 342, 272, 702, 754, 14, 8759, 508, 9854, 272, 702, 440, 754, 14, 2123, 272, 702, 440, 754, 14, 1310, 272, 702, 754, 14, 6721, 63, 11697, 508, 298, 31935, 285, 15922, 2, 339, 327, 7356, 5554, 652, 543, 376, 3031, 272, 1177, 275, 1890, 14, 1932, 8, 267, 1166, 12, 267, 2420, 2580, 582, 620, 8, 1099, 14, 2580, 395, 298, 2123, 582, 298, 4837, 351, 1235, 32, 2694, 14, 957, 221, 298, 1386, 272, 776, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 272, 334, 1099, 4258, 275, 491, 460, 316, 3276, 30188, 14, 1462, 14, 452, 342, 272, 702, 754, 14, 8759, 508, 9854, 272, 702, 754, 14, 2123, 508, 298, 321, 351, 1235, 32, 2694, 14, 957, 2, 272, 702, 440, 754, 14, 1310, 339, 327, 7356, 5554, 652, 543, 282, 1177, 272, 1177, 275, 1890, 14, 1932, 8, 267, 1166, 12, 267, 469, 288, 298, 2580, 582, 620, 8, 1099, 14, 2580, 395, 288, 298, 1310, 582, 2022, 14, 4180, 6333, 4777, 582, 298, 9452, 449, 5593, 267, 1660, 272, 776, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 272, 334, 1099, 4258, 275, 491, 460, 316, 3276, 30188, 14, 1462, 14, 452, 342, 272, 702, 754, 14, 8759, 508, 9854, 272, 702, 754, 14, 2123, 508, 298, 321, 351, 1235, 32, 2694, 14, 957, 2, 272, 702, 754, 14, 1310, 508, 2022, 14, 4180, 6333, 4777, 582, 298, 9452, 449, 5984, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 4073, 63, 9688, 316, 63, 1606, 63, 10625, 63, 4087, 63, 1069, 8, 1258, 304, 272, 1166, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 10625, 531, 339, 327, 3091, 5805, 8759, 29, 1396, 272, 1177, 275, 1890, 14, 362, 8, 633, 9, 272, 702, 1177, 14, 1205, 63, 600, 508, 8290, 339, 327, 961, 5951, 314, 4346, 2351, 5494, 272, 9854, 63, 633, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 8759, 531, 272, 1177, 275, 1890, 14, 362, 8, 8759, 63, 633, 9, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 339, 327, 2832, 282, 1686, 11134, 272, 1177, 275, 1890, 14, 362, 8, 633, 12, 2420, 2580, 582, 298, 10013, 5984, 272, 702, 1177, 14, 1205, 63, 600, 508, 8290, 339, 327, 2832, 282, 18054, 11134, 272, 1177, 275, 1890, 14, 362, 8, 633, 12, 2420, 2580, 582, 298, 1299, 70, 23, 65, 29114, 13, 12383, 65, 13, 20, 8557, 13, 1020, 4361, 13, 68, 2789, 667, 1272, 983, 1194, 65, 5984, 272, 702, 1177, 14, 1205, 63, 600, 508, 7901, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 4073, 63, 9688, 316, 63, 1606, 63, 10625, 63, 15712, 63, 2580, 8, 1258, 304, 272, 327, 961, 5951, 314, 4346, 2351, 5494, 272, 9854, 63, 633, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 8759, 531, 272, 1177, 275, 1890, 14, 362, 8, 8759, 63, 633, 9, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 339, 1166, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 10625, 531, 272, 1177, 17, 275, 1890, 14, 362, 8, 633, 12, 3101, 63, 29495, 5372, 5994, 63, 12058, 540, 63, 30263, 63, 2339, 628, 51, 1129, 848, 531, 272, 702, 1177, 17, 14, 1205, 63, 600, 508, 1926, 272, 702, 491, 460, 316, 3276, 30188, 14, 1462, 14, 452, 1252, 835, 342, 508, 413, 272, 1177, 18, 275, 1890, 14, 362, 8, 267, 1166, 12, 267, 2420, 2580, 582, 1177, 17, 14, 1001, 22957, 2580, 19057, 267, 3101, 63, 29495, 5372, 5994, 63, 12058, 540, 63, 30263, 63, 2339, 628, 1668, 33, 401, 272, 776, 272, 702, 1177, 18, 14, 1001, 22957, 2580, 937, 508, 1177, 17, 14, 1001, 22957, 2580, 937, 272, 702, 491, 460, 316, 3276, 30188, 14, 1462, 14, 452, 1252, 835, 342, 508, 413, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 4073, 63, 9688, 316, 63, 1606, 63, 10625, 63, 12177, 8, 751, 63, 1258, 12, 17195, 63, 751, 304, 272, 327, 961, 5951, 314, 4346, 2351, 5494, 272, 9854, 63, 633, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 8759, 531, 272, 1177, 275, 922, 63, 1258, 14, 362, 8, 8759, 63, 633, 9, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 339, 1166, 275, 3837, 480, 1246, 14, 86, 17, 14, 6666, 14, 9688, 316, 63, 1606, 63, 10625, 531, 272, 1177, 275, 922, 63, 1258, 14, 362, 8, 633, 9, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 272, 334, 1099, 4258, 275, 491, 460, 316, 3276, 30188, 14, 1462, 14, 452, 342, 272, 702, 754, 14, 751, 508, 17195, 63, 751, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 9688, 316, 63, 1606, 63, 8759, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # # Xcode supports build variable substitutions and CPP; sadly, that doesn't work # because: # # 1. Xcode wants to do the Info.plist work before it runs any build phases, # this means if we were to generate a .h file for INFOPLIST_PREFIX_HEADER # we'd have to put it in another target so it runs in time. # 2. Xcode also doesn't check to see if the header being used as a prefix for # the Info.plist has changed. So even if we updated it, it's only looking # at the modtime of the info.plist to see if that's changed. # # So, we work around all of this by making a script build phase that will run # during the app build, and simply update the info.plist in place. This way # by the time the app target is done, the info.plist is correct. # import optparse import os from os import environ as env import plistlib import re import subprocess import sys import tempfile TOP = os.path.join(env['SRCROOT'], '..') sys.path.insert(0, os.path.join(TOP, "build/util")) import lastchange def _GetOutput(args): """Runs a subprocess and waits for termination. Returns (stdout, returncode) of the process. stderr is attached to the parent.""" proc = subprocess.Popen(args, stdout=subprocess.PIPE) (stdout, stderr) = proc.communicate() return (stdout, proc.returncode) def _GetOutputNoError(args): """Similar to _GetOutput() but ignores stderr. If there's an error launching the child (like file not found), the exception will be caught and (None, 1) will be returned to mimic quiet failure.""" try: proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) except OSError: return (None, 1) (stdout, stderr) = proc.communicate() return (stdout, proc.returncode) def _RemoveKeys(plist, *keys): """Removes a varargs of keys from the plist.""" for key in keys: try: del plist[key] except KeyError: pass def _AddVersionKeys(plist): """Adds the product version number into the plist. Returns True on success and False on error. The error will be printed to stderr.""" # Pull in the Chrome version number. VERSION_TOOL = os.path.join(TOP, 'chrome/tools/build/version.py') VERSION_FILE = os.path.join(TOP, 'chrome/VERSION') (stdout, retval1) = _GetOutput([VERSION_TOOL, '-f', VERSION_FILE, '-t', '@MAJOR@.@MINOR@.@BUILD@.@PATCH@']) full_version = stdout.rstrip() (stdout, retval2) = _GetOutput([VERSION_TOOL, '-f', VERSION_FILE, '-t', '@BUILD@.@PATCH@']) bundle_version = stdout.rstrip() # If either of the two version commands finished with non-zero returncode, # report the error up. if retval1 or retval2: return False # Add public version info so "Get Info" works. plist['CFBundleShortVersionString'] = full_version # Honor the 429496.72.95 limit. The maximum comes from splitting 2^32 - 1 # into 6, 2, 2 digits. The limitation was present in Tiger, but it could # have been fixed in later OS release, but hasn't been tested (it's easy # enough to find out with "lsregister -dump). # http://lists.apple.com/archives/carbon-dev/2006/Jun/msg00139.html # BUILD will always be an increasing value, so BUILD_PATH gives us something # unique that meetings what LS wants. plist['CFBundleVersion'] = bundle_version # Return with no error. return True def _DoSVNKeys(plist, add_keys): """Adds the SVN information, visible in about:version, to property list. If |add_keys| is True, it will insert the keys, otherwise it will remove them.""" scm_path, scm_revision = None, None if add_keys: version_info = lastchange.FetchVersionInfo( default_lastchange=None, directory=TOP) scm_path, scm_revision = version_info.url, version_info.revision # See if the operation failed. _RemoveKeys(plist, 'SVNRevision') if scm_revision != None: plist['SVNRevision'] = scm_revision elif add_keys: print >>sys.stderr, 'Could not determine svn revision. This may be OK.' if scm_path != None: plist['SVNPath'] = scm_path else: _RemoveKeys(plist, 'SVNPath') def _DoPDFKeys(plist, add_keys): """Adds PDF support to the document types list. If add_keys is True, it will add the type information dictionary. If it is False, it will remove it if present.""" PDF_FILE_EXTENSION = 'pdf' def __AddPDFKeys(sub_plist): """Writes the keys into a sub-dictionary of the plist.""" sub_plist['CFBundleTypeExtensions'] = [PDF_FILE_EXTENSION] sub_plist['CFBundleTypeIconFile'] = 'document.icns' sub_plist['CFBundleTypeMIMETypes'] = 'application/pdf' sub_plist['CFBundleTypeName'] = 'PDF Document' sub_plist['CFBundleTypeRole'] = 'Viewer' DOCUMENT_TYPES_KEY = 'CFBundleDocumentTypes' # First get the list of document types, creating it if necessary. try: extensions = plist[DOCUMENT_TYPES_KEY] except KeyError: # If this plist doesn't have a type dictionary, create one if set to add the # keys. If not, bail. if not add_keys: return extensions = plist[DOCUMENT_TYPES_KEY] = [] # Loop over each entry in the list, looking for one that handles PDF types. for i, ext in enumerate(extensions): # If an entry for .pdf files is found... if 'CFBundleTypeExtensions' not in ext: continue if PDF_FILE_EXTENSION in ext['CFBundleTypeExtensions']: if add_keys: # Overwrite the existing keys with new ones. __AddPDFKeys(ext) else: # Otherwise, delete the entry entirely. del extensions[i] return # No PDF entry exists. If one needs to be added, do so now. if add_keys: pdf_entry = {} __AddPDFKeys(pdf_entry) extensions.append(pdf_entry) def _AddBreakpadKeys(plist, branding): """Adds the Breakpad keys. This must be called AFTER _AddVersionKeys() and also requires the |branding| argument.""" plist['BreakpadReportInterval'] = '3600' # Deliberately a string. plist['BreakpadProduct'] = '%s_Mac' % branding plist['BreakpadProductDisplay'] = branding plist['BreakpadVersion'] = plist['CFBundleShortVersionString'] # These are both deliberately strings and not boolean. plist['BreakpadSendAndExit'] = 'YES' plist['BreakpadSkipConfirm'] = 'YES' def _RemoveBreakpadKeys(plist): """Removes any set Breakpad keys.""" _RemoveKeys(plist, 'BreakpadURL', 'BreakpadReportInterval', 'BreakpadProduct', 'BreakpadProductDisplay', 'BreakpadVersion', 'BreakpadSendAndExit', 'BreakpadSkipConfirm') def _AddKeystoneKeys(plist, bundle_identifier): """Adds the Keystone keys. This must be called AFTER _AddVersionKeys() and also requires the |bundle_identifier| argument (com.example.product).""" plist['KSVersion'] = plist['CFBundleShortVersionString'] plist['KSProductID'] = bundle_identifier plist['KSUpdateURL'] = 'https://tools.google.com/service/update2' def _RemoveKeystoneKeys(plist): """Removes any set Keystone keys.""" _RemoveKeys(plist, 'KSVersion', 'KSProductID', 'KSUpdateURL') def Main(argv): parser = optparse.OptionParser('%prog [options]') parser.add_option('--breakpad', dest='use_breakpad', action='store', type='int', default=False, help='Enable Breakpad [1 or 0]') parser.add_option('--breakpad_uploads', dest='breakpad_uploads', action='store', type='int', default=False, help='Enable Breakpad\'s uploading of crash dumps [1 or 0]') parser.add_option('--keystone', dest='use_keystone', action='store', type='int', default=False, help='Enable Keystone [1 or 0]') parser.add_option('--svn', dest='add_svn_info', action='store', type='int', default=True, help='Add SVN metadata [1 or 0]') parser.add_option('--pdf', dest='add_pdf_support', action='store', type='int', default=False, help='Add PDF file handler support [1 or 0]') parser.add_option('--branding', dest='branding', action='store', type='string', default=None, help='The branding of the binary') parser.add_option('--bundle_id', dest='bundle_identifier', action='store', type='string', default=None, help='The bundle id of the binary') (options, args) = parser.parse_args(argv) if len(args) > 0: print >>sys.stderr, parser.get_usage() return 1 # Read the plist into its parsed format. DEST_INFO_PLIST = os.path.join(env['TARGET_BUILD_DIR'], env['INFOPLIST_PATH']) plist = plistlib.readPlist(DEST_INFO_PLIST) # Insert the product version. if not _AddVersionKeys(plist): return 2 # Add Breakpad if configured to do so. if options.use_breakpad: if options.branding is None: print >>sys.stderr, 'Use of Breakpad requires branding.' return 1 _AddBreakpadKeys(plist, options.branding) if options.breakpad_uploads: plist['BreakpadURL'] = 'https://clients2.google.com/cr/report' else: # This allows crash dumping to a file without uploading the # dump, for testing purposes. Breakpad does not recognise # "none" as a special value, but this does stop crash dump # uploading from happening. We need to specify something # because if "BreakpadURL" is not present, Breakpad will not # register its crash handler and no crash dumping will occur. plist['BreakpadURL'] = 'none' else: _RemoveBreakpadKeys(plist) # Only add Keystone in Release builds. if options.use_keystone and env['CONFIGURATION'] == 'Release': if options.bundle_identifier is None: print >>sys.stderr, 'Use of Keystone requires the bundle id.' return 1 _AddKeystoneKeys(plist, options.bundle_identifier) else: _RemoveKeystoneKeys(plist) # Adds or removes any SVN keys. _DoSVNKeys(plist, options.add_svn_info) # Adds or removes the PDF file handler entry. _DoPDFKeys(plist, options.add_pdf_support) # Now that all keys have been mutated, rewrite the file. temp_info_plist = tempfile.NamedTemporaryFile() plistlib.writePlist(plist, temp_info_plist.name) # Info.plist will work perfectly well in any plist format, but traditionally # applications use xml1 for this, so convert it to ensure that it's valid. proc = subprocess.Popen(['plutil', '-convert', 'xml1', '-o', DEST_INFO_PLIST, temp_info_plist.name]) proc.wait() return proc.returncode if __name__ == '__main__': sys.exit(Main(sys.argv[1:]))
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 3, 199, 3, 10602, 5171, 1900, 1750, 20873, 436, 28635, 27, 308, 350, 590, 12, 626, 3181, 1133, 1736, 199, 3, 2952, 26, 199, 3, 199, 3, 413, 14, 10602, 15061, 370, 886, 314, 10332, 14, 10265, 1736, 2544, 652, 7858, 1263, 1900, 22587, 12, 199, 3, 259, 642, 4910, 340, 781, 4898, 370, 3550, 282, 1275, 72, 570, 367, 24347, 1938, 4924, 63, 6351, 63, 7311, 199, 3, 259, 781, 5121, 1172, 370, 5324, 652, 315, 4573, 1347, 880, 652, 7858, 315, 900, 14, 199, 3, 499, 14, 10602, 2597, 3181, 1133, 1104, 370, 1937, 340, 314, 1406, 3769, 1202, 465, 282, 2403, 367, 199, 3, 259, 314, 10332, 14, 10265, 965, 2896, 14, 221, 2002, 2755, 340, 781, 4588, 652, 12, 652, 1159, 1454, 10023, 199, 3, 259, 737, 314, 3413, 521, 402, 314, 2256, 14, 10265, 370, 1937, 340, 626, 1159, 2896, 14, 199, 3, 199, 3, 2002, 12, 781, 1736, 6818, 1006, 402, 642, 701, 10663, 282, 2884, 1900, 7669, 626, 911, 1255, 199, 3, 5309, 314, 1145, 1900, 12, 436, 9329, 1678, 314, 2256, 14, 10265, 315, 4192, 14, 221, 961, 4340, 199, 3, 701, 314, 900, 314, 1145, 1347, 365, 4224, 12, 314, 2256, 14, 10265, 365, 3211, 14, 199, 3, 199, 199, 646, 8691, 199, 646, 747, 199, 504, 747, 492, 6160, 465, 2589, 199, 646, 14459, 773, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 199, 199, 11422, 275, 747, 14, 515, 14, 904, 8, 1813, 459, 12447, 5441, 995, 11541, 358, 199, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 904, 8, 11422, 12, 298, 1506, 15, 1974, 2237, 199, 646, 2061, 1461, 421, 199, 318, 485, 18614, 8, 589, 304, 523, 408, 16291, 282, 3873, 436, 14442, 1405, 367, 23868, 14, 1803, 334, 2703, 12, 17630, 9, 523, 402, 314, 2112, 14, 4635, 365, 10102, 370, 314, 1676, 1041, 523, 6499, 275, 3873, 14, 7942, 8, 589, 12, 3839, 29, 5781, 14, 6089, 9, 523, 334, 2703, 12, 4635, 9, 275, 6499, 14, 10664, 342, 523, 372, 334, 2703, 12, 6499, 14, 9913, 9, 421, 199, 318, 485, 18614, 1944, 547, 8, 589, 304, 523, 408, 7467, 6734, 370, 485, 18614, 342, 1325, 24010, 4635, 14, 982, 2337, 1159, 376, 1125, 10623, 316, 523, 314, 1982, 334, 2930, 570, 440, 1911, 395, 314, 1919, 911, 506, 15604, 436, 334, 403, 12, 413, 9, 523, 911, 506, 2138, 370, 24102, 530, 11971, 5988, 1041, 523, 862, 26, 272, 6499, 275, 3873, 14, 7942, 8, 589, 12, 3839, 29, 5781, 14, 6089, 12, 1169, 4635, 29, 5781, 14, 6089, 9, 523, 871, 6440, 26, 272, 372, 334, 403, 12, 413, 9, 523, 334, 2703, 12, 4635, 9, 275, 6499, 14, 10664, 342, 523, 372, 334, 2703, 12, 6499, 14, 9913, 9, 421, 199, 318, 485, 5587, 6340, 8, 10265, 12, 627, 1612, 304, 523, 408, 22948, 282, 23377, 402, 2883, 687, 314, 14459, 1041, 523, 367, 790, 315, 2883, 26, 272, 862, 26, 489, 2150, 14459, 59, 498, 61, 272, 871, 4067, 26, 489, 986, 421, 199, 318, 485, 1123, 3353, 6340, 8, 10265, 304, 523, 408, 14995, 314, 3336, 1015, 1329, 1901, 314, 14459, 14, 1803, 715, 641, 3182, 436, 523, 756, 641, 1125, 14, 710, 1125, 911, 506, 12487, 370, 4635, 1041, 523, 327, 27705, 315, 314, 16776, 1015, 1329, 14, 523, 15945, 63, 9731, 275, 747, 14, 515, 14, 904, 8, 11422, 12, 283, 9887, 15, 2537, 15, 1506, 15, 1023, 14, 647, 358, 523, 15945, 63, 3817, 275, 747, 14, 515, 14, 904, 8, 11422, 12, 283, 9887, 15, 4612, 358, 819, 334, 2703, 12, 9151, 17, 9, 275, 485, 18614, 779, 4612, 63, 9731, 12, 2475, 70, 297, 15945, 63, 3817, 12, 2475, 84, 297, 3303, 10267, 29241, 32, 14, 32, 4896, 726, 32, 14, 32, 8248, 32, 14, 32, 17073, 32, 1105, 523, 2615, 63, 1023, 275, 3839, 14, 6735, 342, 819, 334, 2703, 12, 9151, 18, 9, 275, 485, 18614, 779, 4612, 63, 9731, 12, 2475, 70, 297, 15945, 63, 3817, 12, 2475, 84, 297, 3303, 10267, 8248, 32, 14, 32, 17073, 32, 1105, 523, 8844, 63, 1023, 275, 3839, 14, 6735, 342, 819, 327, 982, 1902, 402, 314, 2877, 1015, 3718, 9158, 543, 2222, 13, 4262, 17630, 12, 523, 327, 3622, 314, 1125, 1536, 14, 523, 340, 9151, 17, 503, 9151, 18, 26, 272, 372, 756, 819, 327, 2654, 4575, 1015, 2256, 880, 298, 1002, 10332, 2, 5419, 14, 523, 14459, 459, 5487, 12320, 10039, 3353, 1558, 418, 275, 2615, 63, 1023, 819, 327, 869, 15034, 314, 17640, 18105, 14, 2819, 14, 2720, 2304, 14, 221, 710, 5696, 12477, 687, 26518, 499, 62, 708, 446, 413, 523, 327, 1901, 221, 1227, 12, 499, 12, 499, 7576, 14, 221, 710, 12305, 1990, 3451, 315, 377, 528, 281, 12, 1325, 652, 4293, 523, 327, 1172, 2757, 6317, 315, 2945, 4403, 4683, 12, 1325, 18699, 1133, 2757, 12470, 334, 390, 1159, 8837, 523, 327, 8321, 370, 2342, 734, 543, 298, 478, 2683, 446, 2724, 680, 523, 327, 1455, 921, 6717, 14, 12820, 14, 957, 15, 28067, 15, 7007, 13520, 13, 2374, 15, 7968, 15, 42, 324, 15, 1328, 383, 7491, 14, 1360, 523, 327, 22974, 911, 3544, 506, 376, 22255, 574, 12, 880, 22974, 63, 3243, 10557, 2739, 6020, 523, 327, 3747, 626, 26743, 780, 4052, 491, 51, 15061, 14, 523, 14459, 459, 5487, 12320, 3353, 418, 275, 8844, 63, 1023, 819, 327, 1432, 543, 949, 1125, 14, 523, 372, 715, 421, 199, 318, 485, 2585, 31222, 6340, 8, 10265, 12, 1050, 63, 1612, 304, 523, 408, 14995, 314, 24639, 2556, 12, 8917, 315, 3595, 26, 1023, 12, 370, 3324, 769, 14, 982, 523, 1204, 525, 63, 1612, 92, 365, 715, 12, 652, 911, 5518, 314, 2883, 12, 4257, 652, 911, 2813, 3062, 1041, 523, 25811, 63, 515, 12, 25811, 63 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 3, 199, 3, 10602, 5171, 1900, 1750, 20873, 436, 28635, 27, 308, 350, 590, 12, 626, 3181, 1133, 1736, 199, 3, 2952, 26, 199, 3, 199, 3, 413, 14, 10602, 15061, 370, 886, 314, 10332, 14, 10265, 1736, 2544, 652, 7858, 1263, 1900, 22587, 12, 199, 3, 259, 642, 4910, 340, 781, 4898, 370, 3550, 282, 1275, 72, 570, 367, 24347, 1938, 4924, 63, 6351, 63, 7311, 199, 3, 259, 781, 5121, 1172, 370, 5324, 652, 315, 4573, 1347, 880, 652, 7858, 315, 900, 14, 199, 3, 499, 14, 10602, 2597, 3181, 1133, 1104, 370, 1937, 340, 314, 1406, 3769, 1202, 465, 282, 2403, 367, 199, 3, 259, 314, 10332, 14, 10265, 965, 2896, 14, 221, 2002, 2755, 340, 781, 4588, 652, 12, 652, 1159, 1454, 10023, 199, 3, 259, 737, 314, 3413, 521, 402, 314, 2256, 14, 10265, 370, 1937, 340, 626, 1159, 2896, 14, 199, 3, 199, 3, 2002, 12, 781, 1736, 6818, 1006, 402, 642, 701, 10663, 282, 2884, 1900, 7669, 626, 911, 1255, 199, 3, 5309, 314, 1145, 1900, 12, 436, 9329, 1678, 314, 2256, 14, 10265, 315, 4192, 14, 221, 961, 4340, 199, 3, 701, 314, 900, 314, 1145, 1347, 365, 4224, 12, 314, 2256, 14, 10265, 365, 3211, 14, 199, 3, 199, 199, 646, 8691, 199, 646, 747, 199, 504, 747, 492, 6160, 465, 2589, 199, 646, 14459, 773, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 199, 199, 11422, 275, 747, 14, 515, 14, 904, 8, 1813, 459, 12447, 5441, 995, 11541, 358, 199, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 904, 8, 11422, 12, 298, 1506, 15, 1974, 2237, 199, 646, 2061, 1461, 421, 199, 318, 485, 18614, 8, 589, 304, 523, 408, 16291, 282, 3873, 436, 14442, 1405, 367, 23868, 14, 1803, 334, 2703, 12, 17630, 9, 523, 402, 314, 2112, 14, 4635, 365, 10102, 370, 314, 1676, 1041, 523, 6499, 275, 3873, 14, 7942, 8, 589, 12, 3839, 29, 5781, 14, 6089, 9, 523, 334, 2703, 12, 4635, 9, 275, 6499, 14, 10664, 342, 523, 372, 334, 2703, 12, 6499, 14, 9913, 9, 421, 199, 318, 485, 18614, 1944, 547, 8, 589, 304, 523, 408, 7467, 6734, 370, 485, 18614, 342, 1325, 24010, 4635, 14, 982, 2337, 1159, 376, 1125, 10623, 316, 523, 314, 1982, 334, 2930, 570, 440, 1911, 395, 314, 1919, 911, 506, 15604, 436, 334, 403, 12, 413, 9, 523, 911, 506, 2138, 370, 24102, 530, 11971, 5988, 1041, 523, 862, 26, 272, 6499, 275, 3873, 14, 7942, 8, 589, 12, 3839, 29, 5781, 14, 6089, 12, 1169, 4635, 29, 5781, 14, 6089, 9, 523, 871, 6440, 26, 272, 372, 334, 403, 12, 413, 9, 523, 334, 2703, 12, 4635, 9, 275, 6499, 14, 10664, 342, 523, 372, 334, 2703, 12, 6499, 14, 9913, 9, 421, 199, 318, 485, 5587, 6340, 8, 10265, 12, 627, 1612, 304, 523, 408, 22948, 282, 23377, 402, 2883, 687, 314, 14459, 1041, 523, 367, 790, 315, 2883, 26, 272, 862, 26, 489, 2150, 14459, 59, 498, 61, 272, 871, 4067, 26, 489, 986, 421, 199, 318, 485, 1123, 3353, 6340, 8, 10265, 304, 523, 408, 14995, 314, 3336, 1015, 1329, 1901, 314, 14459, 14, 1803, 715, 641, 3182, 436, 523, 756, 641, 1125, 14, 710, 1125, 911, 506, 12487, 370, 4635, 1041, 523, 327, 27705, 315, 314, 16776, 1015, 1329, 14, 523, 15945, 63, 9731, 275, 747, 14, 515, 14, 904, 8, 11422, 12, 283, 9887, 15, 2537, 15, 1506, 15, 1023, 14, 647, 358, 523, 15945, 63, 3817, 275, 747, 14, 515, 14, 904, 8, 11422, 12, 283, 9887, 15, 4612, 358, 819, 334, 2703, 12, 9151, 17, 9, 275, 485, 18614, 779, 4612, 63, 9731, 12, 2475, 70, 297, 15945, 63, 3817, 12, 2475, 84, 297, 3303, 10267, 29241, 32, 14, 32, 4896, 726, 32, 14, 32, 8248, 32, 14, 32, 17073, 32, 1105, 523, 2615, 63, 1023, 275, 3839, 14, 6735, 342, 819, 334, 2703, 12, 9151, 18, 9, 275, 485, 18614, 779, 4612, 63, 9731, 12, 2475, 70, 297, 15945, 63, 3817, 12, 2475, 84, 297, 3303, 10267, 8248, 32, 14, 32, 17073, 32, 1105, 523, 8844, 63, 1023, 275, 3839, 14, 6735, 342, 819, 327, 982, 1902, 402, 314, 2877, 1015, 3718, 9158, 543, 2222, 13, 4262, 17630, 12, 523, 327, 3622, 314, 1125, 1536, 14, 523, 340, 9151, 17, 503, 9151, 18, 26, 272, 372, 756, 819, 327, 2654, 4575, 1015, 2256, 880, 298, 1002, 10332, 2, 5419, 14, 523, 14459, 459, 5487, 12320, 10039, 3353, 1558, 418, 275, 2615, 63, 1023, 819, 327, 869, 15034, 314, 17640, 18105, 14, 2819, 14, 2720, 2304, 14, 221, 710, 5696, 12477, 687, 26518, 499, 62, 708, 446, 413, 523, 327, 1901, 221, 1227, 12, 499, 12, 499, 7576, 14, 221, 710, 12305, 1990, 3451, 315, 377, 528, 281, 12, 1325, 652, 4293, 523, 327, 1172, 2757, 6317, 315, 2945, 4403, 4683, 12, 1325, 18699, 1133, 2757, 12470, 334, 390, 1159, 8837, 523, 327, 8321, 370, 2342, 734, 543, 298, 478, 2683, 446, 2724, 680, 523, 327, 1455, 921, 6717, 14, 12820, 14, 957, 15, 28067, 15, 7007, 13520, 13, 2374, 15, 7968, 15, 42, 324, 15, 1328, 383, 7491, 14, 1360, 523, 327, 22974, 911, 3544, 506, 376, 22255, 574, 12, 880, 22974, 63, 3243, 10557, 2739, 6020, 523, 327, 3747, 626, 26743, 780, 4052, 491, 51, 15061, 14, 523, 14459, 459, 5487, 12320, 3353, 418, 275, 8844, 63, 1023, 819, 327, 1432, 543, 949, 1125, 14, 523, 372, 715, 421, 199, 318, 485, 2585, 31222, 6340, 8, 10265, 12, 1050, 63, 1612, 304, 523, 408, 14995, 314, 24639, 2556, 12, 8917, 315, 3595, 26, 1023, 12, 370, 3324, 769, 14, 982, 523, 1204, 525, 63, 1612, 92, 365, 715, 12, 652, 911, 5518, 314, 2883, 12, 4257, 652, 911, 2813, 3062, 1041, 523, 25811, 63, 515, 12, 25811, 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,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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 ]
jalexvig/tensorflow
tensorflow/python/framework/sparse_tensor.py
12
9826
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Classes and functions used to construct graphs.""" # pylint: disable=g-bad-name from __future__ import absolute_import from __future__ import division from __future__ import print_function import collections from tensorflow.python import pywrap_tensorflow from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_util from tensorflow.python.util.tf_export import tf_export # pylint: disable=protected-access _TensorLike = ops._TensorLike _eval_using_default_session = ops._eval_using_default_session _override_helper = ops._override_helper # pylint: enable=protected-access @tf_export("SparseTensor") class SparseTensor(_TensorLike): """Represents a sparse tensor. TensorFlow represents a sparse tensor as three separate dense tensors: `indices`, `values`, and `dense_shape`. In Python, the three tensors are collected into a `SparseTensor` class for ease of use. If you have separate `indices`, `values`, and `dense_shape` tensors, wrap them in a `SparseTensor` object before passing to the ops below. Concretely, the sparse tensor `SparseTensor(indices, values, dense_shape)` comprises the following components, where `N` and `ndims` are the number of values and number of dimensions in the `SparseTensor`, respectively: * `indices`: A 2-D int64 tensor of dense_shape `[N, ndims]`, which specifies the indices of the elements in the sparse tensor that contain nonzero values (elements are zero-indexed). For example, `indices=[[1,3], [2,4]]` specifies that the elements with indexes of [1,3] and [2,4] have nonzero values. * `values`: A 1-D tensor of any type and dense_shape `[N]`, which supplies the values for each element in `indices`. For example, given `indices=[[1,3], [2,4]]`, the parameter `values=[18, 3.6]` specifies that element [1,3] of the sparse tensor has a value of 18, and element [2,4] of the tensor has a value of 3.6. * `dense_shape`: A 1-D int64 tensor of dense_shape `[ndims]`, which specifies the dense_shape of the sparse tensor. Takes a list indicating the number of elements in each dimension. For example, `dense_shape=[3,6]` specifies a two-dimensional 3x6 tensor, `dense_shape=[2,3,4]` specifies a three-dimensional 2x3x4 tensor, and `dense_shape=[9]` specifies a one-dimensional tensor with 9 elements. The corresponding dense tensor satisfies: ```python dense.shape = dense_shape dense[tuple(indices[i])] = values[i] ``` By convention, `indices` should be sorted in row-major order (or equivalently lexicographic order on the tuples `indices[i]`). This is not enforced when `SparseTensor` objects are constructed, but most ops assume correct ordering. If the ordering of sparse tensor `st` is wrong, a fixed version can be obtained by calling `tf.sparse_reorder(st)`. Example: The sparse tensor ```python SparseTensor(indices=[[0, 0], [1, 2]], values=[1, 2], dense_shape=[3, 4]) ``` represents the dense tensor ```python [[1, 0, 0, 0] [0, 0, 2, 0] [0, 0, 0, 0]] ``` """ @classmethod def from_value(cls, sparse_tensor_value): if not is_sparse(sparse_tensor_value): raise TypeError("Neither a SparseTensor nor SparseTensorValue: %s." % sparse_tensor_value) return SparseTensor( indices=sparse_tensor_value.indices, values=sparse_tensor_value.values, dense_shape=sparse_tensor_value.dense_shape) def __init__(self, indices, values, dense_shape): """Creates a `SparseTensor`. Args: indices: A 2-D int64 tensor of shape `[N, ndims]`. values: A 1-D tensor of any type and shape `[N]`. dense_shape: A 1-D int64 tensor of shape `[ndims]`. Returns: A `SparseTensor`. """ with ops.name_scope(None, "SparseTensor", [indices, values, dense_shape]): indices = ops.convert_to_tensor( indices, name="indices", dtype=dtypes.int64) # Always pass as_ref=True because we want to be able to update # values later if it is a VariableOp. # TODO(touts): Consider adding mutable_values() when 'values' # is a VariableOp and updating users of SparseTensor. values = ops.internal_convert_to_tensor( values, name="values", as_ref=True) dense_shape = ops.convert_to_tensor( dense_shape, name="dense_shape", dtype=dtypes.int64) self._indices = indices self._values = values self._dense_shape = dense_shape indices_shape = indices.get_shape().with_rank(2) values_shape = values.get_shape().with_rank(1) dense_shape_shape = dense_shape.get_shape().with_rank(1) # Assert number of rows in indices match the number of elements in values. indices_shape[0].merge_with(values_shape[0]) # Assert number of columns in indices matches the number of elements in # dense_shape. indices_shape[1].merge_with(dense_shape_shape[0]) def get_shape(self): """Get the `TensorShape` representing the shape of the dense tensor. Returns: A `TensorShape` object. """ return tensor_util.constant_value_as_shape(self._dense_shape) @property def indices(self): """The indices of non-zero values in the represented dense tensor. Returns: A 2-D Tensor of int64 with dense_shape `[N, ndims]`, where `N` is the number of non-zero values in the tensor, and `ndims` is the rank. """ return self._indices @property def values(self): """The non-zero values in the represented dense tensor. Returns: A 1-D Tensor of any data type. """ return self._values @property def op(self): """The `Operation` that produces `values` as an output.""" return self.values.op @property def dtype(self): """The `DType` of elements in this tensor.""" return self._values.dtype @property def dense_shape(self): """A 1-D Tensor of int64 representing the shape of the dense tensor.""" return self._dense_shape @property def graph(self): """The `Graph` that contains the index, value, and dense_shape tensors.""" return self._indices.graph def __str__(self): return "SparseTensor(indices=%s, values=%s, dense_shape=%s)" % ( self._indices, self._values, self._dense_shape) def eval(self, feed_dict=None, session=None): """Evaluates this sparse tensor in a `Session`. Calling this method will execute all preceding operations that produce the inputs needed for the operation that produces this tensor. *N.B.* Before invoking `SparseTensor.eval()`, its graph must have been launched in a session, and either a default session must be available, or `session` must be specified explicitly. Args: feed_dict: A dictionary that maps `Tensor` objects to feed values. See @{tf.Session.run} for a description of the valid feed values. session: (Optional.) The `Session` to be used to evaluate this sparse tensor. If none, the default session will be used. Returns: A `SparseTensorValue` object. """ indices, values, dense_shape = _eval_using_default_session( [self.indices, self.values, self.dense_shape], feed_dict, self.graph, session) return SparseTensorValue(indices, values, dense_shape) @staticmethod def _override_operator(operator, func): _override_helper(SparseTensor, operator, func) SparseTensorValue = collections.namedtuple( "SparseTensorValue", ["indices", "values", "dense_shape"]) tf_export("SparseTensorValue")(SparseTensorValue) pywrap_tensorflow.RegisterSparseTensorValueClass(SparseTensorValue) @tf_export("convert_to_tensor_or_sparse_tensor") def convert_to_tensor_or_sparse_tensor(value, dtype=None, name=None): """Converts value to a `SparseTensor` or `Tensor`. Args: value: A `SparseTensor`, `SparseTensorValue`, or an object whose type has a registered `Tensor` conversion function. dtype: Optional element type for the returned tensor. If missing, the type is inferred from the type of `value`. name: Optional name to use if a new `Tensor` is created. Returns: A `SparseTensor` or `Tensor` based on `value`. Raises: RuntimeError: If result type is incompatible with `dtype`. """ if dtype is not None: dtype = dtypes.as_dtype(dtype) if isinstance(value, SparseTensorValue): value = SparseTensor.from_value(value) if isinstance(value, SparseTensor): if dtype and not dtype.is_compatible_with(value.dtype): raise RuntimeError( "Sparse dtype: requested = %s, actual = %s" % ( dtype.name, value.dtype.name)) return value return ops.internal_convert_to_tensor( value, dtype=dtype, name=name) def is_sparse(x): """Check whether `x` is sparse. Check whether an object is a `tf.SparseTensor` or `tf.SparseTensorValue`. Args: x: A python object to check. Returns: `True` iff `x` is a `tf.SparseTensor` or `tf.SparseTensorValue`. """ return isinstance(x, (SparseTensor, SparseTensorValue))
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 15711, 436, 3423, 1202, 370, 6982, 18312, 1041, 199, 3, 4287, 26, 3507, 29, 71, 13, 4087, 13, 354, 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, 5055, 199, 199, 504, 3228, 14, 1548, 492, 1134, 3823, 63, 16008, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2345, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1974, 14, 3249, 63, 3790, 492, 2833, 63, 3790, 199, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 199, 63, 3861, 12545, 275, 4156, 423, 3861, 12545, 199, 63, 2579, 63, 4941, 63, 885, 63, 1730, 275, 4156, 423, 2579, 63, 4941, 63, 885, 63, 1730, 199, 63, 4415, 63, 3676, 275, 4156, 423, 4415, 63, 3676, 199, 3, 4287, 26, 4756, 29, 6798, 13, 2732, 421, 199, 32, 3249, 63, 3790, 480, 12079, 531, 199, 533, 14531, 3861, 1547, 3861, 12545, 304, 523, 408, 18089, 282, 5178, 2345, 14, 819, 9134, 8469, 282, 5178, 2345, 465, 7795, 7396, 9363, 10519, 26, 523, 658, 4108, 3559, 658, 1459, 3559, 436, 658, 7253, 63, 1392, 2313, 221, 1010, 2018, 12, 314, 7795, 10519, 787, 523, 13736, 1901, 282, 658, 12079, 64, 1021, 367, 325, 482, 402, 675, 14, 221, 982, 1265, 1172, 7396, 523, 658, 4108, 3559, 658, 1459, 3559, 436, 658, 7253, 63, 1392, 64, 10519, 12, 4816, 3062, 315, 282, 658, 12079, 64, 523, 909, 2544, 9476, 370, 314, 4156, 5084, 14, 819, 1448, 7564, 590, 12, 314, 5178, 2345, 658, 12079, 8, 4108, 12, 1338, 12, 9363, 63, 1392, 12544, 523, 1013, 322, 874, 314, 2569, 7323, 12, 2382, 658, 46, 64, 436, 658, 13575, 64, 787, 314, 1329, 523, 402, 1338, 436, 1329, 402, 7365, 315, 314, 658, 12079, 3559, 17342, 26, 819, 627, 658, 4108, 8340, 437, 499, 13, 36, 1109, 772, 2345, 402, 9363, 63, 1392, 14505, 46, 12, 302, 5380, 61, 3559, 1314, 9314, 272, 314, 4918, 402, 314, 4008, 315, 314, 5178, 2345, 626, 1395, 23338, 272, 1338, 334, 5527, 787, 4697, 13, 16821, 680, 2104, 2893, 12, 658, 4108, 16025, 17, 12, 19, 467, 359, 18, 12, 20, 2677, 64, 272, 9314, 626, 314, 4008, 543, 10507, 402, 359, 17, 12, 19, 61, 436, 359, 18, 12, 20, 61, 1172, 272, 23338, 1338, 14, 819, 627, 658, 1459, 8340, 437, 413, 13, 36, 2345, 402, 1263, 730, 436, 9363, 63, 1392, 14505, 46, 61, 3559, 1314, 4973, 6528, 314, 272, 1338, 367, 1924, 1819, 315, 658, 4108, 2313, 2104, 2893, 12, 1627, 272, 658, 4108, 16025, 17, 12, 19, 467, 359, 18, 12, 20, 2677, 3559, 314, 2725, 658, 1459, 1524, 1085, 12, 650, 14, 22, 16090, 9314, 272, 626, 1819, 359, 17, 12, 19, 61, 402, 314, 5178, 2345, 965, 282, 574, 402, 6155, 12, 436, 1819, 272, 359, 18, 12, 20, 61, 402, 314, 2345, 965, 282, 574, 402, 650, 14, 22, 14, 819, 627, 658, 7253, 63, 1392, 8340, 437, 413, 13, 36, 1109, 772, 2345, 402, 9363, 63, 1392, 14505, 13575, 61, 3559, 1314, 9314, 272, 314, 9363, 63, 1392, 402, 314, 5178, 2345, 14, 17415, 282, 769, 9297, 314, 1329, 402, 272, 4008, 315, 1924, 6240, 14, 2104, 2893, 12, 658, 7253, 63, 1392, 1524, 19, 12, 22, 16090, 9314, 282, 272, 2877, 13, 13014, 650, 88, 22, 2345, 12, 658, 7253, 63, 1392, 1524, 18, 12, 19, 12, 20, 16090, 9314, 282, 272, 7795, 13, 13014, 499, 88, 19, 88, 20, 2345, 12, 436, 658, 7253, 63, 1392, 1524, 25, 16090, 9314, 282, 272, 1373, 13, 13014, 2345, 543, 1749, 4008, 14, 819, 710, 5226, 9363, 2345, 13529, 5604, 26, 819, 10841, 1548, 523, 9363, 14, 1392, 275, 9363, 63, 1392, 523, 9363, 59, 2960, 8, 4108, 59, 73, 12457, 275, 1338, 59, 73, 61, 523, 10841, 819, 4885, 16129, 12, 658, 4108, 64, 1077, 506, 3355, 315, 1962, 13, 8452, 1865, 334, 269, 7353, 590, 523, 1026, 30077, 9770, 1865, 641, 314, 6346, 658, 4108, 59, 73, 61, 14963, 961, 365, 440, 30163, 1380, 523, 658, 12079, 64, 2251, 787, 14701, 12, 1325, 4750, 4156, 5534, 3211, 7794, 14, 523, 982, 314, 7794, 402, 5178, 2345, 658, 270, 64, 365, 6835, 12, 282, 6317, 1015, 883, 506, 523, 15884, 701, 6358, 658, 3249, 14, 4421, 63, 29463, 8, 270, 20414, 819, 5679, 26, 710, 5178, 2345, 819, 10841, 1548, 523, 14531, 3861, 8, 4108, 16025, 16, 12, 378, 467, 359, 17, 12, 499, 2365, 1338, 1524, 17, 12, 499, 467, 9363, 63, 1392, 1524, 19, 12, 841, 566, 523, 10841, 819, 8469, 314, 9363, 2345, 819, 10841, 1548, 523, 3474, 17, 12, 378, 12, 378, 12, 378, 61, 2043, 359, 16, 12, 378, 12, 499, 12, 378, 61, 2043, 359, 16, 12, 378, 12, 378, 12, 378, 2677, 523, 10841, 523, 408, 819, 768, 3744, 523, 347, 687, 63, 585, 8, 1886, 12, 5178, 63, 3128, 63, 585, 304, 272, 340, 440, 365, 63, 4421, 8, 4421, 63, 3128, 63, 585, 304, 489, 746, 3146, 480, 4698, 1711, 282, 14531, 3861, 6590, 14531, 3861, 1110, 26, 450, 83, 2122, 450, 1993, 5178, 63, 3128, 63, 585, 9 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 15711, 436, 3423, 1202, 370, 6982, 18312, 1041, 199, 3, 4287, 26, 3507, 29, 71, 13, 4087, 13, 354, 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, 5055, 199, 199, 504, 3228, 14, 1548, 492, 1134, 3823, 63, 16008, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2345, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1974, 14, 3249, 63, 3790, 492, 2833, 63, 3790, 199, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 199, 63, 3861, 12545, 275, 4156, 423, 3861, 12545, 199, 63, 2579, 63, 4941, 63, 885, 63, 1730, 275, 4156, 423, 2579, 63, 4941, 63, 885, 63, 1730, 199, 63, 4415, 63, 3676, 275, 4156, 423, 4415, 63, 3676, 199, 3, 4287, 26, 4756, 29, 6798, 13, 2732, 421, 199, 32, 3249, 63, 3790, 480, 12079, 531, 199, 533, 14531, 3861, 1547, 3861, 12545, 304, 523, 408, 18089, 282, 5178, 2345, 14, 819, 9134, 8469, 282, 5178, 2345, 465, 7795, 7396, 9363, 10519, 26, 523, 658, 4108, 3559, 658, 1459, 3559, 436, 658, 7253, 63, 1392, 2313, 221, 1010, 2018, 12, 314, 7795, 10519, 787, 523, 13736, 1901, 282, 658, 12079, 64, 1021, 367, 325, 482, 402, 675, 14, 221, 982, 1265, 1172, 7396, 523, 658, 4108, 3559, 658, 1459, 3559, 436, 658, 7253, 63, 1392, 64, 10519, 12, 4816, 3062, 315, 282, 658, 12079, 64, 523, 909, 2544, 9476, 370, 314, 4156, 5084, 14, 819, 1448, 7564, 590, 12, 314, 5178, 2345, 658, 12079, 8, 4108, 12, 1338, 12, 9363, 63, 1392, 12544, 523, 1013, 322, 874, 314, 2569, 7323, 12, 2382, 658, 46, 64, 436, 658, 13575, 64, 787, 314, 1329, 523, 402, 1338, 436, 1329, 402, 7365, 315, 314, 658, 12079, 3559, 17342, 26, 819, 627, 658, 4108, 8340, 437, 499, 13, 36, 1109, 772, 2345, 402, 9363, 63, 1392, 14505, 46, 12, 302, 5380, 61, 3559, 1314, 9314, 272, 314, 4918, 402, 314, 4008, 315, 314, 5178, 2345, 626, 1395, 23338, 272, 1338, 334, 5527, 787, 4697, 13, 16821, 680, 2104, 2893, 12, 658, 4108, 16025, 17, 12, 19, 467, 359, 18, 12, 20, 2677, 64, 272, 9314, 626, 314, 4008, 543, 10507, 402, 359, 17, 12, 19, 61, 436, 359, 18, 12, 20, 61, 1172, 272, 23338, 1338, 14, 819, 627, 658, 1459, 8340, 437, 413, 13, 36, 2345, 402, 1263, 730, 436, 9363, 63, 1392, 14505, 46, 61, 3559, 1314, 4973, 6528, 314, 272, 1338, 367, 1924, 1819, 315, 658, 4108, 2313, 2104, 2893, 12, 1627, 272, 658, 4108, 16025, 17, 12, 19, 467, 359, 18, 12, 20, 2677, 3559, 314, 2725, 658, 1459, 1524, 1085, 12, 650, 14, 22, 16090, 9314, 272, 626, 1819, 359, 17, 12, 19, 61, 402, 314, 5178, 2345, 965, 282, 574, 402, 6155, 12, 436, 1819, 272, 359, 18, 12, 20, 61, 402, 314, 2345, 965, 282, 574, 402, 650, 14, 22, 14, 819, 627, 658, 7253, 63, 1392, 8340, 437, 413, 13, 36, 1109, 772, 2345, 402, 9363, 63, 1392, 14505, 13575, 61, 3559, 1314, 9314, 272, 314, 9363, 63, 1392, 402, 314, 5178, 2345, 14, 17415, 282, 769, 9297, 314, 1329, 402, 272, 4008, 315, 1924, 6240, 14, 2104, 2893, 12, 658, 7253, 63, 1392, 1524, 19, 12, 22, 16090, 9314, 282, 272, 2877, 13, 13014, 650, 88, 22, 2345, 12, 658, 7253, 63, 1392, 1524, 18, 12, 19, 12, 20, 16090, 9314, 282, 272, 7795, 13, 13014, 499, 88, 19, 88, 20, 2345, 12, 436, 658, 7253, 63, 1392, 1524, 25, 16090, 9314, 282, 272, 1373, 13, 13014, 2345, 543, 1749, 4008, 14, 819, 710, 5226, 9363, 2345, 13529, 5604, 26, 819, 10841, 1548, 523, 9363, 14, 1392, 275, 9363, 63, 1392, 523, 9363, 59, 2960, 8, 4108, 59, 73, 12457, 275, 1338, 59, 73, 61, 523, 10841, 819, 4885, 16129, 12, 658, 4108, 64, 1077, 506, 3355, 315, 1962, 13, 8452, 1865, 334, 269, 7353, 590, 523, 1026, 30077, 9770, 1865, 641, 314, 6346, 658, 4108, 59, 73, 61, 14963, 961, 365, 440, 30163, 1380, 523, 658, 12079, 64, 2251, 787, 14701, 12, 1325, 4750, 4156, 5534, 3211, 7794, 14, 523, 982, 314, 7794, 402, 5178, 2345, 658, 270, 64, 365, 6835, 12, 282, 6317, 1015, 883, 506, 523, 15884, 701, 6358, 658, 3249, 14, 4421, 63, 29463, 8, 270, 20414, 819, 5679, 26, 710, 5178, 2345, 819, 10841, 1548, 523, 14531, 3861, 8, 4108, 16025, 16, 12, 378, 467, 359, 17, 12, 499, 2365, 1338, 1524, 17, 12, 499, 467, 9363, 63, 1392, 1524, 19, 12, 841, 566, 523, 10841, 819, 8469, 314, 9363, 2345, 819, 10841, 1548, 523, 3474, 17, 12, 378, 12, 378, 12, 378, 61, 2043, 359, 16, 12, 378, 12, 499, 12, 378, 61, 2043, 359, 16, 12, 378, 12, 378, 12, 378, 2677, 523, 10841, 523, 408, 819, 768, 3744, 523, 347, 687, 63, 585, 8, 1886, 12, 5178, 63, 3128, 63, 585, 304, 272, 340, 440, 365, 63, 4421, 8, 4421, 63, 3128, 63, 585, 304, 489, 746, 3146, 480, 4698, 1711, 282, 14531, 3861, 6590, 14531, 3861, 1110, 26, 450, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
drxaero/calibre
src/calibre/ebooks/chm/metadata.py
14
5612
#!/usr/bin/env python2 # vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai from __future__ import with_statement __license__ = 'GPL v3' __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>' __docformat__ = 'restructuredtext en' import re, codecs from calibre.ebooks.BeautifulSoup import BeautifulSoup from calibre.ebooks.chardet import xml_to_unicode from calibre.ebooks.metadata import string_to_authors, MetaInformation from calibre.utils.logging import default_log from calibre.ptempfile import TemporaryFile from calibre import force_unicode def _clean(s): return s.replace(u'\u00a0', u' ') def _detag(tag): str = u"" if tag is None: return str for elem in tag: if hasattr(elem, "contents"): str += _detag(elem) else: str += _clean(elem) return str def _metadata_from_table(soup, searchfor): td = soup.find('td', text=re.compile(searchfor, flags=re.I)) if td is None: return None td = td.parent # there appears to be multiple ways of structuring the metadata # on the home page. cue some nasty special-case hacks... if re.match(r'^\s*'+searchfor+r'\s*$', td.renderContents(None), flags=re.I): meta = _detag(td.findNextSibling('td')) return re.sub('^:', '', meta).strip() else: meta = _detag(td) return re.sub(r'^[^:]+:', '', meta).strip() def _metadata_from_span(soup, searchfor): span = soup.find('span', {'class': re.compile(searchfor, flags=re.I)}) if span is None: return None # this metadata might need some cleaning up still :/ return _detag(span.renderContents(None).strip()) def _get_authors(soup): aut = (_metadata_from_span(soup, r'author') or _metadata_from_table(soup, r'^\s*by\s*:?\s+')) ans = [_('Unknown')] if aut is not None: ans = string_to_authors(aut) return ans def _get_publisher(soup): return (_metadata_from_span(soup, 'imprint') or _metadata_from_table(soup, 'publisher')) def _get_isbn(soup): return (_metadata_from_span(soup, 'isbn') or _metadata_from_table(soup, 'isbn')) def _get_comments(soup): date = (_metadata_from_span(soup, 'cwdate') or _metadata_from_table(soup, 'pub date')) pages = ( _metadata_from_span(soup, 'pages') or _metadata_from_table(soup, 'pages')) try: # date span can have copyright symbols in it... date = date.replace(u'\u00a9', '').strip() # and pages often comes as '(\d+ pages)' pages = re.search(r'\d+', pages).group(0) return u'Published %s, %s pages.' % (date, pages) except: pass return None def _get_cover(soup, rdr): ans = None try: ans = soup.find('img', alt=re.compile('cover', flags=re.I))['src'] except TypeError: # meeehh, no handy alt-tag goodness, try some hackery # the basic idea behind this is that in general, the cover image # has a height:width ratio of ~1.25, whereas most of the nav # buttons are decidedly less than that. # what we do in this is work out that ratio, take 1.25 off it and # save the absolute value when we sort by this value, the smallest # one is most likely to be the cover image, hopefully. r = {} for img in soup('img'): try: r[abs(float(re.search(r'[0-9.]+', img['height']).group())/float(re.search(r'[0-9.]+', img['width']).group())-1.25)] = img['src'] except KeyError: # interestingly, occasionally the only image without height # or width attrs is the cover... r[0] = img['src'] except: # Probably invalid width, height aattributes, ignore continue l = r.keys() l.sort() if l: ans = r[l[0]] # this link comes from the internal html, which is in a subdir if ans is not None: try: ans = rdr.GetFile(ans) except: ans = rdr.root + "/" + ans try: ans = rdr.GetFile(ans) except: ans = None if ans is not None: from PIL import Image from cStringIO import StringIO buf = StringIO() try: Image.open(StringIO(ans)).convert('RGB').save(buf, 'JPEG') ans = buf.getvalue() except: ans = None return ans def get_metadata_from_reader(rdr): raw = rdr.GetFile(rdr.home) home = BeautifulSoup(xml_to_unicode(raw, strip_encoding_pats=True, resolve_entities=True)[0]) title = rdr.title try: x = rdr.GetEncoding() codecs.lookup(x) enc = x except: enc = 'cp1252' title = force_unicode(title, enc) authors = _get_authors(home) mi = MetaInformation(title, authors) publisher = _get_publisher(home) if publisher: mi.publisher = publisher isbn = _get_isbn(home) if isbn: mi.isbn = isbn comments = _get_comments(home) if comments: mi.comments = comments cdata = _get_cover(home, rdr) if cdata is not None: mi.cover_data = ('jpg', cdata) return mi def get_metadata(stream): with TemporaryFile('_chm_metadata.chm') as fname: with open(fname, 'wb') as f: f.write(stream.read()) from calibre.ebooks.chm.reader import CHMReader rdr = CHMReader(fname, default_log) return get_metadata_from_reader(rdr)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 6695, 26, 493, 2991, 29, 6610, 13, 24, 26, 1086, 29, 20, 26, 3519, 29, 20, 26, 1207, 26, 386, 26, 10329, 29, 20, 26, 5789, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 363, 1682, 363, 257, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 6542, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 32, 7697, 5017, 1939, 31876, 14, 846, 3524, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 199, 199, 646, 295, 12, 6010, 199, 199, 504, 19238, 14, 69, 8858, 14, 30117, 12341, 492, 17132, 199, 504, 19238, 14, 69, 8858, 14, 1560, 9886, 492, 2748, 63, 475, 63, 2975, 199, 504, 19238, 14, 69, 8858, 14, 2343, 492, 1059, 63, 475, 63, 8149, 12, 6288, 4935, 199, 504, 19238, 14, 1208, 14, 4806, 492, 849, 63, 793, 199, 504, 19238, 14, 80, 17336, 492, 21791, 1173, 199, 504, 19238, 492, 3542, 63, 2975, 199, 199, 318, 485, 3118, 8, 83, 304, 272, 372, 308, 14, 1814, 8, 85, 1154, 85, 383, 65, 16, 297, 399, 7, 5320, 199, 199, 318, 485, 271, 1450, 8, 1450, 304, 272, 620, 275, 399, 341, 272, 340, 1947, 365, 488, 26, 267, 372, 620, 272, 367, 6193, 315, 1947, 26, 267, 340, 2688, 8, 6086, 12, 298, 4407, 2349, 288, 620, 847, 485, 271, 1450, 8, 6086, 9, 267, 587, 26, 288, 620, 847, 485, 3118, 8, 6086, 9, 272, 372, 620, 421, 199, 318, 485, 2343, 63, 504, 63, 1224, 8, 9317, 12, 2754, 509, 304, 272, 12749, 275, 9108, 14, 1623, 360, 2076, 297, 1318, 29, 264, 14, 2014, 8, 1733, 509, 12, 3285, 29, 264, 14, 41, 430, 272, 340, 12749, 365, 488, 26, 267, 372, 488, 272, 12749, 275, 12749, 14, 1708, 272, 327, 2337, 11337, 370, 506, 3663, 15217, 402, 2702, 4039, 314, 3341, 272, 327, 641, 314, 5629, 2034, 14, 286, 310, 2005, 302, 27352, 4539, 13, 2546, 11176, 83, 1396, 272, 340, 295, 14, 1431, 8, 82, 15542, 83, 10, 6828, 1733, 509, 11, 82, 1154, 83, 32125, 12749, 14, 3352, 11383, 8, 403, 395, 3285, 29, 264, 14, 41, 304, 267, 3404, 275, 485, 271, 1450, 8, 2076, 14, 1623, 5765, 16016, 360, 2076, 1333, 267, 372, 295, 14, 954, 9097, 6536, 3260, 3404, 680, 1913, 342, 272, 587, 26, 267, 3404, 275, 485, 271, 1450, 8, 2076, 9, 267, 372, 295, 14, 954, 8, 82, 4289, 4735, 26, 2807, 6536, 3260, 3404, 680, 1913, 342, 199, 199, 318, 485, 2343, 63, 504, 63, 3751, 8, 9317, 12, 2754, 509, 304, 272, 13598, 275, 9108, 14, 1623, 360, 3751, 297, 791, 533, 356, 295, 14, 2014, 8, 1733, 509, 12, 3285, 29, 264, 14, 41, 11466, 272, 340, 13598, 365, 488, 26, 267, 372, 488, 272, 327, 642, 3341, 5594, 1929, 2005, 29579, 1536, 5139, 520, 15, 272, 372, 485, 271, 1450, 8, 3751, 14, 3352, 11383, 8, 403, 680, 1913, 1012, 199, 199, 318, 485, 362, 63, 8149, 8, 9317, 304, 272, 6384, 275, 6110, 2343, 63, 504, 63, 3751, 8, 9317, 12, 519, 7, 2502, 358, 267, 503, 485, 2343, 63, 504, 63, 1224, 8, 9317, 12, 519, 15542, 83, 10, 991, 60, 83, 19429, 8995, 83, 11, 1333, 272, 4987, 275, 359, 11252, 5912, 5440, 272, 340, 6384, 365, 440, 488, 26, 267, 4987, 275, 1059, 63, 475, 63, 8149, 8, 6898, 9, 272, 372, 4987, 199, 199, 318, 485, 362, 63, 12789, 8, 9317, 304, 272, 372, 6110, 2343, 63, 504, 63, 3751, 8, 9317, 12, 283, 3236, 672, 358, 267, 503, 485, 2343, 63, 504, 63, 1224, 8, 9317, 12, 283, 12789, 1333, 199, 199, 318, 485, 362, 63, 374, 10472, 8, 9317, 304, 272, 372, 6110, 2343, 63, 504, 63, 3751, 8, 9317, 12, 283, 374, 10472, 358, 267, 503, 485, 2343, 63, 504, 63, 1224, 8, 9317, 12, 283, 374, 10472, 1333, 199, 199, 318, 485, 362, 63, 6223, 8, 9317, 304, 272, 1434, 275, 6110, 2343, 63, 504, 63, 3751, 8, 9317, 12, 283, 15346, 602, 358, 267, 503, 485, 2343, 63, 504, 63, 1224, 8, 9317, 12, 283, 5645, 1434, 1333, 272, 6497, 275, 334, 485, 2343, 63, 504, 63, 3751, 8, 9317, 12, 283, 5856, 358, 267, 503, 485, 2343, 63, 504, 63, 1224, 8, 9317, 12, 283, 5856, 1333, 272, 862, 26, 267, 327, 1434, 13598, 883, 1172, 4248, 6698, 315, 652, 1396, 267, 1434, 275, 1434, 14, 1814, 8, 85, 1154, 85, 383, 65, 25, 297, 12548, 1913, 342, 267, 327, 436, 6497, 14115, 12477, 465, 283, 2961, 68, 11, 6497, 3171, 267, 6497, 275, 295, 14, 1733, 8, 82, 1154, 68, 7386, 6497, 680, 923, 8, 16, 9, 267, 372, 399, 7, 27862, 450, 83, 12, 450, 83, 6497, 3530, 450, 334, 602, 12, 6497, 9, 272, 871, 26, 267, 986, 272, 372, 488, 199, 199, 318, 485, 362, 63, 5899, 8, 9317, 12, 519, 5012, 304, 272, 4987, 275, 488, 272, 862, 26, 267, 4987, 275, 9108, 14, 1623, 360, 4060, 297, 8791, 29, 264, 14, 2014, 360, 5899, 297, 3285, 29, 264, 14, 41, 430, 459, 2164, 418, 272, 871, 3146, 26, 267, 327, 562, 1024, 12156, 12, 949, 4926, 89, 8791, 13, 1450, 6954, 4171, 12, 862, 2005, 11176, 994, 267, 327, 314, 5678, 16819, 22172, 642, 365, 626, 315, 8605, 12, 314, 8486, 1834, 267, 327, 965, 282, 4569, 26, 2063, 10463, 402, 6146, 17, 14, 821, 12, 29781, 4750, 402, 314, 16681, 267, 327, 15766, 787, 12985, 770, 590, 6656, 2419, 626, 14, 267, 327, 4052, 781, 886, 315, 642, 365, 1736, 734, 626, 10463, 12, 5452, 413, 14, 821, 2331, 652, 436, 267, 327, 3354, 314, 3679, 574, 1380, 781, 4069, 701, 642, 574, 12, 314, 18604, 267, 327, 1373, 365, 4750, 12060, 370, 506, 314, 8486, 1834, 12, 3661, 5836, 14, 267, 519, 275, 1052, 267, 367, 6050, 315, 9108, 360, 4060, 735, 288, 862, 26, 355, 519, 59, 2101, 8, 1609, 8, 264, 14, 1733, 8, 82, 3894, 16, 13, 25, 14, 11529, 490, 6050, 459, 3333, 13227, 923, 1012, 15, 1609, 8, 264, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 6695, 26, 493, 2991, 29, 6610, 13, 24, 26, 1086, 29, 20, 26, 3519, 29, 20, 26, 1207, 26, 386, 26, 10329, 29, 20, 26, 5789, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 363, 1682, 363, 257, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 6542, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 32, 7697, 5017, 1939, 31876, 14, 846, 3524, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 199, 199, 646, 295, 12, 6010, 199, 199, 504, 19238, 14, 69, 8858, 14, 30117, 12341, 492, 17132, 199, 504, 19238, 14, 69, 8858, 14, 1560, 9886, 492, 2748, 63, 475, 63, 2975, 199, 504, 19238, 14, 69, 8858, 14, 2343, 492, 1059, 63, 475, 63, 8149, 12, 6288, 4935, 199, 504, 19238, 14, 1208, 14, 4806, 492, 849, 63, 793, 199, 504, 19238, 14, 80, 17336, 492, 21791, 1173, 199, 504, 19238, 492, 3542, 63, 2975, 199, 199, 318, 485, 3118, 8, 83, 304, 272, 372, 308, 14, 1814, 8, 85, 1154, 85, 383, 65, 16, 297, 399, 7, 5320, 199, 199, 318, 485, 271, 1450, 8, 1450, 304, 272, 620, 275, 399, 341, 272, 340, 1947, 365, 488, 26, 267, 372, 620, 272, 367, 6193, 315, 1947, 26, 267, 340, 2688, 8, 6086, 12, 298, 4407, 2349, 288, 620, 847, 485, 271, 1450, 8, 6086, 9, 267, 587, 26, 288, 620, 847, 485, 3118, 8, 6086, 9, 272, 372, 620, 421, 199, 318, 485, 2343, 63, 504, 63, 1224, 8, 9317, 12, 2754, 509, 304, 272, 12749, 275, 9108, 14, 1623, 360, 2076, 297, 1318, 29, 264, 14, 2014, 8, 1733, 509, 12, 3285, 29, 264, 14, 41, 430, 272, 340, 12749, 365, 488, 26, 267, 372, 488, 272, 12749, 275, 12749, 14, 1708, 272, 327, 2337, 11337, 370, 506, 3663, 15217, 402, 2702, 4039, 314, 3341, 272, 327, 641, 314, 5629, 2034, 14, 286, 310, 2005, 302, 27352, 4539, 13, 2546, 11176, 83, 1396, 272, 340, 295, 14, 1431, 8, 82, 15542, 83, 10, 6828, 1733, 509, 11, 82, 1154, 83, 32125, 12749, 14, 3352, 11383, 8, 403, 395, 3285, 29, 264, 14, 41, 304, 267, 3404, 275, 485, 271, 1450, 8, 2076, 14, 1623, 5765, 16016, 360, 2076, 1333, 267, 372, 295, 14, 954, 9097, 6536, 3260, 3404, 680, 1913, 342, 272, 587, 26, 267, 3404, 275, 485, 271, 1450, 8, 2076, 9, 267, 372, 295, 14, 954, 8, 82, 4289, 4735, 26, 2807, 6536, 3260, 3404, 680, 1913, 342, 199, 199, 318, 485, 2343, 63, 504, 63, 3751, 8, 9317, 12, 2754, 509, 304, 272, 13598, 275, 9108, 14, 1623, 360, 3751, 297, 791, 533, 356, 295, 14, 2014, 8, 1733, 509, 12, 3285, 29, 264, 14, 41, 11466, 272, 340, 13598, 365, 488, 26, 267, 372, 488, 272, 327, 642, 3341, 5594, 1929, 2005, 29579, 1536, 5139, 520, 15, 272, 372, 485, 271, 1450, 8, 3751, 14, 3352, 11383, 8, 403, 680, 1913, 1012, 199, 199, 318, 485, 362, 63, 8149, 8, 9317, 304, 272, 6384, 275, 6110, 2343, 63, 504, 63, 3751, 8, 9317, 12, 519, 7, 2502, 358, 267, 503, 485, 2343, 63, 504, 63, 1224, 8, 9317, 12, 519, 15542, 83, 10, 991, 60, 83, 19429, 8995, 83, 11, 1333, 272, 4987, 275, 359, 11252, 5912, 5440, 272, 340, 6384, 365, 440, 488, 26, 267, 4987, 275, 1059, 63, 475, 63, 8149, 8, 6898, 9, 272, 372, 4987, 199, 199, 318, 485, 362, 63, 12789, 8, 9317, 304, 272, 372, 6110, 2343, 63, 504, 63, 3751, 8, 9317, 12, 283, 3236, 672, 358, 267, 503, 485, 2343, 63, 504, 63, 1224, 8, 9317, 12, 283, 12789, 1333, 199, 199, 318, 485, 362, 63, 374, 10472, 8, 9317, 304, 272, 372, 6110, 2343, 63, 504, 63, 3751, 8, 9317, 12, 283, 374, 10472, 358, 267, 503, 485, 2343, 63, 504, 63, 1224, 8, 9317, 12, 283, 374, 10472, 1333, 199, 199, 318, 485, 362, 63, 6223, 8, 9317, 304, 272, 1434, 275, 6110, 2343, 63, 504, 63, 3751, 8, 9317, 12, 283, 15346, 602, 358, 267, 503, 485, 2343, 63, 504, 63, 1224, 8, 9317, 12, 283, 5645, 1434, 1333, 272, 6497, 275, 334, 485, 2343, 63, 504, 63, 3751, 8, 9317, 12, 283, 5856, 358, 267, 503, 485, 2343, 63, 504, 63, 1224, 8, 9317, 12, 283, 5856, 1333, 272, 862, 26, 267, 327, 1434, 13598, 883, 1172, 4248, 6698, 315, 652, 1396, 267, 1434, 275, 1434, 14, 1814, 8, 85, 1154, 85, 383, 65, 25, 297, 12548, 1913, 342, 267, 327, 436, 6497, 14115, 12477, 465, 283, 2961, 68, 11, 6497, 3171, 267, 6497, 275, 295, 14, 1733, 8, 82, 1154, 68, 7386, 6497, 680, 923, 8, 16, 9, 267, 372, 399, 7, 27862, 450, 83, 12, 450, 83, 6497, 3530, 450, 334, 602, 12, 6497, 9, 272, 871, 26, 267, 986, 272, 372, 488, 199, 199, 318, 485, 362, 63, 5899, 8, 9317, 12, 519, 5012, 304, 272, 4987, 275, 488, 272, 862, 26, 267, 4987, 275, 9108, 14, 1623, 360, 4060, 297, 8791, 29, 264, 14, 2014, 360, 5899, 297, 3285, 29, 264, 14, 41, 430, 459, 2164, 418, 272, 871, 3146, 26, 267, 327, 562, 1024, 12156, 12, 949, 4926, 89, 8791, 13, 1450, 6954, 4171, 12, 862, 2005, 11176, 994, 267, 327, 314, 5678, 16819, 22172, 642, 365, 626, 315, 8605, 12, 314, 8486, 1834, 267, 327, 965, 282, 4569, 26, 2063, 10463, 402, 6146, 17, 14, 821, 12, 29781, 4750, 402, 314, 16681, 267, 327, 15766, 787, 12985, 770, 590, 6656, 2419, 626, 14, 267, 327, 4052, 781, 886, 315, 642, 365, 1736, 734, 626, 10463, 12, 5452, 413, 14, 821, 2331, 652, 436, 267, 327, 3354, 314, 3679, 574, 1380, 781, 4069, 701, 642, 574, 12, 314, 18604, 267, 327, 1373, 365, 4750, 12060, 370, 506, 314, 8486, 1834, 12, 3661, 5836, 14, 267, 519, 275, 1052, 267, 367, 6050, 315, 9108, 360, 4060, 735, 288, 862, 26, 355, 519, 59, 2101, 8, 1609, 8, 264, 14, 1733, 8, 82, 3894, 16, 13, 25, 14, 11529, 490, 6050, 459, 3333, 13227, 923, 1012, 15, 1609, 8, 264, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
rvykydal/anaconda
pyanaconda/modules/common/structures/kickstart.py
5
3975
# # DBus structures for kickstart. # # Copyright (C) 2019 Red Hat, Inc. All rights reserved. # # 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, see <http://www.gnu.org/licenses/>. # from dasbus.structure import DBusData from dasbus.typing import * # pylint: disable=wildcard-import __all__ = ["KickstartMessage", "KickstartReport"] class KickstartMessage(DBusData): """The kickstart message.""" def __init__(self): self._module_name = "" self._file_name = "" self._line_number = 0 self._message = "" @property def module_name(self) -> Str: """Name of the DBus module. :return: a DBus name """ return self._module_name @module_name.setter def module_name(self, value: Str): self._module_name = value @property def file_name(self) -> Str: """Name of the file. :return: a file name """ return self._file_name @file_name.setter def file_name(self, value: Str): self._file_name = value @property def line_number(self) -> UInt32: """Number of the line. :return: a number """ return UInt32(self._line_number) @line_number.setter def line_number(self, value: UInt32): self._line_number = value @property def message(self) -> Str: """Translated message. :return: a string """ return self._message @message.setter def message(self, value: Str): self._message = value @classmethod def for_error(cls, e): """Create a new message for a kickstart error. :param e: an instance of KickstartError :return: an instance of KickstartMessage """ data = cls() data.message = e.message data.line_number = e.lineno or 0 return data @classmethod def for_warning(cls, warn_msg): """Create a new message for a kickstart error. :param str warn_msg: a warning string :return: an instance of KickstartMessage """ data = cls() data.message = warn_msg data.line_number = 0 return data def __str__(self): """Return the string representation.""" return self.message class KickstartReport(DBusData): """The kickstart report.""" def __init__(self): self._error_messages = [] self._warning_messages = [] def is_valid(self): """Is the kickstart valid? :return: True or False """ return not self._error_messages def get_messages(self): """Get all messages. :return: a list of messages """ return self.error_messages + self.warning_messages @property def error_messages(self) -> List[KickstartMessage]: """List of error messages. :return: a list of messages """ return self._error_messages @error_messages.setter def error_messages(self, messages: List[KickstartMessage]): self._error_messages = list(messages) @property def warning_messages(self) -> List[KickstartMessage]: """List of warning messages. :return: a list of messages """ return self._warning_messages @warning_messages.setter def warning_messages(self, messages: List[KickstartMessage]): self._warning_messages = list(messages)
gpl-2.0
[ 3, 199, 3, 6249, 527, 13955, 367, 1022, 18938, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 20312, 221, 9572, 13002, 12, 3277, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 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, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 504, 366, 305, 5610, 14, 6976, 492, 6249, 527, 1451, 199, 504, 366, 305, 5610, 14, 29747, 492, 627, 221, 327, 4287, 26, 3507, 29, 16692, 13, 646, 199, 199, 363, 452, 363, 275, 2097, 43, 18938, 2209, 401, 298, 43, 18938, 7457, 937, 421, 199, 533, 1804, 18938, 2209, 8, 2846, 527, 1451, 304, 272, 408, 1918, 1022, 18938, 1245, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 578, 63, 354, 275, 3087, 267, 291, 423, 493, 63, 354, 275, 3087, 267, 291, 423, 604, 63, 1955, 275, 378, 267, 291, 423, 1188, 275, 3087, 339, 768, 1829, 272, 347, 859, 63, 354, 8, 277, 9, 1035, 8303, 26, 267, 408, 985, 402, 314, 6249, 527, 859, 14, 398, 520, 1107, 26, 282, 6249, 527, 536, 267, 408, 267, 372, 291, 423, 578, 63, 354, 339, 768, 578, 63, 354, 14, 8345, 272, 347, 859, 63, 354, 8, 277, 12, 574, 26, 8303, 304, 267, 291, 423, 578, 63, 354, 275, 574, 339, 768, 1829, 272, 347, 570, 63, 354, 8, 277, 9, 1035, 8303, 26, 267, 408, 985, 402, 314, 570, 14, 398, 520, 1107, 26, 282, 570, 536, 267, 408, 267, 372, 291, 423, 493, 63, 354, 339, 768, 493, 63, 354, 14, 8345, 272, 347, 570, 63, 354, 8, 277, 12, 574, 26, 8303, 304, 267, 291, 423, 493, 63, 354, 275, 574, 339, 768, 1829, 272, 347, 1004, 63, 1955, 8, 277, 9, 1035, 10666, 708, 26, 267, 408, 3259, 402, 314, 1004, 14, 398, 520, 1107, 26, 282, 1329, 267, 408, 267, 372, 10666, 708, 8, 277, 423, 604, 63, 1955, 9, 339, 768, 604, 63, 1955, 14, 8345, 272, 347, 1004, 63, 1955, 8, 277, 12, 574, 26, 10666, 708, 304, 267, 291, 423, 604, 63, 1955, 275, 574, 339, 768, 1829, 272, 347, 1245, 8, 277, 9, 1035, 8303, 26, 267, 408, 3188, 1776, 1245, 14, 398, 520, 1107, 26, 282, 1059, 267, 408, 267, 372, 291, 423, 1188, 339, 768, 1188, 14, 8345, 272, 347, 1245, 8, 277, 12, 574, 26, 8303, 304, 267, 291, 423, 1188, 275, 574, 339, 768, 3744, 272, 347, 367, 63, 705, 8, 1886, 12, 325, 304, 267, 408, 2499, 282, 892, 1245, 367, 282, 1022, 18938, 1125, 14, 398, 520, 635, 325, 26, 376, 1256, 402, 1804, 18938, 547, 267, 520, 1107, 26, 376, 1256, 402, 1804, 18938, 2209, 267, 408, 267, 666, 275, 843, 342, 267, 666, 14, 1188, 275, 325, 14, 1188, 267, 666, 14, 604, 63, 1955, 275, 325, 14, 3469, 503, 378, 267, 372, 666, 339, 768, 3744, 272, 347, 367, 63, 3764, 8, 1886, 12, 7987, 63, 1328, 304, 267, 408, 2499, 282, 892, 1245, 367, 282, 1022, 18938, 1125, 14, 398, 520, 635, 620, 7987, 63, 1328, 26, 282, 5721, 1059, 267, 520, 1107, 26, 376, 1256, 402, 1804, 18938, 2209, 267, 408, 267, 666, 275, 843, 342, 267, 666, 14, 1188, 275, 7987, 63, 1328, 267, 666, 14, 604, 63, 1955, 275, 378, 267, 372, 666, 339, 347, 636, 495, 721, 277, 304, 267, 408, 1767, 314, 1059, 6025, 1041, 267, 372, 291, 14, 1188, 421, 199, 533, 1804, 18938, 7457, 8, 2846, 527, 1451, 304, 272, 408, 1918, 1022, 18938, 3622, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 705, 63, 3431, 275, 942, 267, 291, 423, 3764, 63, 3431, 275, 942, 339, 347, 365, 63, 1078, 8, 277, 304, 267, 408, 1831, 314, 1022, 18938, 1686, 31, 398, 520, 1107, 26, 715, 503, 756, 267, 408, 267, 372, 440, 291, 423, 705, 63, 3431, 339, 347, 664, 63, 3431, 8, 277, 304, 267, 408, 1002, 1006, 3788, 14, 398, 520, 1107, 26, 282, 769, 402, 3788, 267, 408, 267, 372, 291, 14, 705, 63, 3431, 435, 291, 14, 3764, 63, 3431, 339, 768, 1829, 272, 347, 1125, 63, 3431, 8, 277, 9, 1035, 3820, 59, 43, 18938, 2209, 2189, 267, 408, 1296, 402, 1125, 3788, 14, 398, 520, 1107, 26, 282, 769, 402, 3788, 267, 408, 267, 372, 291, 423, 705, 63, 3431, 339, 768, 705, 63, 3431, 14, 8345, 272, 347, 1125, 63, 3431, 8, 277, 12, 3788, 26, 3820, 59, 43, 18938, 2209, 4682, 267, 291, 423, 705, 63, 3431, 275, 769, 8, 3431, 9, 339, 768, 1829, 272, 347, 5721, 63, 3431, 8, 277, 9, 1035, 3820, 59, 43, 18938, 2209, 2189, 267, 408, 1296, 402, 5721, 3788, 14, 398, 520, 1107, 26, 282, 769, 402, 3788, 267, 408, 267, 372, 291, 423, 3764, 63, 3431, 339, 768, 3764, 63, 3431, 14, 8345, 272, 347, 5721, 63, 3431, 8, 277, 12, 3788, 26, 3820, 59, 43, 18938, 2209, 4682, 267, 291, 423, 3764, 63, 3431, 275, 769, 8, 3431, 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 ]
[ 199, 3, 6249, 527, 13955, 367, 1022, 18938, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 20312, 221, 9572, 13002, 12, 3277, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 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, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 504, 366, 305, 5610, 14, 6976, 492, 6249, 527, 1451, 199, 504, 366, 305, 5610, 14, 29747, 492, 627, 221, 327, 4287, 26, 3507, 29, 16692, 13, 646, 199, 199, 363, 452, 363, 275, 2097, 43, 18938, 2209, 401, 298, 43, 18938, 7457, 937, 421, 199, 533, 1804, 18938, 2209, 8, 2846, 527, 1451, 304, 272, 408, 1918, 1022, 18938, 1245, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 578, 63, 354, 275, 3087, 267, 291, 423, 493, 63, 354, 275, 3087, 267, 291, 423, 604, 63, 1955, 275, 378, 267, 291, 423, 1188, 275, 3087, 339, 768, 1829, 272, 347, 859, 63, 354, 8, 277, 9, 1035, 8303, 26, 267, 408, 985, 402, 314, 6249, 527, 859, 14, 398, 520, 1107, 26, 282, 6249, 527, 536, 267, 408, 267, 372, 291, 423, 578, 63, 354, 339, 768, 578, 63, 354, 14, 8345, 272, 347, 859, 63, 354, 8, 277, 12, 574, 26, 8303, 304, 267, 291, 423, 578, 63, 354, 275, 574, 339, 768, 1829, 272, 347, 570, 63, 354, 8, 277, 9, 1035, 8303, 26, 267, 408, 985, 402, 314, 570, 14, 398, 520, 1107, 26, 282, 570, 536, 267, 408, 267, 372, 291, 423, 493, 63, 354, 339, 768, 493, 63, 354, 14, 8345, 272, 347, 570, 63, 354, 8, 277, 12, 574, 26, 8303, 304, 267, 291, 423, 493, 63, 354, 275, 574, 339, 768, 1829, 272, 347, 1004, 63, 1955, 8, 277, 9, 1035, 10666, 708, 26, 267, 408, 3259, 402, 314, 1004, 14, 398, 520, 1107, 26, 282, 1329, 267, 408, 267, 372, 10666, 708, 8, 277, 423, 604, 63, 1955, 9, 339, 768, 604, 63, 1955, 14, 8345, 272, 347, 1004, 63, 1955, 8, 277, 12, 574, 26, 10666, 708, 304, 267, 291, 423, 604, 63, 1955, 275, 574, 339, 768, 1829, 272, 347, 1245, 8, 277, 9, 1035, 8303, 26, 267, 408, 3188, 1776, 1245, 14, 398, 520, 1107, 26, 282, 1059, 267, 408, 267, 372, 291, 423, 1188, 339, 768, 1188, 14, 8345, 272, 347, 1245, 8, 277, 12, 574, 26, 8303, 304, 267, 291, 423, 1188, 275, 574, 339, 768, 3744, 272, 347, 367, 63, 705, 8, 1886, 12, 325, 304, 267, 408, 2499, 282, 892, 1245, 367, 282, 1022, 18938, 1125, 14, 398, 520, 635, 325, 26, 376, 1256, 402, 1804, 18938, 547, 267, 520, 1107, 26, 376, 1256, 402, 1804, 18938, 2209, 267, 408, 267, 666, 275, 843, 342, 267, 666, 14, 1188, 275, 325, 14, 1188, 267, 666, 14, 604, 63, 1955, 275, 325, 14, 3469, 503, 378, 267, 372, 666, 339, 768, 3744, 272, 347, 367, 63, 3764, 8, 1886, 12, 7987, 63, 1328, 304, 267, 408, 2499, 282, 892, 1245, 367, 282, 1022, 18938, 1125, 14, 398, 520, 635, 620, 7987, 63, 1328, 26, 282, 5721, 1059, 267, 520, 1107, 26, 376, 1256, 402, 1804, 18938, 2209, 267, 408, 267, 666, 275, 843, 342, 267, 666, 14, 1188, 275, 7987, 63, 1328, 267, 666, 14, 604, 63, 1955, 275, 378, 267, 372, 666, 339, 347, 636, 495, 721, 277, 304, 267, 408, 1767, 314, 1059, 6025, 1041, 267, 372, 291, 14, 1188, 421, 199, 533, 1804, 18938, 7457, 8, 2846, 527, 1451, 304, 272, 408, 1918, 1022, 18938, 3622, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 705, 63, 3431, 275, 942, 267, 291, 423, 3764, 63, 3431, 275, 942, 339, 347, 365, 63, 1078, 8, 277, 304, 267, 408, 1831, 314, 1022, 18938, 1686, 31, 398, 520, 1107, 26, 715, 503, 756, 267, 408, 267, 372, 440, 291, 423, 705, 63, 3431, 339, 347, 664, 63, 3431, 8, 277, 304, 267, 408, 1002, 1006, 3788, 14, 398, 520, 1107, 26, 282, 769, 402, 3788, 267, 408, 267, 372, 291, 14, 705, 63, 3431, 435, 291, 14, 3764, 63, 3431, 339, 768, 1829, 272, 347, 1125, 63, 3431, 8, 277, 9, 1035, 3820, 59, 43, 18938, 2209, 2189, 267, 408, 1296, 402, 1125, 3788, 14, 398, 520, 1107, 26, 282, 769, 402, 3788, 267, 408, 267, 372, 291, 423, 705, 63, 3431, 339, 768, 705, 63, 3431, 14, 8345, 272, 347, 1125, 63, 3431, 8, 277, 12, 3788, 26, 3820, 59, 43, 18938, 2209, 4682, 267, 291, 423, 705, 63, 3431, 275, 769, 8, 3431, 9, 339, 768, 1829, 272, 347, 5721, 63, 3431, 8, 277, 9, 1035, 3820, 59, 43, 18938, 2209, 2189, 267, 408, 1296, 402, 5721, 3788, 14, 398, 520, 1107, 26, 282, 769, 402, 3788, 267, 408, 267, 372, 291, 423, 3764, 63, 3431, 339, 768, 3764, 63, 3431, 14, 8345, 272, 347, 5721, 63, 3431, 8, 277, 12, 3788, 26, 3820, 59, 43, 18938, 2209, 4682, 267, 291, 423, 3764, 63, 3431, 275, 769, 8, 3431, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Krossom/python-for-android
python-modules/twisted/twisted/conch/client/agent.py
60
1740
# -*- test-case-name: twisted.conch.test.test_default -*- # Copyright (c) 2001-2009 Twisted Matrix Laboratories. # See LICENSE for details. """ Accesses the key agent for user authentication. Maintainer: Paul Swartz """ import os from twisted.conch.ssh import agent, channel, keys from twisted.internet import protocol, reactor from twisted.python import log class SSHAgentClient(agent.SSHAgentClient): def __init__(self): agent.SSHAgentClient.__init__(self) self.blobs = [] def getPublicKeys(self): return self.requestIdentities().addCallback(self._cbPublicKeys) def _cbPublicKeys(self, blobcomm): log.msg('got %i public keys' % len(blobcomm)) self.blobs = [x[0] for x in blobcomm] def getPublicKey(self): """ Return a L{Key} from the first blob in C{self.blobs}, if any, or return C{None}. """ if self.blobs: return keys.Key.fromString(self.blobs.pop(0)) return None class SSHAgentForwardingChannel(channel.SSHChannel): def channelOpen(self, specificData): cc = protocol.ClientCreator(reactor, SSHAgentForwardingLocal) d = cc.connectUNIX(os.environ['SSH_AUTH_SOCK']) d.addCallback(self._cbGotLocal) d.addErrback(lambda x:self.loseConnection()) self.buf = '' def _cbGotLocal(self, local): self.local = local self.dataReceived = self.local.transport.write self.local.dataReceived = self.write def dataReceived(self, data): self.buf += data def closed(self): if self.local: self.local.loseConnection() self.local = None class SSHAgentForwardingLocal(protocol.Protocol): pass
apache-2.0
[ 3, 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 388, 335, 14, 396, 14, 396, 63, 885, 1882, 199, 3, 1898, 334, 67, 9, 12521, 13, 8664, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 1945, 5804, 314, 790, 6631, 367, 922, 6299, 14, 199, 199, 11903, 8368, 281, 26, 28574, 16666, 28124, 199, 624, 199, 199, 646, 747, 199, 199, 504, 7390, 14, 388, 335, 14, 5510, 492, 6631, 12, 3623, 12, 2883, 199, 504, 7390, 14, 4901, 492, 4113, 12, 9655, 199, 504, 7390, 14, 1548, 492, 943, 4388, 199, 533, 12027, 7788, 3041, 8, 4054, 14, 13716, 7788, 3041, 304, 339, 347, 636, 826, 721, 277, 304, 267, 6631, 14, 13716, 7788, 3041, 855, 826, 721, 277, 9, 267, 291, 14, 21893, 275, 942, 2378, 347, 664, 9885, 6340, 8, 277, 304, 267, 372, 291, 14, 1069, 17062, 5080, 1252, 10053, 8, 277, 423, 2894, 9885, 6340, 9, 2378, 347, 485, 2894, 9885, 6340, 8, 277, 12, 9182, 1404, 304, 267, 943, 14, 1328, 360, 7808, 450, 73, 4575, 2883, 7, 450, 822, 8, 6582, 1404, 430, 267, 291, 14, 21893, 275, 359, 88, 59, 16, 61, 367, 671, 315, 9182, 1404, 61, 2378, 347, 664, 26238, 8, 277, 304, 267, 408, 267, 1432, 282, 491, 91, 1197, 93, 687, 314, 1642, 9182, 315, 445, 91, 277, 14, 21893, 1386, 340, 1263, 12, 503, 267, 372, 445, 91, 403, 5565, 267, 408, 267, 340, 291, 14, 21893, 26, 288, 372, 2883, 14, 1197, 14, 504, 1558, 8, 277, 14, 21893, 14, 1935, 8, 16, 430, 267, 372, 488, 4388, 199, 533, 12027, 7788, 26427, 5358, 8, 2775, 14, 13716, 5358, 304, 339, 347, 3623, 4299, 8, 277, 12, 2488, 1451, 304, 267, 7429, 275, 4113, 14, 3041, 17523, 8, 13544, 12, 12027, 7788, 26427, 5339, 9, 267, 366, 275, 7429, 14, 2242, 19584, 8, 736, 14, 2314, 459, 13716, 63, 5580, 63, 9469, 1105, 267, 366, 14, 10053, 8, 277, 423, 2894, 13662, 5339, 9, 267, 366, 14, 31554, 8, 2734, 671, 26, 277, 14, 32452, 1012, 267, 291, 14, 1436, 275, 2125, 2378, 347, 485, 2894, 13662, 5339, 8, 277, 12, 2257, 304, 267, 291, 14, 1832, 275, 2257, 267, 291, 14, 25037, 275, 291, 14, 1832, 14, 5545, 14, 952, 267, 291, 14, 1832, 14, 25037, 275, 291, 14, 952, 2378, 347, 666, 9392, 8, 277, 12, 666, 304, 267, 291, 14, 1436, 847, 666, 2378, 347, 6876, 8, 277, 304, 267, 340, 291, 14, 1832, 26, 288, 291, 14, 1832, 14, 32452, 342, 288, 291, 14, 1832, 275, 488, 421, 199, 533, 12027, 7788, 26427, 5339, 8, 3922, 14, 3658, 304, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 388, 335, 14, 396, 14, 396, 63, 885, 1882, 199, 3, 1898, 334, 67, 9, 12521, 13, 8664, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 1945, 5804, 314, 790, 6631, 367, 922, 6299, 14, 199, 199, 11903, 8368, 281, 26, 28574, 16666, 28124, 199, 624, 199, 199, 646, 747, 199, 199, 504, 7390, 14, 388, 335, 14, 5510, 492, 6631, 12, 3623, 12, 2883, 199, 504, 7390, 14, 4901, 492, 4113, 12, 9655, 199, 504, 7390, 14, 1548, 492, 943, 4388, 199, 533, 12027, 7788, 3041, 8, 4054, 14, 13716, 7788, 3041, 304, 339, 347, 636, 826, 721, 277, 304, 267, 6631, 14, 13716, 7788, 3041, 855, 826, 721, 277, 9, 267, 291, 14, 21893, 275, 942, 2378, 347, 664, 9885, 6340, 8, 277, 304, 267, 372, 291, 14, 1069, 17062, 5080, 1252, 10053, 8, 277, 423, 2894, 9885, 6340, 9, 2378, 347, 485, 2894, 9885, 6340, 8, 277, 12, 9182, 1404, 304, 267, 943, 14, 1328, 360, 7808, 450, 73, 4575, 2883, 7, 450, 822, 8, 6582, 1404, 430, 267, 291, 14, 21893, 275, 359, 88, 59, 16, 61, 367, 671, 315, 9182, 1404, 61, 2378, 347, 664, 26238, 8, 277, 304, 267, 408, 267, 1432, 282, 491, 91, 1197, 93, 687, 314, 1642, 9182, 315, 445, 91, 277, 14, 21893, 1386, 340, 1263, 12, 503, 267, 372, 445, 91, 403, 5565, 267, 408, 267, 340, 291, 14, 21893, 26, 288, 372, 2883, 14, 1197, 14, 504, 1558, 8, 277, 14, 21893, 14, 1935, 8, 16, 430, 267, 372, 488, 4388, 199, 533, 12027, 7788, 26427, 5358, 8, 2775, 14, 13716, 5358, 304, 339, 347, 3623, 4299, 8, 277, 12, 2488, 1451, 304, 267, 7429, 275, 4113, 14, 3041, 17523, 8, 13544, 12, 12027, 7788, 26427, 5339, 9, 267, 366, 275, 7429, 14, 2242, 19584, 8, 736, 14, 2314, 459, 13716, 63, 5580, 63, 9469, 1105, 267, 366, 14, 10053, 8, 277, 423, 2894, 13662, 5339, 9, 267, 366, 14, 31554, 8, 2734, 671, 26, 277, 14, 32452, 1012, 267, 291, 14, 1436, 275, 2125, 2378, 347, 485, 2894, 13662, 5339, 8, 277, 12, 2257, 304, 267, 291, 14, 1832, 275, 2257, 267, 291, 14, 25037, 275, 291, 14, 1832, 14, 5545, 14, 952, 267, 291, 14, 1832, 14, 25037, 275, 291, 14, 952, 2378, 347, 666, 9392, 8, 277, 12, 666, 304, 267, 291, 14, 1436, 847, 666, 2378, 347, 6876, 8, 277, 304, 267, 340, 291, 14, 1832, 26, 288, 291, 14, 1832, 14, 32452, 342, 288, 291, 14, 1832, 275, 488, 421, 199, 533, 12027, 7788, 26427, 5339, 8, 3922, 14, 3658, 304, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
atvcaptain/enigma2
lib/python/Plugins/Extensions/DVDBurn/Title.py
1
6455
from __future__ import absolute_import from Components.config import ConfigSubsection, ConfigSubList, ConfigInteger, ConfigText, ConfigSelection from . import TitleCutter class ConfigFixedText(ConfigText): def __init__(self, text, visible_width=60): ConfigText.__init__(self, default = text, fixed_size = True, visible_width = visible_width) def handleKey(self, key): pass class Title: def __init__(self, project): self.properties = ConfigSubsection() self.properties.menutitle = ConfigText(fixed_size = False, visible_width = 80) self.properties.menusubtitle = ConfigText(fixed_size = False, visible_width = 80) self.properties.aspect = ConfigSelection(choices = [("4:3", _("4:3")), ("16:9", _("16:9"))]) self.properties.widescreen = ConfigSelection(choices = [("nopanscan", "nopanscan"), ("noletterbox", "noletterbox")]) self.properties.autochapter = ConfigInteger(default = 0, limits = (0, 60)) self.properties.audiotracks = ConfigSubList() self.DVBname = _("Title") self.DVBdescr = _("Description") self.DVBchannel = _("Channel") self.cuesheet = [ ] self.source = None self.filesize = 0 self.estimatedDiskspace = 0 self.inputfile = "" self.cutlist = [ ] self.chaptermarks = [ ] self.timeCreate = None self.project = project self.length = 0 self.VideoType = -1 self.VideoPID = -1 self.framerate = 0 self.progressive = -1 self.resolution = (-1, -1) def addService(self, service): from os import path from enigma import eServiceCenter, iServiceInformation from ServiceReference import ServiceReference from time import localtime, time self.source = service serviceHandler = eServiceCenter.getInstance() info = serviceHandler.info(service) sDescr = info and info.getInfoString(service, iServiceInformation.sDescription) or "" self.DVBdescr = sDescr sTimeCreate = info.getInfo(service, iServiceInformation.sTimeCreate) if sTimeCreate > 1: self.timeCreate = localtime(sTimeCreate) serviceref = ServiceReference(info.getInfoString(service, iServiceInformation.sServiceref)) name = info and info.getName(service) or "Title" + sDescr self.DVBname = name self.DVBchannel = serviceref.getServiceName() self.inputfile = service.getPath() self.filesize = path.getsize(self.inputfile) self.estimatedDiskspace = self.filesize self.length = info.getLength(service) def addFile(self, filename): from enigma import eServiceReference ref = eServiceReference(1, 0, filename) self.addService(ref) self.project.session.openWithCallback(self.titleEditDone, TitleCutter.CutlistReader, self) def titleEditDone(self, cutlist): self.initDVDmenuText(len(self.project.titles)) self.cuesheet = cutlist self.produceFinalCuesheet() def initDVDmenuText(self, track): s = self.project.menutemplate.settings self.properties.menutitle.setValue(self.formatDVDmenuText(s.titleformat.getValue(), track)) self.properties.menusubtitle.setValue(self.formatDVDmenuText(s.subtitleformat.getValue(), track)) def formatDVDmenuText(self, template, track): template = template.replace("$i", str(track)) template = template.replace("$t", self.DVBname) template = template.replace("$d", self.DVBdescr) template = template.replace("$c", str(len(self.chaptermarks)+1)) template = template.replace("$f", self.inputfile) template = template.replace("$C", self.DVBchannel) #if template.find("$A") >= 0: audiolist = [ ] for audiotrack in self.properties.audiotracks: active = audiotrack.active.getValue() if active: trackstring = audiotrack.format.getValue() trackstring += ' (' + audiotrack.language.getValue() + ')' audiolist.append(trackstring) audiostring = ', '.join(audiolist) template = template.replace("$A", audiostring) if template.find("$l") >= 0: l = self.length lengthstring = "%d:%02d:%02d" % (l/3600, l%3600/60, l%60) template = template.replace("$l", lengthstring) if self.timeCreate: template = template.replace("$Y", str(self.timeCreate[0])) template = template.replace("$M", str(self.timeCreate[1])) template = template.replace("$D", str(self.timeCreate[2])) timestring = "%d:%02d" % (self.timeCreate[3], self.timeCreate[4]) template = template.replace("$T", timestring) else: template = template.replace("$Y", "").replace("$M", "").replace("$D", "").replace("$T", "") return template def produceFinalCuesheet(self): CUT_TYPE_IN = 0 CUT_TYPE_OUT = 1 CUT_TYPE_MARK = 2 CUT_TYPE_LAST = 3 accumulated_in = 0 accumulated_at = 0 last_in = 0 self.cutlist = [ ] self.chaptermarks = [ ] # our demuxer expects *strictly* IN,OUT lists. currently_in = not any(type == CUT_TYPE_IN for pts, type in self.cuesheet) if currently_in: self.cutlist.append(0) # emulate "in" at first for (pts, type) in self.cuesheet: #print "pts=", pts, "type=", type, "accumulated_in=", accumulated_in, "accumulated_at=", accumulated_at, "last_in=", last_in if type == CUT_TYPE_IN and not currently_in: self.cutlist.append(pts) last_in = pts currently_in = True if type == CUT_TYPE_OUT and currently_in: self.cutlist.append(pts) # accumulate the segment accumulated_in += pts - last_in accumulated_at = pts currently_in = False if type == CUT_TYPE_MARK and currently_in: # relocate chaptermark against "in" time. This is not 100% accurate, # as the in/out points are not. reloc_pts = pts - last_in + accumulated_in self.chaptermarks.append(reloc_pts) if len(self.cutlist) > 1: part = accumulated_in / (self.length*90000.0) usedsize = int ( part * self.filesize ) self.estimatedDiskspace = usedsize self.length = accumulated_in / 90000 def getChapterMarks(self, template="$h:$m:$s.$t"): timestamps = [ ] chapters = [ ] minutes = self.properties.autochapter.getValue() if len(self.chaptermarks) < 1 and minutes > 0: chapterpts = 0 while chapterpts < (self.length-60*minutes)*90000: chapterpts += 90000 * 60 * minutes chapters.append(chapterpts) else: chapters = self.chaptermarks for p in chapters: timestring = template.replace("$h", str(p / (90000 * 3600))) timestring = timestring.replace("$m", ("%02d" % (p % (90000 * 3600) / (90000 * 60)))) timestring = timestring.replace("$s", ("%02d" % (p % (90000 * 60) / 90000))) timestring = timestring.replace("$t", ("%03d" % ((p % 90000) / 90))) timestamps.append(timestring) return timestamps
gpl-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 17823, 14, 888, 492, 4094, 31839, 12, 4094, 2610, 1296, 12, 4094, 2674, 12, 4094, 1872, 12, 32245, 199, 504, 1275, 492, 16881, 35, 18404, 199, 199, 533, 4094, 9515, 1872, 8, 2028, 1872, 304, 199, 198, 318, 636, 826, 721, 277, 12, 1318, 12, 8917, 63, 2063, 29, 2259, 304, 507, 198, 2028, 1872, 855, 826, 721, 277, 12, 849, 275, 1318, 12, 6317, 63, 890, 275, 715, 12, 8917, 63, 2063, 275, 8917, 63, 2063, 9, 199, 198, 318, 2429, 1197, 8, 277, 12, 790, 304, 507, 198, 1529, 199, 199, 533, 16881, 26, 199, 198, 318, 636, 826, 721, 277, 12, 2199, 304, 507, 198, 277, 14, 3282, 275, 4094, 31839, 342, 507, 198, 277, 14, 3282, 14, 1410, 935, 1118, 275, 4094, 1872, 8, 5964, 63, 890, 275, 756, 12, 8917, 63, 2063, 275, 5939, 9, 507, 198, 277, 14, 3282, 14, 30969, 456, 1213, 275, 4094, 1872, 8, 5964, 63, 890, 275, 756, 12, 8917, 63, 2063, 275, 5939, 9, 507, 198, 277, 14, 3282, 14, 18658, 275, 32245, 8, 4577, 275, 10003, 20, 26, 19, 401, 3824, 20, 26, 19, 8150, 1689, 975, 26, 25, 401, 3824, 975, 26, 25, 2237, 566, 507, 198, 277, 14, 3282, 14, 13062, 5410, 275, 32245, 8, 4577, 275, 10003, 20443, 290, 6282, 401, 298, 20443, 290, 6282, 1288, 1689, 889, 9269, 1977, 401, 298, 889, 9269, 1977, 13403, 507, 198, 277, 14, 3282, 14, 2495, 11316, 275, 4094, 2674, 8, 885, 275, 378, 12, 10976, 275, 334, 16, 12, 5212, 430, 507, 198, 277, 14, 3282, 14, 23577, 357, 345, 5618, 275, 4094, 2610, 1296, 342, 507, 198, 277, 14, 6741, 34, 354, 275, 3824, 6888, 531, 507, 198, 277, 14, 6741, 34, 12113, 275, 3824, 5831, 531, 507, 198, 277, 14, 6741, 34, 2775, 275, 3824, 5358, 531, 507, 198, 277, 14, 14932, 5069, 275, 359, 1622, 507, 198, 277, 14, 1365, 275, 488, 507, 198, 277, 14, 19233, 275, 378, 507, 198, 277, 14, 597, 12754, 10690, 2638, 275, 378, 507, 198, 277, 14, 1210, 493, 275, 3087, 507, 198, 277, 14, 5919, 513, 275, 359, 1622, 507, 198, 277, 14, 11316, 10375, 275, 359, 1622, 507, 198, 277, 14, 521, 2499, 275, 488, 507, 198, 277, 14, 1715, 275, 2199, 507, 198, 277, 14, 1267, 275, 378, 507, 198, 277, 14, 9166, 804, 275, 446, 17, 507, 198, 277, 14, 9166, 16098, 275, 446, 17, 507, 198, 277, 14, 1943, 1866, 275, 378, 507, 198, 277, 14, 6595, 470, 3398, 275, 446, 17, 507, 198, 277, 14, 12588, 275, 5868, 17, 12, 446, 17, 9, 421, 198, 318, 1050, 3167, 8, 277, 12, 2435, 304, 507, 198, 504, 747, 492, 931, 507, 198, 504, 655, 27021, 492, 325, 3167, 13551, 12, 284, 3167, 4935, 507, 198, 504, 7591, 5083, 492, 7591, 5083, 507, 198, 504, 900, 492, 2257, 521, 12, 900, 507, 198, 277, 14, 1365, 275, 2435, 507, 198, 1364, 2461, 275, 325, 3167, 13551, 14, 29964, 342, 507, 198, 815, 275, 2435, 2461, 14, 815, 8, 1364, 9, 507, 198, 83, 28782, 275, 2256, 436, 2256, 14, 362, 2354, 1558, 8, 1364, 12, 284, 3167, 4935, 14, 83, 5831, 9, 503, 3087, 507, 198, 277, 14, 6741, 34, 12113, 275, 308, 28782, 507, 198, 83, 1366, 2499, 275, 2256, 14, 362, 2354, 8, 1364, 12, 284, 3167, 4935, 14, 83, 1366, 2499, 9, 507, 198, 692, 308, 1366, 2499, 690, 413, 26, 686, 198, 277, 14, 521, 2499, 275, 2257, 521, 8, 83, 1366, 2499, 9, 507, 198, 1364, 1121, 275, 7591, 5083, 8, 815, 14, 362, 2354, 1558, 8, 1364, 12, 284, 3167, 4935, 14, 83, 3167, 1121, 430, 507, 198, 354, 275, 2256, 436, 2256, 14, 16405, 8, 1364, 9, 503, 298, 6888, 2, 435, 308, 28782, 507, 198, 277, 14, 6741, 34, 354, 275, 536, 507, 198, 277, 14, 6741, 34, 2775, 275, 2435, 1121, 14, 362, 3167, 985, 342, 507, 198, 277, 14, 1210, 493, 275, 2435, 14, 362, 2042, 342, 507, 198, 277, 14, 19233, 275, 931, 14, 20733, 8, 277, 14, 1210, 493, 9, 507, 198, 277, 14, 597, 12754, 10690, 2638, 275, 291, 14, 19233, 507, 198, 277, 14, 1267, 275, 2256, 14, 362, 4625, 8, 1364, 9, 5264, 199, 198, 318, 1050, 1173, 8, 277, 12, 1788, 304, 507, 198, 504, 655, 27021, 492, 325, 3167, 5083, 507, 198, 1121, 275, 325, 3167, 5083, 8, 17, 12, 378, 12, 1788, 9, 507, 198, 277, 14, 525, 3167, 8, 1121, 9, 507, 198, 277, 14, 1715, 14, 1730, 14, 30913, 8, 277, 14, 1213, 4685, 10759, 12, 16881, 35, 18404, 14, 23498, 513, 5929, 12, 291, 9, 8299, 198, 318, 2538, 4685, 10759, 8, 277, 12, 10415, 513, 304, 507, 198, 277, 14, 826, 6741, 36, 4470, 1872, 8, 552, 8, 277, 14, 1715, 14, 8916, 430, 507, 198, 277, 14, 14932, 5069, 275, 10415, 513, 507, 198, 277, 14, 7832, 12776, 35, 310, 5069, 342, 421, 198, 318, 4205, 6741, 36, 4470, 1872, 8, 277, 12, 4426, 304, 507, 198, 83, 275, 291, 14, 1715, 14, 4470, 1160, 14, 1751, 507, 198, 277, 14, 3282, 14, 1410, 935, 1118, 14, 14733, 8, 277, 14, 908, 6741, 36, 4470, 1872, 8, 83, 14, 1213, 908, 14, 17186, 1062, 4426, 430, 507, 198, 277, 14, 3282, 14, 30969, 456, 1213, 14, 14733, 8, 277, 14, 908, 6741, 36, 4470, 1872, 8, 83, 14, 14348, 908, 14, 17186, 1062, 4426, 430, 421, 198, 318, 1475, 6741, 36, 4470, 1872, 8, 277, 12, 1978, 12, 4426, 304, 507, 198, 1160, 275, 1978, 14, 1814, 21506, 73, 401, 620, 8, 3885, 430, 507, 198, 1160, 275, 1978, 14, 1814, 21506, 84, 401, 291, 14, 6741, 34, 354, 9, 507, 198, 1160, 275, 1978, 14, 1814, 21506, 68, 401, 291, 14, 6741, 34, 12113, 9, 507, 198, 1160, 275, 1978, 14, 1814, 21506, 67, 401, 620, 8, 552, 8, 277, 14, 11316, 10375, 6393, 17, 430, 507, 198, 1160, 275, 1978, 14, 1814, 21506, 70, 401, 291, 14, 1210, 493, 9, 507, 198, 1160, 275, 1978, 14, 1814, 21506, 35, 401, 291, 14, 6741 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 17823, 14, 888, 492, 4094, 31839, 12, 4094, 2610, 1296, 12, 4094, 2674, 12, 4094, 1872, 12, 32245, 199, 504, 1275, 492, 16881, 35, 18404, 199, 199, 533, 4094, 9515, 1872, 8, 2028, 1872, 304, 199, 198, 318, 636, 826, 721, 277, 12, 1318, 12, 8917, 63, 2063, 29, 2259, 304, 507, 198, 2028, 1872, 855, 826, 721, 277, 12, 849, 275, 1318, 12, 6317, 63, 890, 275, 715, 12, 8917, 63, 2063, 275, 8917, 63, 2063, 9, 199, 198, 318, 2429, 1197, 8, 277, 12, 790, 304, 507, 198, 1529, 199, 199, 533, 16881, 26, 199, 198, 318, 636, 826, 721, 277, 12, 2199, 304, 507, 198, 277, 14, 3282, 275, 4094, 31839, 342, 507, 198, 277, 14, 3282, 14, 1410, 935, 1118, 275, 4094, 1872, 8, 5964, 63, 890, 275, 756, 12, 8917, 63, 2063, 275, 5939, 9, 507, 198, 277, 14, 3282, 14, 30969, 456, 1213, 275, 4094, 1872, 8, 5964, 63, 890, 275, 756, 12, 8917, 63, 2063, 275, 5939, 9, 507, 198, 277, 14, 3282, 14, 18658, 275, 32245, 8, 4577, 275, 10003, 20, 26, 19, 401, 3824, 20, 26, 19, 8150, 1689, 975, 26, 25, 401, 3824, 975, 26, 25, 2237, 566, 507, 198, 277, 14, 3282, 14, 13062, 5410, 275, 32245, 8, 4577, 275, 10003, 20443, 290, 6282, 401, 298, 20443, 290, 6282, 1288, 1689, 889, 9269, 1977, 401, 298, 889, 9269, 1977, 13403, 507, 198, 277, 14, 3282, 14, 2495, 11316, 275, 4094, 2674, 8, 885, 275, 378, 12, 10976, 275, 334, 16, 12, 5212, 430, 507, 198, 277, 14, 3282, 14, 23577, 357, 345, 5618, 275, 4094, 2610, 1296, 342, 507, 198, 277, 14, 6741, 34, 354, 275, 3824, 6888, 531, 507, 198, 277, 14, 6741, 34, 12113, 275, 3824, 5831, 531, 507, 198, 277, 14, 6741, 34, 2775, 275, 3824, 5358, 531, 507, 198, 277, 14, 14932, 5069, 275, 359, 1622, 507, 198, 277, 14, 1365, 275, 488, 507, 198, 277, 14, 19233, 275, 378, 507, 198, 277, 14, 597, 12754, 10690, 2638, 275, 378, 507, 198, 277, 14, 1210, 493, 275, 3087, 507, 198, 277, 14, 5919, 513, 275, 359, 1622, 507, 198, 277, 14, 11316, 10375, 275, 359, 1622, 507, 198, 277, 14, 521, 2499, 275, 488, 507, 198, 277, 14, 1715, 275, 2199, 507, 198, 277, 14, 1267, 275, 378, 507, 198, 277, 14, 9166, 804, 275, 446, 17, 507, 198, 277, 14, 9166, 16098, 275, 446, 17, 507, 198, 277, 14, 1943, 1866, 275, 378, 507, 198, 277, 14, 6595, 470, 3398, 275, 446, 17, 507, 198, 277, 14, 12588, 275, 5868, 17, 12, 446, 17, 9, 421, 198, 318, 1050, 3167, 8, 277, 12, 2435, 304, 507, 198, 504, 747, 492, 931, 507, 198, 504, 655, 27021, 492, 325, 3167, 13551, 12, 284, 3167, 4935, 507, 198, 504, 7591, 5083, 492, 7591, 5083, 507, 198, 504, 900, 492, 2257, 521, 12, 900, 507, 198, 277, 14, 1365, 275, 2435, 507, 198, 1364, 2461, 275, 325, 3167, 13551, 14, 29964, 342, 507, 198, 815, 275, 2435, 2461, 14, 815, 8, 1364, 9, 507, 198, 83, 28782, 275, 2256, 436, 2256, 14, 362, 2354, 1558, 8, 1364, 12, 284, 3167, 4935, 14, 83, 5831, 9, 503, 3087, 507, 198, 277, 14, 6741, 34, 12113, 275, 308, 28782, 507, 198, 83, 1366, 2499, 275, 2256, 14, 362, 2354, 8, 1364, 12, 284, 3167, 4935, 14, 83, 1366, 2499, 9, 507, 198, 692, 308, 1366, 2499, 690, 413, 26, 686, 198, 277, 14, 521, 2499, 275, 2257, 521, 8, 83, 1366, 2499, 9, 507, 198, 1364, 1121, 275, 7591, 5083, 8, 815, 14, 362, 2354, 1558, 8, 1364, 12, 284, 3167, 4935, 14, 83, 3167, 1121, 430, 507, 198, 354, 275, 2256, 436, 2256, 14, 16405, 8, 1364, 9, 503, 298, 6888, 2, 435, 308, 28782, 507, 198, 277, 14, 6741, 34, 354, 275, 536, 507, 198, 277, 14, 6741, 34, 2775, 275, 2435, 1121, 14, 362, 3167, 985, 342, 507, 198, 277, 14, 1210, 493, 275, 2435, 14, 362, 2042, 342, 507, 198, 277, 14, 19233, 275, 931, 14, 20733, 8, 277, 14, 1210, 493, 9, 507, 198, 277, 14, 597, 12754, 10690, 2638, 275, 291, 14, 19233, 507, 198, 277, 14, 1267, 275, 2256, 14, 362, 4625, 8, 1364, 9, 5264, 199, 198, 318, 1050, 1173, 8, 277, 12, 1788, 304, 507, 198, 504, 655, 27021, 492, 325, 3167, 5083, 507, 198, 1121, 275, 325, 3167, 5083, 8, 17, 12, 378, 12, 1788, 9, 507, 198, 277, 14, 525, 3167, 8, 1121, 9, 507, 198, 277, 14, 1715, 14, 1730, 14, 30913, 8, 277, 14, 1213, 4685, 10759, 12, 16881, 35, 18404, 14, 23498, 513, 5929, 12, 291, 9, 8299, 198, 318, 2538, 4685, 10759, 8, 277, 12, 10415, 513, 304, 507, 198, 277, 14, 826, 6741, 36, 4470, 1872, 8, 552, 8, 277, 14, 1715, 14, 8916, 430, 507, 198, 277, 14, 14932, 5069, 275, 10415, 513, 507, 198, 277, 14, 7832, 12776, 35, 310, 5069, 342, 421, 198, 318, 4205, 6741, 36, 4470, 1872, 8, 277, 12, 4426, 304, 507, 198, 83, 275, 291, 14, 1715, 14, 4470, 1160, 14, 1751, 507, 198, 277, 14, 3282, 14, 1410, 935, 1118, 14, 14733, 8, 277, 14, 908, 6741, 36, 4470, 1872, 8, 83, 14, 1213, 908, 14, 17186, 1062, 4426, 430, 507, 198, 277, 14, 3282, 14, 30969, 456, 1213, 14, 14733, 8, 277, 14, 908, 6741, 36, 4470, 1872, 8, 83, 14, 14348, 908, 14, 17186, 1062, 4426, 430, 421, 198, 318, 1475, 6741, 36, 4470, 1872, 8, 277, 12, 1978, 12, 4426, 304, 507, 198, 1160, 275, 1978, 14, 1814, 21506, 73, 401, 620, 8, 3885, 430, 507, 198, 1160, 275, 1978, 14, 1814, 21506, 84, 401, 291, 14, 6741, 34, 354, 9, 507, 198, 1160, 275, 1978, 14, 1814, 21506, 68, 401, 291, 14, 6741, 34, 12113, 9, 507, 198, 1160, 275, 1978, 14, 1814, 21506, 67, 401, 620, 8, 552, 8, 277, 14, 11316, 10375, 6393, 17, 430, 507, 198, 1160, 275, 1978, 14, 1814, 21506, 70, 401, 291, 14, 1210, 493, 9, 507, 198, 1160, 275, 1978, 14, 1814, 21506, 35, 401, 291, 14, 6741, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
shsingh/ansible
lib/ansible/module_utils/network/ios/facts/lag_interfaces/lag_interfaces.py
21
4252
# # -*- coding: utf-8 -*- # Copyright 2019 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) """ The ios lag_interfaces fact class It is in this file the configuration is collected from the device for a given resource, parsed, and the facts tree is populated based on the configuration. """ from __future__ import absolute_import, division, print_function __metaclass__ = type import re from copy import deepcopy from ansible.module_utils.network.common import utils from ansible.module_utils.network.ios.utils.utils import get_interface_type, normalize_interface from ansible.module_utils.network.ios.argspec.lag_interfaces.lag_interfaces import Lag_interfacesArgs class Lag_interfacesFacts(object): """ The ios_lag_interfaces fact class """ def __init__(self, module, subspec='config', options='options'): self._module = module self.argument_spec = Lag_interfacesArgs.argument_spec spec = deepcopy(self.argument_spec) if subspec: if options: facts_argument_spec = spec[subspec][options] else: facts_argument_spec = spec[subspec] else: facts_argument_spec = spec self.generated_spec = utils.generate_dict(facts_argument_spec) def populate_facts(self, connection, ansible_facts, data=None): """ Populate the facts for interfaces :param connection: the device connection :param ansible_facts: Facts dictionary :param data: previously collected conf :rtype: dictionary :returns: facts """ objs = [] if not data: data = connection.get('show running-config | section ^interface') # operate on a collection of resource x config = data.split('interface ') for conf in config: if conf: obj = self.render_config(self.generated_spec, conf) if obj: if not obj.get('members'): obj.update({'members': []}) objs.append(obj) # for appending members configured with same channel-group for each in range(len(objs)): if each < (len(objs) - 1): if objs[each]['name'] == objs[each + 1]['name']: objs[each]['members'].append(objs[each + 1]['members'][0]) del objs[each + 1] facts = {} if objs: facts['lag_interfaces'] = [] params = utils.validate_config(self.argument_spec, {'config': objs}) for cfg in params['config']: facts['lag_interfaces'].append(utils.remove_empties(cfg)) ansible_facts['ansible_network_resources'].update(facts) return ansible_facts def render_config(self, spec, conf): """ Render config as dictionary structure and delete keys from spec for null values :param spec: The facts tree, generated from the argspec :param conf: The configuration :rtype: dictionary :returns: The generated config """ config = deepcopy(spec) match = re.search(r'^(\S+)', conf) intf = match.group(1) if get_interface_type(intf) == 'unknown': return {} member_config = {} channel_group = utils.parse_conf_arg(conf, 'channel-group') if intf.startswith('Gi'): config['name'] = intf config['members'] = [] if channel_group: channel_group = channel_group.split(' ') id = channel_group[0] config['name'] = 'Port-channel{0}'.format(str(id)) if 'mode' in channel_group: mode = channel_group[2] member_config.update({'mode': mode}) if 'link' in channel_group: link = channel_group[2] member_config.update({'link': link}) if member_config.get('mode') or member_config.get('link'): member_config['member'] = normalize_interface(intf) config['members'].append(member_config) return utils.remove_empties(config)
gpl-3.0
[ 3, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 20312, 9572, 13002, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 199, 3, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 624, 199, 1918, 29516, 17891, 63, 7436, 10572, 1021, 199, 7940, 365, 315, 642, 570, 314, 2897, 365, 13736, 687, 314, 2243, 199, 509, 282, 1627, 2073, 12, 4565, 12, 436, 314, 9036, 3123, 365, 16460, 199, 6788, 641, 314, 2897, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 646, 295, 199, 504, 1331, 492, 14800, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 492, 3778, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 9207, 14, 1208, 14, 1208, 492, 664, 63, 3266, 63, 466, 12, 7666, 63, 3266, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 9207, 14, 15644, 14, 1823, 63, 7436, 14, 1823, 63, 7436, 492, 491, 643, 63, 7436, 6213, 421, 199, 533, 491, 643, 63, 7436, 25821, 8, 785, 304, 272, 408, 710, 29516, 63, 1823, 63, 7436, 10572, 1021, 272, 408, 339, 347, 636, 826, 721, 277, 12, 859, 12, 1007, 1650, 534, 888, 297, 1511, 534, 1419, 735, 267, 291, 423, 578, 275, 859, 267, 291, 14, 2094, 63, 1650, 275, 491, 643, 63, 7436, 6213, 14, 2094, 63, 1650, 267, 3158, 275, 14800, 8, 277, 14, 2094, 63, 1650, 9, 267, 340, 1007, 1650, 26, 288, 340, 1511, 26, 355, 9036, 63, 2094, 63, 1650, 275, 3158, 59, 954, 1650, 1527, 1419, 61, 288, 587, 26, 355, 9036, 63, 2094, 63, 1650, 275, 3158, 59, 954, 1650, 61, 267, 587, 26, 288, 9036, 63, 2094, 63, 1650, 275, 3158, 398, 291, 14, 10176, 63, 1650, 275, 3778, 14, 4208, 63, 807, 8, 5047, 63, 2094, 63, 1650, 9, 339, 347, 13904, 63, 5047, 8, 277, 12, 1950, 12, 3242, 63, 5047, 12, 666, 29, 403, 304, 267, 408, 31731, 314, 9036, 367, 8386, 267, 520, 635, 1950, 26, 314, 2243, 1950, 267, 520, 635, 3242, 63, 5047, 26, 481, 22282, 2600, 267, 520, 635, 666, 26, 10889, 13736, 3743, 267, 520, 4500, 26, 2600, 267, 520, 5808, 26, 9036, 267, 408, 267, 13474, 275, 942, 398, 340, 440, 666, 26, 288, 666, 275, 1950, 14, 362, 360, 2384, 3879, 13, 888, 1204, 3420, 7167, 3266, 358, 267, 327, 19218, 641, 282, 3245, 402, 2073, 671, 267, 1101, 275, 666, 14, 1294, 360, 3266, 5320, 267, 367, 3743, 315, 1101, 26, 288, 340, 3743, 26, 355, 1559, 275, 291, 14, 3352, 63, 888, 8, 277, 14, 10176, 63, 1650, 12, 3743, 9, 355, 340, 1559, 26, 490, 340, 440, 1559, 14, 362, 360, 6334, 735, 717, 1559, 14, 873, 3252, 6334, 356, 942, 1552, 490, 13474, 14, 740, 8, 1113, 9, 398, 327, 367, 24373, 7556, 7526, 543, 2011, 3623, 13, 923, 267, 367, 1924, 315, 1425, 8, 552, 8, 8718, 2298, 288, 340, 1924, 665, 334, 552, 8, 8718, 9, 446, 413, 304, 355, 340, 13474, 59, 10885, 2733, 354, 418, 508, 13474, 59, 10885, 435, 413, 2733, 354, 2565, 490, 13474, 59, 10885, 2733, 6334, 2278, 740, 8, 8718, 59, 10885, 435, 413, 2733, 6334, 3488, 16, 566, 490, 2150, 13474, 59, 10885, 435, 413, 61, 267, 9036, 275, 1052, 398, 340, 13474, 26, 288, 9036, 459, 1823, 63, 7436, 418, 275, 942, 288, 1862, 275, 3778, 14, 3502, 63, 888, 8, 277, 14, 2094, 63, 1650, 12, 791, 888, 356, 13474, 1552, 953, 367, 4810, 315, 1862, 459, 888, 2565, 355, 9036, 459, 1823, 63, 7436, 2278, 740, 8, 1208, 14, 2168, 63, 2109, 1417, 8, 4128, 430, 267, 3242, 63, 5047, 459, 4853, 63, 1200, 63, 4435, 2278, 873, 8, 5047, 9, 398, 372, 3242, 63, 5047, 339, 347, 3795, 63, 888, 8, 277, 12, 3158, 12, 3743, 304, 267, 408, 267, 17769, 1101, 465, 2600, 5523, 436, 3145, 2883, 881, 687, 3158, 367, 2973, 1338, 398, 520, 635, 3158, 26, 710, 9036, 3123, 12, 4046, 687, 314, 26632, 267, 520, 635, 3743, 26, 710, 2897, 267, 520, 4500, 26, 2600, 267, 520, 5808, 26, 710, 4046, 1101, 267, 408, 267, 1101, 275, 14800, 8, 1650, 9, 267, 1336, 275, 295, 14, 1733, 8, 82, 31344, 51, 14705, 3743, 9, 267, 20697, 275, 1336, 14, 923, 8, 17, 9, 398, 340, 664, 63, 3266, 63, 466, 8, 21100, 9, 508, 283, 5187, 356, 288, 372, 1052, 267, 3653, 63, 888, 275, 1052, 267, 3623, 63, 923, 275, 3778, 14, 1122, 63, 2190, 63, 1273, 8, 2190, 12, 283, 2775, 13, 923, 358, 267, 340, 20697, 14, 2460, 360, 30815, 735, 288, 1101, 459, 354, 418, 275, 20697, 288, 1101, 459, 6334, 418, 275, 942, 288, 340, 3623, 63, 923, 26, 355, 3623, 63, 923, 275, 3623, 63, 923, 14, 1294, 360, 5320, 355, 1305, 275, 3623, 63, 923, 59, 16, 61, 355, 1101, 459, 354, 418, 275, 283, 4313, 13, 2775, 91, 16, 5285, 908, 8, 495, 8, 344, 430, 355, 340, 283, 632, 7, 315, 3623, 63, 923, 26, 490, 818, 275, 3623, 63, 923, 59, 18, 61, 490, 3653, 63, 888, 14, 873, 3252, 632, 356, 818, 1552, 355, 340, 283, 1073, 7, 315, 3623, 63, 923, 26, 490, 2142, 275, 3623, 63, 923, 59, 18, 61, 490, 3653, 63, 888, 14, 873, 3252, 1073, 356, 2142, 1552, 288, 340, 3653, 63, 888, 14, 362, 360, 632, 358, 503, 3653, 63, 888, 14, 362, 360, 1073, 735, 355, 3653, 63, 888, 459, 1114, 418, 275, 7666, 63, 3266, 8, 21100, 9, 355, 1101, 459, 6334, 2278, 740, 8, 1114, 63, 888, 9, 398, 372, 3778, 14, 2168, 63, 2109, 1417, 8, 888, 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 ]
[ 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 20312, 9572, 13002, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 199, 3, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 624, 199, 1918, 29516, 17891, 63, 7436, 10572, 1021, 199, 7940, 365, 315, 642, 570, 314, 2897, 365, 13736, 687, 314, 2243, 199, 509, 282, 1627, 2073, 12, 4565, 12, 436, 314, 9036, 3123, 365, 16460, 199, 6788, 641, 314, 2897, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 646, 295, 199, 504, 1331, 492, 14800, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 492, 3778, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 9207, 14, 1208, 14, 1208, 492, 664, 63, 3266, 63, 466, 12, 7666, 63, 3266, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 9207, 14, 15644, 14, 1823, 63, 7436, 14, 1823, 63, 7436, 492, 491, 643, 63, 7436, 6213, 421, 199, 533, 491, 643, 63, 7436, 25821, 8, 785, 304, 272, 408, 710, 29516, 63, 1823, 63, 7436, 10572, 1021, 272, 408, 339, 347, 636, 826, 721, 277, 12, 859, 12, 1007, 1650, 534, 888, 297, 1511, 534, 1419, 735, 267, 291, 423, 578, 275, 859, 267, 291, 14, 2094, 63, 1650, 275, 491, 643, 63, 7436, 6213, 14, 2094, 63, 1650, 267, 3158, 275, 14800, 8, 277, 14, 2094, 63, 1650, 9, 267, 340, 1007, 1650, 26, 288, 340, 1511, 26, 355, 9036, 63, 2094, 63, 1650, 275, 3158, 59, 954, 1650, 1527, 1419, 61, 288, 587, 26, 355, 9036, 63, 2094, 63, 1650, 275, 3158, 59, 954, 1650, 61, 267, 587, 26, 288, 9036, 63, 2094, 63, 1650, 275, 3158, 398, 291, 14, 10176, 63, 1650, 275, 3778, 14, 4208, 63, 807, 8, 5047, 63, 2094, 63, 1650, 9, 339, 347, 13904, 63, 5047, 8, 277, 12, 1950, 12, 3242, 63, 5047, 12, 666, 29, 403, 304, 267, 408, 31731, 314, 9036, 367, 8386, 267, 520, 635, 1950, 26, 314, 2243, 1950, 267, 520, 635, 3242, 63, 5047, 26, 481, 22282, 2600, 267, 520, 635, 666, 26, 10889, 13736, 3743, 267, 520, 4500, 26, 2600, 267, 520, 5808, 26, 9036, 267, 408, 267, 13474, 275, 942, 398, 340, 440, 666, 26, 288, 666, 275, 1950, 14, 362, 360, 2384, 3879, 13, 888, 1204, 3420, 7167, 3266, 358, 267, 327, 19218, 641, 282, 3245, 402, 2073, 671, 267, 1101, 275, 666, 14, 1294, 360, 3266, 5320, 267, 367, 3743, 315, 1101, 26, 288, 340, 3743, 26, 355, 1559, 275, 291, 14, 3352, 63, 888, 8, 277, 14, 10176, 63, 1650, 12, 3743, 9, 355, 340, 1559, 26, 490, 340, 440, 1559, 14, 362, 360, 6334, 735, 717, 1559, 14, 873, 3252, 6334, 356, 942, 1552, 490, 13474, 14, 740, 8, 1113, 9, 398, 327, 367, 24373, 7556, 7526, 543, 2011, 3623, 13, 923, 267, 367, 1924, 315, 1425, 8, 552, 8, 8718, 2298, 288, 340, 1924, 665, 334, 552, 8, 8718, 9, 446, 413, 304, 355, 340, 13474, 59, 10885, 2733, 354, 418, 508, 13474, 59, 10885, 435, 413, 2733, 354, 2565, 490, 13474, 59, 10885, 2733, 6334, 2278, 740, 8, 8718, 59, 10885, 435, 413, 2733, 6334, 3488, 16, 566, 490, 2150, 13474, 59, 10885, 435, 413, 61, 267, 9036, 275, 1052, 398, 340, 13474, 26, 288, 9036, 459, 1823, 63, 7436, 418, 275, 942, 288, 1862, 275, 3778, 14, 3502, 63, 888, 8, 277, 14, 2094, 63, 1650, 12, 791, 888, 356, 13474, 1552, 953, 367, 4810, 315, 1862, 459, 888, 2565, 355, 9036, 459, 1823, 63, 7436, 2278, 740, 8, 1208, 14, 2168, 63, 2109, 1417, 8, 4128, 430, 267, 3242, 63, 5047, 459, 4853, 63, 1200, 63, 4435, 2278, 873, 8, 5047, 9, 398, 372, 3242, 63, 5047, 339, 347, 3795, 63, 888, 8, 277, 12, 3158, 12, 3743, 304, 267, 408, 267, 17769, 1101, 465, 2600, 5523, 436, 3145, 2883, 881, 687, 3158, 367, 2973, 1338, 398, 520, 635, 3158, 26, 710, 9036, 3123, 12, 4046, 687, 314, 26632, 267, 520, 635, 3743, 26, 710, 2897, 267, 520, 4500, 26, 2600, 267, 520, 5808, 26, 710, 4046, 1101, 267, 408, 267, 1101, 275, 14800, 8, 1650, 9, 267, 1336, 275, 295, 14, 1733, 8, 82, 31344, 51, 14705, 3743, 9, 267, 20697, 275, 1336, 14, 923, 8, 17, 9, 398, 340, 664, 63, 3266, 63, 466, 8, 21100, 9, 508, 283, 5187, 356, 288, 372, 1052, 267, 3653, 63, 888, 275, 1052, 267, 3623, 63, 923, 275, 3778, 14, 1122, 63, 2190, 63, 1273, 8, 2190, 12, 283, 2775, 13, 923, 358, 267, 340, 20697, 14, 2460, 360, 30815, 735, 288, 1101, 459, 354, 418, 275, 20697, 288, 1101, 459, 6334, 418, 275, 942, 288, 340, 3623, 63, 923, 26, 355, 3623, 63, 923, 275, 3623, 63, 923, 14, 1294, 360, 5320, 355, 1305, 275, 3623, 63, 923, 59, 16, 61, 355, 1101, 459, 354, 418, 275, 283, 4313, 13, 2775, 91, 16, 5285, 908, 8, 495, 8, 344, 430, 355, 340, 283, 632, 7, 315, 3623, 63, 923, 26, 490, 818, 275, 3623, 63, 923, 59, 18, 61, 490, 3653, 63, 888, 14, 873, 3252, 632, 356, 818, 1552, 355, 340, 283, 1073, 7, 315, 3623, 63, 923, 26, 490, 2142, 275, 3623, 63, 923, 59, 18, 61, 490, 3653, 63, 888, 14, 873, 3252, 1073, 356, 2142, 1552, 288, 340, 3653, 63, 888, 14, 362, 360, 632, 358, 503, 3653, 63, 888, 14, 362, 360, 1073, 735, 355, 3653, 63, 888, 459, 1114, 418, 275, 7666, 63, 3266, 8, 21100, 9, 355, 1101, 459, 6334, 2278, 740, 8, 1114, 63, 888, 9, 398, 372, 3778, 14, 2168, 63, 2109, 1417, 8, 888, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
40223112/2015cd_midterm
static/Brython3.1.0-20150301-090019/Lib/tarfile.py
728
88474
#!/usr/bin/env python3 #------------------------------------------------------------------- # tarfile.py #------------------------------------------------------------------- # Copyright (C) 2002 Lars Gustaebel <lars@gustaebel.de> # All rights reserved. # # 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. # """Read from and write to tar format archives. """ version = "0.9.0" __author__ = "Lars Gust\u00e4bel (lars@gustaebel.de)" __date__ = "$Date: 2011-02-25 17:42:01 +0200 (Fri, 25 Feb 2011) $" __cvsid__ = "$Id: tarfile.py 88586 2011-02-25 15:42:01Z marc-andre.lemburg $" __credits__ = "Gustavo Niemeyer, Niels Gust\u00e4bel, Richard Townsend." #--------- # Imports #--------- import sys import os import io import shutil import stat import time import struct import copy import re try: import grp, pwd except ImportError: grp = pwd = None # os.symlink on Windows prior to 6.0 raises NotImplementedError symlink_exception = (AttributeError, NotImplementedError) try: # WindowsError (1314) will be raised if the caller does not hold the # SeCreateSymbolicLinkPrivilege privilege symlink_exception += (WindowsError,) except NameError: pass # from tarfile import * __all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"] from builtins import open as _open # Since 'open' is TarFile.open #--------------------------------------------------------- # tar constants #--------------------------------------------------------- NUL = b"\0" # the null character BLOCKSIZE = 512 # length of processing blocks RECORDSIZE = BLOCKSIZE * 20 # length of records GNU_MAGIC = b"ustar \0" # magic gnu tar string POSIX_MAGIC = b"ustar\x0000" # magic posix tar string LENGTH_NAME = 100 # maximum length of a filename LENGTH_LINK = 100 # maximum length of a linkname LENGTH_PREFIX = 155 # maximum length of the prefix field REGTYPE = b"0" # regular file AREGTYPE = b"\0" # regular file LNKTYPE = b"1" # link (inside tarfile) SYMTYPE = b"2" # symbolic link CHRTYPE = b"3" # character special device BLKTYPE = b"4" # block special device DIRTYPE = b"5" # directory FIFOTYPE = b"6" # fifo special device CONTTYPE = b"7" # contiguous file GNUTYPE_LONGNAME = b"L" # GNU tar longname GNUTYPE_LONGLINK = b"K" # GNU tar longlink GNUTYPE_SPARSE = b"S" # GNU tar sparse file XHDTYPE = b"x" # POSIX.1-2001 extended header XGLTYPE = b"g" # POSIX.1-2001 global header SOLARIS_XHDTYPE = b"X" # Solaris extended header USTAR_FORMAT = 0 # POSIX.1-1988 (ustar) format GNU_FORMAT = 1 # GNU tar format PAX_FORMAT = 2 # POSIX.1-2001 (pax) format DEFAULT_FORMAT = GNU_FORMAT #--------------------------------------------------------- # tarfile constants #--------------------------------------------------------- # File types that tarfile supports: SUPPORTED_TYPES = (REGTYPE, AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, CONTTYPE, CHRTYPE, BLKTYPE, GNUTYPE_LONGNAME, GNUTYPE_LONGLINK, GNUTYPE_SPARSE) # File types that will be treated as a regular file. REGULAR_TYPES = (REGTYPE, AREGTYPE, CONTTYPE, GNUTYPE_SPARSE) # File types that are part of the GNU tar format. GNU_TYPES = (GNUTYPE_LONGNAME, GNUTYPE_LONGLINK, GNUTYPE_SPARSE) # Fields from a pax header that override a TarInfo attribute. PAX_FIELDS = ("path", "linkpath", "size", "mtime", "uid", "gid", "uname", "gname") # Fields from a pax header that are affected by hdrcharset. PAX_NAME_FIELDS = {"path", "linkpath", "uname", "gname"} # Fields in a pax header that are numbers, all other fields # are treated as strings. PAX_NUMBER_FIELDS = { "atime": float, "ctime": float, "mtime": float, "uid": int, "gid": int, "size": int } #--------------------------------------------------------- # Bits used in the mode field, values in octal. #--------------------------------------------------------- S_IFLNK = 0o120000 # symbolic link S_IFREG = 0o100000 # regular file S_IFBLK = 0o060000 # block device S_IFDIR = 0o040000 # directory S_IFCHR = 0o020000 # character device S_IFIFO = 0o010000 # fifo TSUID = 0o4000 # set UID on execution TSGID = 0o2000 # set GID on execution TSVTX = 0o1000 # reserved TUREAD = 0o400 # read by owner TUWRITE = 0o200 # write by owner TUEXEC = 0o100 # execute/search by owner TGREAD = 0o040 # read by group TGWRITE = 0o020 # write by group TGEXEC = 0o010 # execute/search by group TOREAD = 0o004 # read by other TOWRITE = 0o002 # write by other TOEXEC = 0o001 # execute/search by other #--------------------------------------------------------- # initialization #--------------------------------------------------------- if os.name in ("nt", "ce"): ENCODING = "utf-8" else: ENCODING = sys.getfilesystemencoding() #--------------------------------------------------------- # Some useful functions #--------------------------------------------------------- def stn(s, length, encoding, errors): """Convert a string to a null-terminated bytes object. """ s = s.encode(encoding, errors) return s[:length] + (length - len(s)) * NUL def nts(s, encoding, errors): """Convert a null-terminated bytes object to a string. """ p = s.find(b"\0") if p != -1: s = s[:p] return s.decode(encoding, errors) def nti(s): """Convert a number field to a python number. """ # There are two possible encodings for a number field, see # itn() below. if s[0] in (0o200, 0o377): n = 0 for i in range(len(s) - 1): n <<= 8 n += s[i + 1] if s[0] == 0o377: n = -(256 ** (len(s) - 1) - n) else: try: n = int(nts(s, "ascii", "strict") or "0", 8) except ValueError: raise InvalidHeaderError("invalid header") return n def itn(n, digits=8, format=DEFAULT_FORMAT): """Convert a python number to a number field. """ # POSIX 1003.1-1988 requires numbers to be encoded as a string of # octal digits followed by a null-byte, this allows values up to # (8**(digits-1))-1. GNU tar allows storing numbers greater than # that if necessary. A leading 0o200 or 0o377 byte indicate this # particular encoding, the following digits-1 bytes are a big-endian # base-256 representation. This allows values up to (256**(digits-1))-1. # A 0o200 byte indicates a positive number, a 0o377 byte a negative # number. if 0 <= n < 8 ** (digits - 1): s = bytes("%0*o" % (digits - 1, n), "ascii") + NUL elif format == GNU_FORMAT and -256 ** (digits - 1) <= n < 256 ** (digits - 1): if n >= 0: s = bytearray([0o200]) else: s = bytearray([0o377]) n = 256 ** digits + n for i in range(digits - 1): s.insert(1, n & 0o377) n >>= 8 else: raise ValueError("overflow in number field") return s def calc_chksums(buf): """Calculate the checksum for a member's header by summing up all characters except for the chksum field which is treated as if it was filled with spaces. According to the GNU tar sources, some tars (Sun and NeXT) calculate chksum with signed char, which will be different if there are chars in the buffer with the high bit set. So we calculate two checksums, unsigned and signed. """ unsigned_chksum = 256 + sum(struct.unpack_from("148B8x356B", buf)) signed_chksum = 256 + sum(struct.unpack_from("148b8x356b", buf)) return unsigned_chksum, signed_chksum def copyfileobj(src, dst, length=None): """Copy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content. """ if length == 0: return if length is None: shutil.copyfileobj(src, dst) return BUFSIZE = 16 * 1024 blocks, remainder = divmod(length, BUFSIZE) for b in range(blocks): buf = src.read(BUFSIZE) if len(buf) < BUFSIZE: raise IOError("end of file reached") dst.write(buf) if remainder != 0: buf = src.read(remainder) if len(buf) < remainder: raise IOError("end of file reached") dst.write(buf) return def filemode(mode): """Deprecated in this location; use stat.filemode.""" import warnings warnings.warn("deprecated in favor of stat.filemode", DeprecationWarning, 2) return stat.filemode(mode) class TarError(Exception): """Base exception.""" pass class ExtractError(TarError): """General exception for extract errors.""" pass class ReadError(TarError): """Exception for unreadable tar archives.""" pass class CompressionError(TarError): """Exception for unavailable compression methods.""" pass class StreamError(TarError): """Exception for unsupported operations on stream-like TarFiles.""" pass class HeaderError(TarError): """Base exception for header errors.""" pass class EmptyHeaderError(HeaderError): """Exception for empty headers.""" pass class TruncatedHeaderError(HeaderError): """Exception for truncated headers.""" pass class EOFHeaderError(HeaderError): """Exception for end of file headers.""" pass class InvalidHeaderError(HeaderError): """Exception for invalid headers.""" pass class SubsequentHeaderError(HeaderError): """Exception for missing and invalid extended headers.""" pass #--------------------------- # internal stream interface #--------------------------- class _LowLevelFile: """Low-level file object. Supports reading and writing. It is used instead of a regular file object for streaming access. """ def __init__(self, name, mode): mode = { "r": os.O_RDONLY, "w": os.O_WRONLY | os.O_CREAT | os.O_TRUNC, }[mode] if hasattr(os, "O_BINARY"): mode |= os.O_BINARY self.fd = os.open(name, mode, 0o666) def close(self): os.close(self.fd) def read(self, size): return os.read(self.fd, size) def write(self, s): os.write(self.fd, s) class _Stream: """Class that serves as an adapter between TarFile and a stream-like object. The stream-like object only needs to have a read() or write() method and is accessed blockwise. Use of gzip or bzip2 compression is possible. A stream-like object could be for example: sys.stdin, sys.stdout, a socket, a tape device etc. _Stream is intended to be used only internally. """ def __init__(self, name, mode, comptype, fileobj, bufsize): """Construct a _Stream object. """ self._extfileobj = True if fileobj is None: fileobj = _LowLevelFile(name, mode) self._extfileobj = False if comptype == '*': # Enable transparent compression detection for the # stream interface fileobj = _StreamProxy(fileobj) comptype = fileobj.getcomptype() self.name = name or "" self.mode = mode self.comptype = comptype self.fileobj = fileobj self.bufsize = bufsize self.buf = b"" self.pos = 0 self.closed = False try: if comptype == "gz": try: import zlib except ImportError: raise CompressionError("zlib module is not available") self.zlib = zlib self.crc = zlib.crc32(b"") if mode == "r": self._init_read_gz() self.exception = zlib.error else: self._init_write_gz() elif comptype == "bz2": try: import bz2 except ImportError: raise CompressionError("bz2 module is not available") if mode == "r": self.dbuf = b"" self.cmp = bz2.BZ2Decompressor() self.exception = IOError else: self.cmp = bz2.BZ2Compressor() elif comptype == "xz": try: import lzma except ImportError: raise CompressionError("lzma module is not available") if mode == "r": self.dbuf = b"" self.cmp = lzma.LZMADecompressor() self.exception = lzma.LZMAError else: self.cmp = lzma.LZMACompressor() elif comptype != "tar": raise CompressionError("unknown compression type %r" % comptype) except: if not self._extfileobj: self.fileobj.close() self.closed = True raise def __del__(self): if hasattr(self, "closed") and not self.closed: self.close() def _init_write_gz(self): """Initialize for writing with gzip compression. """ self.cmp = self.zlib.compressobj(9, self.zlib.DEFLATED, -self.zlib.MAX_WBITS, self.zlib.DEF_MEM_LEVEL, 0) timestamp = struct.pack("<L", int(time.time())) self.__write(b"\037\213\010\010" + timestamp + b"\002\377") if self.name.endswith(".gz"): self.name = self.name[:-3] # RFC1952 says we must use ISO-8859-1 for the FNAME field. self.__write(self.name.encode("iso-8859-1", "replace") + NUL) def write(self, s): """Write string s to the stream. """ if self.comptype == "gz": self.crc = self.zlib.crc32(s, self.crc) self.pos += len(s) if self.comptype != "tar": s = self.cmp.compress(s) self.__write(s) def __write(self, s): """Write string s to the stream if a whole new block is ready to be written. """ self.buf += s while len(self.buf) > self.bufsize: self.fileobj.write(self.buf[:self.bufsize]) self.buf = self.buf[self.bufsize:] def close(self): """Close the _Stream object. No operation should be done on it afterwards. """ if self.closed: return if self.mode == "w" and self.comptype != "tar": self.buf += self.cmp.flush() if self.mode == "w" and self.buf: self.fileobj.write(self.buf) self.buf = b"" if self.comptype == "gz": # The native zlib crc is an unsigned 32-bit integer, but # the Python wrapper implicitly casts that to a signed C # long. So, on a 32-bit box self.crc may "look negative", # while the same crc on a 64-bit box may "look positive". # To avoid irksome warnings from the `struct` module, force # it to look positive on all boxes. self.fileobj.write(struct.pack("<L", self.crc & 0xffffffff)) self.fileobj.write(struct.pack("<L", self.pos & 0xffffFFFF)) if not self._extfileobj: self.fileobj.close() self.closed = True def _init_read_gz(self): """Initialize for reading a gzip compressed fileobj. """ self.cmp = self.zlib.decompressobj(-self.zlib.MAX_WBITS) self.dbuf = b"" # taken from gzip.GzipFile with some alterations if self.__read(2) != b"\037\213": raise ReadError("not a gzip file") if self.__read(1) != b"\010": raise CompressionError("unsupported compression method") flag = ord(self.__read(1)) self.__read(6) if flag & 4: xlen = ord(self.__read(1)) + 256 * ord(self.__read(1)) self.read(xlen) if flag & 8: while True: s = self.__read(1) if not s or s == NUL: break if flag & 16: while True: s = self.__read(1) if not s or s == NUL: break if flag & 2: self.__read(2) def tell(self): """Return the stream's file pointer position. """ return self.pos def seek(self, pos=0): """Set the stream's file pointer to pos. Negative seeking is forbidden. """ if pos - self.pos >= 0: blocks, remainder = divmod(pos - self.pos, self.bufsize) for i in range(blocks): self.read(self.bufsize) self.read(remainder) else: raise StreamError("seeking backwards is not allowed") return self.pos def read(self, size=None): """Return the next size number of bytes from the stream. If size is not defined, return all bytes of the stream up to EOF. """ if size is None: t = [] while True: buf = self._read(self.bufsize) if not buf: break t.append(buf) buf = "".join(t) else: buf = self._read(size) self.pos += len(buf) return buf def _read(self, size): """Return size bytes from the stream. """ if self.comptype == "tar": return self.__read(size) c = len(self.dbuf) while c < size: buf = self.__read(self.bufsize) if not buf: break try: buf = self.cmp.decompress(buf) except self.exception: raise ReadError("invalid compressed data") self.dbuf += buf c += len(buf) buf = self.dbuf[:size] self.dbuf = self.dbuf[size:] return buf def __read(self, size): """Return size bytes from stream. If internal buffer is empty, read another block from the stream. """ c = len(self.buf) while c < size: buf = self.fileobj.read(self.bufsize) if not buf: break self.buf += buf c += len(buf) buf = self.buf[:size] self.buf = self.buf[size:] return buf # class _Stream class _StreamProxy(object): """Small proxy class that enables transparent compression detection for the Stream interface (mode 'r|*'). """ def __init__(self, fileobj): self.fileobj = fileobj self.buf = self.fileobj.read(BLOCKSIZE) def read(self, size): self.read = self.fileobj.read return self.buf def getcomptype(self): if self.buf.startswith(b"\x1f\x8b\x08"): return "gz" elif self.buf[0:3] == b"BZh" and self.buf[4:10] == b"1AY&SY": return "bz2" elif self.buf.startswith((b"\x5d\x00\x00\x80", b"\xfd7zXZ")): return "xz" else: return "tar" def close(self): self.fileobj.close() # class StreamProxy #------------------------ # Extraction file object #------------------------ class _FileInFile(object): """A thin wrapper around an existing file object that provides a part of its data as an individual file object. """ def __init__(self, fileobj, offset, size, blockinfo=None): self.fileobj = fileobj self.offset = offset self.size = size self.position = 0 self.name = getattr(fileobj, "name", None) self.closed = False if blockinfo is None: blockinfo = [(0, size)] # Construct a map with data and zero blocks. self.map_index = 0 self.map = [] lastpos = 0 realpos = self.offset for offset, size in blockinfo: if offset > lastpos: self.map.append((False, lastpos, offset, None)) self.map.append((True, offset, offset + size, realpos)) realpos += size lastpos = offset + size if lastpos < self.size: self.map.append((False, lastpos, self.size, None)) def flush(self): pass def readable(self): return True def writable(self): return False def seekable(self): return self.fileobj.seekable() def tell(self): """Return the current file position. """ return self.position def seek(self, position, whence=io.SEEK_SET): """Seek to a position in the file. """ if whence == io.SEEK_SET: self.position = min(max(position, 0), self.size) elif whence == io.SEEK_CUR: if position < 0: self.position = max(self.position + position, 0) else: self.position = min(self.position + position, self.size) elif whence == io.SEEK_END: self.position = max(min(self.size + position, self.size), 0) else: raise ValueError("Invalid argument") return self.position def read(self, size=None): """Read data from the file. """ if size is None: size = self.size - self.position else: size = min(size, self.size - self.position) buf = b"" while size > 0: while True: data, start, stop, offset = self.map[self.map_index] if start <= self.position < stop: break else: self.map_index += 1 if self.map_index == len(self.map): self.map_index = 0 length = min(size, stop - self.position) if data: self.fileobj.seek(offset + (self.position - start)) buf += self.fileobj.read(length) else: buf += NUL * length size -= length self.position += length return buf def readinto(self, b): buf = self.read(len(b)) b[:len(buf)] = buf return len(buf) def close(self): self.closed = True #class _FileInFile class ExFileObject(io.BufferedReader): def __init__(self, tarfile, tarinfo): fileobj = _FileInFile(tarfile.fileobj, tarinfo.offset_data, tarinfo.size, tarinfo.sparse) super().__init__(fileobj) #class ExFileObject #------------------ # Exported Classes #------------------ class TarInfo(object): """Informational class which holds the details about an archive member given by a tar header block. TarInfo objects are returned by TarFile.getmember(), TarFile.getmembers() and TarFile.gettarinfo() and are usually created internally. """ __slots__ = ("name", "mode", "uid", "gid", "size", "mtime", "chksum", "type", "linkname", "uname", "gname", "devmajor", "devminor", "offset", "offset_data", "pax_headers", "sparse", "tarfile", "_sparse_structs", "_link_target") def __init__(self, name=""): """Construct a TarInfo object. name is the optional name of the member. """ self.name = name # member name self.mode = 0o644 # file permissions self.uid = 0 # user id self.gid = 0 # group id self.size = 0 # file size self.mtime = 0 # modification time self.chksum = 0 # header checksum self.type = REGTYPE # member type self.linkname = "" # link name self.uname = "" # user name self.gname = "" # group name self.devmajor = 0 # device major number self.devminor = 0 # device minor number self.offset = 0 # the tar header starts here self.offset_data = 0 # the file's data starts here self.sparse = None # sparse member information self.pax_headers = {} # pax header information # In pax headers the "name" and "linkname" field are called # "path" and "linkpath". def _getpath(self): return self.name def _setpath(self, name): self.name = name path = property(_getpath, _setpath) def _getlinkpath(self): return self.linkname def _setlinkpath(self, linkname): self.linkname = linkname linkpath = property(_getlinkpath, _setlinkpath) def __repr__(self): return "<%s %r at %#x>" % (self.__class__.__name__,self.name,id(self)) def get_info(self): """Return the TarInfo's attributes as a dictionary. """ info = { "name": self.name, "mode": self.mode & 0o7777, "uid": self.uid, "gid": self.gid, "size": self.size, "mtime": self.mtime, "chksum": self.chksum, "type": self.type, "linkname": self.linkname, "uname": self.uname, "gname": self.gname, "devmajor": self.devmajor, "devminor": self.devminor } if info["type"] == DIRTYPE and not info["name"].endswith("/"): info["name"] += "/" return info def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape"): """Return a tar header as a string of 512 byte blocks. """ info = self.get_info() if format == USTAR_FORMAT: return self.create_ustar_header(info, encoding, errors) elif format == GNU_FORMAT: return self.create_gnu_header(info, encoding, errors) elif format == PAX_FORMAT: return self.create_pax_header(info, encoding) else: raise ValueError("invalid format") def create_ustar_header(self, info, encoding, errors): """Return the object as a ustar header block. """ info["magic"] = POSIX_MAGIC if len(info["linkname"]) > LENGTH_LINK: raise ValueError("linkname is too long") if len(info["name"]) > LENGTH_NAME: info["prefix"], info["name"] = self._posix_split_name(info["name"]) return self._create_header(info, USTAR_FORMAT, encoding, errors) def create_gnu_header(self, info, encoding, errors): """Return the object as a GNU header block sequence. """ info["magic"] = GNU_MAGIC buf = b"" if len(info["linkname"]) > LENGTH_LINK: buf += self._create_gnu_long_header(info["linkname"], GNUTYPE_LONGLINK, encoding, errors) if len(info["name"]) > LENGTH_NAME: buf += self._create_gnu_long_header(info["name"], GNUTYPE_LONGNAME, encoding, errors) return buf + self._create_header(info, GNU_FORMAT, encoding, errors) def create_pax_header(self, info, encoding): """Return the object as a ustar header block. If it cannot be represented this way, prepend a pax extended header sequence with supplement information. """ info["magic"] = POSIX_MAGIC pax_headers = self.pax_headers.copy() # Test string fields for values that exceed the field length or cannot # be represented in ASCII encoding. for name, hname, length in ( ("name", "path", LENGTH_NAME), ("linkname", "linkpath", LENGTH_LINK), ("uname", "uname", 32), ("gname", "gname", 32)): if hname in pax_headers: # The pax header has priority. continue # Try to encode the string as ASCII. try: info[name].encode("ascii", "strict") except UnicodeEncodeError: pax_headers[hname] = info[name] continue if len(info[name]) > length: pax_headers[hname] = info[name] # Test number fields for values that exceed the field limit or values # that like to be stored as float. for name, digits in (("uid", 8), ("gid", 8), ("size", 12), ("mtime", 12)): if name in pax_headers: # The pax header has priority. Avoid overflow. info[name] = 0 continue val = info[name] if not 0 <= val < 8 ** (digits - 1) or isinstance(val, float): pax_headers[name] = str(val) info[name] = 0 # Create a pax extended header if necessary. if pax_headers: buf = self._create_pax_generic_header(pax_headers, XHDTYPE, encoding) else: buf = b"" return buf + self._create_header(info, USTAR_FORMAT, "ascii", "replace") @classmethod def create_pax_global_header(cls, pax_headers): """Return the object as a pax global header block sequence. """ return cls._create_pax_generic_header(pax_headers, XGLTYPE, "utf-8") def _posix_split_name(self, name): """Split a name longer than 100 chars into a prefix and a name part. """ prefix = name[:LENGTH_PREFIX + 1] while prefix and prefix[-1] != "/": prefix = prefix[:-1] name = name[len(prefix):] prefix = prefix[:-1] if not prefix or len(name) > LENGTH_NAME: raise ValueError("name is too long") return prefix, name @staticmethod def _create_header(info, format, encoding, errors): """Return a header block. info is a dictionary with file information, format must be one of the *_FORMAT constants. """ parts = [ stn(info.get("name", ""), 100, encoding, errors), itn(info.get("mode", 0) & 0o7777, 8, format), itn(info.get("uid", 0), 8, format), itn(info.get("gid", 0), 8, format), itn(info.get("size", 0), 12, format), itn(info.get("mtime", 0), 12, format), b" ", # checksum field info.get("type", REGTYPE), stn(info.get("linkname", ""), 100, encoding, errors), info.get("magic", POSIX_MAGIC), stn(info.get("uname", ""), 32, encoding, errors), stn(info.get("gname", ""), 32, encoding, errors), itn(info.get("devmajor", 0), 8, format), itn(info.get("devminor", 0), 8, format), stn(info.get("prefix", ""), 155, encoding, errors) ] buf = struct.pack("%ds" % BLOCKSIZE, b"".join(parts)) chksum = calc_chksums(buf[-BLOCKSIZE:])[0] buf = buf[:-364] + bytes("%06o\0" % chksum, "ascii") + buf[-357:] return buf @staticmethod def _create_payload(payload): """Return the string payload filled with zero bytes up to the next 512 byte border. """ blocks, remainder = divmod(len(payload), BLOCKSIZE) if remainder > 0: payload += (BLOCKSIZE - remainder) * NUL return payload @classmethod def _create_gnu_long_header(cls, name, type, encoding, errors): """Return a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence for name. """ name = name.encode(encoding, errors) + NUL info = {} info["name"] = "././@LongLink" info["type"] = type info["size"] = len(name) info["magic"] = GNU_MAGIC # create extended header + name blocks. return cls._create_header(info, USTAR_FORMAT, encoding, errors) + \ cls._create_payload(name) @classmethod def _create_pax_generic_header(cls, pax_headers, type, encoding): """Return a POSIX.1-2008 extended or global header sequence that contains a list of keyword, value pairs. The values must be strings. """ # Check if one of the fields contains surrogate characters and thereby # forces hdrcharset=BINARY, see _proc_pax() for more information. binary = False for keyword, value in pax_headers.items(): try: value.encode("utf-8", "strict") except UnicodeEncodeError: binary = True break records = b"" if binary: # Put the hdrcharset field at the beginning of the header. records += b"21 hdrcharset=BINARY\n" for keyword, value in pax_headers.items(): keyword = keyword.encode("utf-8") if binary: # Try to restore the original byte representation of `value'. # Needless to say, that the encoding must match the string. value = value.encode(encoding, "surrogateescape") else: value = value.encode("utf-8") l = len(keyword) + len(value) + 3 # ' ' + '=' + '\n' n = p = 0 while True: n = l + len(str(p)) if n == p: break p = n records += bytes(str(p), "ascii") + b" " + keyword + b"=" + value + b"\n" # We use a hardcoded "././@PaxHeader" name like star does # instead of the one that POSIX recommends. info = {} info["name"] = "././@PaxHeader" info["type"] = type info["size"] = len(records) info["magic"] = POSIX_MAGIC # Create pax header + record blocks. return cls._create_header(info, USTAR_FORMAT, "ascii", "replace") + \ cls._create_payload(records) @classmethod def frombuf(cls, buf, encoding, errors): """Construct a TarInfo object from a 512 byte bytes object. """ if len(buf) == 0: raise EmptyHeaderError("empty header") if len(buf) != BLOCKSIZE: raise TruncatedHeaderError("truncated header") if buf.count(NUL) == BLOCKSIZE: raise EOFHeaderError("end of file header") chksum = nti(buf[148:156]) if chksum not in calc_chksums(buf): raise InvalidHeaderError("bad checksum") obj = cls() obj.name = nts(buf[0:100], encoding, errors) obj.mode = nti(buf[100:108]) obj.uid = nti(buf[108:116]) obj.gid = nti(buf[116:124]) obj.size = nti(buf[124:136]) obj.mtime = nti(buf[136:148]) obj.chksum = chksum obj.type = buf[156:157] obj.linkname = nts(buf[157:257], encoding, errors) obj.uname = nts(buf[265:297], encoding, errors) obj.gname = nts(buf[297:329], encoding, errors) obj.devmajor = nti(buf[329:337]) obj.devminor = nti(buf[337:345]) prefix = nts(buf[345:500], encoding, errors) # Old V7 tar format represents a directory as a regular # file with a trailing slash. if obj.type == AREGTYPE and obj.name.endswith("/"): obj.type = DIRTYPE # The old GNU sparse format occupies some of the unused # space in the buffer for up to 4 sparse structures. # Save the them for later processing in _proc_sparse(). if obj.type == GNUTYPE_SPARSE: pos = 386 structs = [] for i in range(4): try: offset = nti(buf[pos:pos + 12]) numbytes = nti(buf[pos + 12:pos + 24]) except ValueError: break structs.append((offset, numbytes)) pos += 24 isextended = bool(buf[482]) origsize = nti(buf[483:495]) obj._sparse_structs = (structs, isextended, origsize) # Remove redundant slashes from directories. if obj.isdir(): obj.name = obj.name.rstrip("/") # Reconstruct a ustar longname. if prefix and obj.type not in GNU_TYPES: obj.name = prefix + "/" + obj.name return obj @classmethod def fromtarfile(cls, tarfile): """Return the next TarInfo object from TarFile object tarfile. """ buf = tarfile.fileobj.read(BLOCKSIZE) obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors) obj.offset = tarfile.fileobj.tell() - BLOCKSIZE return obj._proc_member(tarfile) #-------------------------------------------------------------------------- # The following are methods that are called depending on the type of a # member. The entry point is _proc_member() which can be overridden in a # subclass to add custom _proc_*() methods. A _proc_*() method MUST # implement the following # operations: # 1. Set self.offset_data to the position where the data blocks begin, # if there is data that follows. # 2. Set tarfile.offset to the position where the next member's header will # begin. # 3. Return self or another valid TarInfo object. def _proc_member(self, tarfile): """Choose the right processing method depending on the type and call it. """ if self.type in (GNUTYPE_LONGNAME, GNUTYPE_LONGLINK): return self._proc_gnulong(tarfile) elif self.type == GNUTYPE_SPARSE: return self._proc_sparse(tarfile) elif self.type in (XHDTYPE, XGLTYPE, SOLARIS_XHDTYPE): return self._proc_pax(tarfile) else: return self._proc_builtin(tarfile) def _proc_builtin(self, tarfile): """Process a builtin type or an unknown type which will be treated as a regular file. """ self.offset_data = tarfile.fileobj.tell() offset = self.offset_data if self.isreg() or self.type not in SUPPORTED_TYPES: # Skip the following data blocks. offset += self._block(self.size) tarfile.offset = offset # Patch the TarInfo object with saved global # header information. self._apply_pax_info(tarfile.pax_headers, tarfile.encoding, tarfile.errors) return self def _proc_gnulong(self, tarfile): """Process the blocks that hold a GNU longname or longlink member. """ buf = tarfile.fileobj.read(self._block(self.size)) # Fetch the next header and process it. try: next = self.fromtarfile(tarfile) except HeaderError: raise SubsequentHeaderError("missing or bad subsequent header") # Patch the TarInfo object from the next header with # the longname information. next.offset = self.offset if self.type == GNUTYPE_LONGNAME: next.name = nts(buf, tarfile.encoding, tarfile.errors) elif self.type == GNUTYPE_LONGLINK: next.linkname = nts(buf, tarfile.encoding, tarfile.errors) return next def _proc_sparse(self, tarfile): """Process a GNU sparse header plus extra headers. """ # We already collected some sparse structures in frombuf(). structs, isextended, origsize = self._sparse_structs del self._sparse_structs # Collect sparse structures from extended header blocks. while isextended: buf = tarfile.fileobj.read(BLOCKSIZE) pos = 0 for i in range(21): try: offset = nti(buf[pos:pos + 12]) numbytes = nti(buf[pos + 12:pos + 24]) except ValueError: break if offset and numbytes: structs.append((offset, numbytes)) pos += 24 isextended = bool(buf[504]) self.sparse = structs self.offset_data = tarfile.fileobj.tell() tarfile.offset = self.offset_data + self._block(self.size) self.size = origsize return self def _proc_pax(self, tarfile): """Process an extended or global header as described in POSIX.1-2008. """ # Read the header information. buf = tarfile.fileobj.read(self._block(self.size)) # A pax header stores supplemental information for either # the following file (extended) or all following files # (global). if self.type == XGLTYPE: pax_headers = tarfile.pax_headers else: pax_headers = tarfile.pax_headers.copy() # Check if the pax header contains a hdrcharset field. This tells us # the encoding of the path, linkpath, uname and gname fields. Normally, # these fields are UTF-8 encoded but since POSIX.1-2008 tar # implementations are allowed to store them as raw binary strings if # the translation to UTF-8 fails. match = re.search(br"\d+ hdrcharset=([^\n]+)\n", buf) if match is not None: pax_headers["hdrcharset"] = match.group(1).decode("utf-8") # For the time being, we don't care about anything other than "BINARY". # The only other value that is currently allowed by the standard is # "ISO-IR 10646 2000 UTF-8" in other words UTF-8. hdrcharset = pax_headers.get("hdrcharset") if hdrcharset == "BINARY": encoding = tarfile.encoding else: encoding = "utf-8" # Parse pax header information. A record looks like that: # "%d %s=%s\n" % (length, keyword, value). length is the size # of the complete record including the length field itself and # the newline. keyword and value are both UTF-8 encoded strings. regex = re.compile(br"(\d+) ([^=]+)=") pos = 0 while True: match = regex.match(buf, pos) if not match: break length, keyword = match.groups() length = int(length) value = buf[match.end(2) + 1:match.start(1) + length - 1] # Normally, we could just use "utf-8" as the encoding and "strict" # as the error handler, but we better not take the risk. For # example, GNU tar <= 1.23 is known to store filenames it cannot # translate to UTF-8 as raw strings (unfortunately without a # hdrcharset=BINARY header). # We first try the strict standard encoding, and if that fails we # fall back on the user's encoding and error handler. keyword = self._decode_pax_field(keyword, "utf-8", "utf-8", tarfile.errors) if keyword in PAX_NAME_FIELDS: value = self._decode_pax_field(value, encoding, tarfile.encoding, tarfile.errors) else: value = self._decode_pax_field(value, "utf-8", "utf-8", tarfile.errors) pax_headers[keyword] = value pos += length # Fetch the next header. try: next = self.fromtarfile(tarfile) except HeaderError: raise SubsequentHeaderError("missing or bad subsequent header") # Process GNU sparse information. if "GNU.sparse.map" in pax_headers: # GNU extended sparse format version 0.1. self._proc_gnusparse_01(next, pax_headers) elif "GNU.sparse.size" in pax_headers: # GNU extended sparse format version 0.0. self._proc_gnusparse_00(next, pax_headers, buf) elif pax_headers.get("GNU.sparse.major") == "1" and pax_headers.get("GNU.sparse.minor") == "0": # GNU extended sparse format version 1.0. self._proc_gnusparse_10(next, pax_headers, tarfile) if self.type in (XHDTYPE, SOLARIS_XHDTYPE): # Patch the TarInfo object with the extended header info. next._apply_pax_info(pax_headers, tarfile.encoding, tarfile.errors) next.offset = self.offset if "size" in pax_headers: # If the extended header replaces the size field, # we need to recalculate the offset where the next # header starts. offset = next.offset_data if next.isreg() or next.type not in SUPPORTED_TYPES: offset += next._block(next.size) tarfile.offset = offset return next def _proc_gnusparse_00(self, next, pax_headers, buf): """Process a GNU tar extended sparse header, version 0.0. """ offsets = [] for match in re.finditer(br"\d+ GNU.sparse.offset=(\d+)\n", buf): offsets.append(int(match.group(1))) numbytes = [] for match in re.finditer(br"\d+ GNU.sparse.numbytes=(\d+)\n", buf): numbytes.append(int(match.group(1))) next.sparse = list(zip(offsets, numbytes)) def _proc_gnusparse_01(self, next, pax_headers): """Process a GNU tar extended sparse header, version 0.1. """ sparse = [int(x) for x in pax_headers["GNU.sparse.map"].split(",")] next.sparse = list(zip(sparse[::2], sparse[1::2])) def _proc_gnusparse_10(self, next, pax_headers, tarfile): """Process a GNU tar extended sparse header, version 1.0. """ fields = None sparse = [] buf = tarfile.fileobj.read(BLOCKSIZE) fields, buf = buf.split(b"\n", 1) fields = int(fields) while len(sparse) < fields * 2: if b"\n" not in buf: buf += tarfile.fileobj.read(BLOCKSIZE) number, buf = buf.split(b"\n", 1) sparse.append(int(number)) next.offset_data = tarfile.fileobj.tell() next.sparse = list(zip(sparse[::2], sparse[1::2])) def _apply_pax_info(self, pax_headers, encoding, errors): """Replace fields with supplemental information from a previous pax extended or global header. """ for keyword, value in pax_headers.items(): if keyword == "GNU.sparse.name": setattr(self, "path", value) elif keyword == "GNU.sparse.size": setattr(self, "size", int(value)) elif keyword == "GNU.sparse.realsize": setattr(self, "size", int(value)) elif keyword in PAX_FIELDS: if keyword in PAX_NUMBER_FIELDS: try: value = PAX_NUMBER_FIELDS[keyword](value) except ValueError: value = 0 if keyword == "path": value = value.rstrip("/") setattr(self, keyword, value) self.pax_headers = pax_headers.copy() def _decode_pax_field(self, value, encoding, fallback_encoding, fallback_errors): """Decode a single field from a pax record. """ try: return value.decode(encoding, "strict") except UnicodeDecodeError: return value.decode(fallback_encoding, fallback_errors) def _block(self, count): """Round up a byte count by BLOCKSIZE and return it, e.g. _block(834) => 1024. """ blocks, remainder = divmod(count, BLOCKSIZE) if remainder: blocks += 1 return blocks * BLOCKSIZE def isreg(self): return self.type in REGULAR_TYPES def isfile(self): return self.isreg() def isdir(self): return self.type == DIRTYPE def issym(self): return self.type == SYMTYPE def islnk(self): return self.type == LNKTYPE def ischr(self): return self.type == CHRTYPE def isblk(self): return self.type == BLKTYPE def isfifo(self): return self.type == FIFOTYPE def issparse(self): return self.sparse is not None def isdev(self): return self.type in (CHRTYPE, BLKTYPE, FIFOTYPE) # class TarInfo class TarFile(object): """The TarFile Class provides an interface to tar archives. """ debug = 0 # May be set from 0 (no msgs) to 3 (all msgs) dereference = False # If true, add content of linked file to the # tar file, else the link. ignore_zeros = False # If true, skips empty or invalid blocks and # continues processing. errorlevel = 1 # If 0, fatal errors only appear in debug # messages (if debug >= 0). If > 0, errors # are passed to the caller as exceptions. format = DEFAULT_FORMAT # The format to use when creating an archive. encoding = ENCODING # Encoding for 8-bit character strings. errors = None # Error handler for unicode conversion. tarinfo = TarInfo # The default TarInfo class to use. fileobject = ExFileObject # The file-object for extractfile(). def __init__(self, name=None, mode="r", fileobj=None, format=None, tarinfo=None, dereference=None, ignore_zeros=None, encoding=None, errors="surrogateescape", pax_headers=None, debug=None, errorlevel=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for reading or writing data. If it can be determined, `mode' is overridden by `fileobj's mode. `fileobj' is not closed, when TarFile is closed. """ if len(mode) > 1 or mode not in "raw": raise ValueError("mode must be 'r', 'a' or 'w'") self.mode = mode self._mode = {"r": "rb", "a": "r+b", "w": "wb"}[mode] if not fileobj: if self.mode == "a" and not os.path.exists(name): # Create nonexistent files in append mode. self.mode = "w" self._mode = "wb" fileobj = bltn_open(name, self._mode) self._extfileobj = False else: if name is None and hasattr(fileobj, "name"): name = fileobj.name if hasattr(fileobj, "mode"): self._mode = fileobj.mode self._extfileobj = True self.name = os.path.abspath(name) if name else None self.fileobj = fileobj # Init attributes. if format is not None: self.format = format if tarinfo is not None: self.tarinfo = tarinfo if dereference is not None: self.dereference = dereference if ignore_zeros is not None: self.ignore_zeros = ignore_zeros if encoding is not None: self.encoding = encoding self.errors = errors if pax_headers is not None and self.format == PAX_FORMAT: self.pax_headers = pax_headers else: self.pax_headers = {} if debug is not None: self.debug = debug if errorlevel is not None: self.errorlevel = errorlevel # Init datastructures. self.closed = False self.members = [] # list of members as TarInfo objects self._loaded = False # flag if all members have been read self.offset = self.fileobj.tell() # current position in the archive file self.inodes = {} # dictionary caching the inodes of # archive members already added try: if self.mode == "r": self.firstmember = None self.firstmember = self.next() if self.mode == "a": # Move to the end of the archive, # before the first empty block. while True: self.fileobj.seek(self.offset) try: tarinfo = self.tarinfo.fromtarfile(self) self.members.append(tarinfo) except EOFHeaderError: self.fileobj.seek(self.offset) break except HeaderError as e: raise ReadError(str(e)) if self.mode in "aw": self._loaded = True if self.pax_headers: buf = self.tarinfo.create_pax_global_header(self.pax_headers.copy()) self.fileobj.write(buf) self.offset += len(buf) except: if not self._extfileobj: self.fileobj.close() self.closed = True raise #-------------------------------------------------------------------------- # Below are the classmethods which act as alternate constructors to the # TarFile class. The open() method is the only one that is needed for # public use; it is the "super"-constructor and is able to select an # adequate "sub"-constructor for a particular compression using the mapping # from OPEN_METH. # # This concept allows one to subclass TarFile without losing the comfort of # the super-constructor. A sub-constructor is registered and made available # by adding it to the mapping in OPEN_METH. @classmethod def open(cls, name=None, mode="r", fileobj=None, bufsize=RECORDSIZE, **kwargs): """Open a tar archive for reading, writing or appending. Return an appropriate TarFile class. mode: 'r' or 'r:*' open for reading with transparent compression 'r:' open for reading exclusively uncompressed 'r:gz' open for reading with gzip compression 'r:bz2' open for reading with bzip2 compression 'r:xz' open for reading with lzma compression 'a' or 'a:' open for appending, creating the file if necessary 'w' or 'w:' open for writing without compression 'w:gz' open for writing with gzip compression 'w:bz2' open for writing with bzip2 compression 'w:xz' open for writing with lzma compression 'r|*' open a stream of tar blocks with transparent compression 'r|' open an uncompressed stream of tar blocks for reading 'r|gz' open a gzip compressed stream of tar blocks 'r|bz2' open a bzip2 compressed stream of tar blocks 'r|xz' open an lzma compressed stream of tar blocks 'w|' open an uncompressed stream for writing 'w|gz' open a gzip compressed stream for writing 'w|bz2' open a bzip2 compressed stream for writing 'w|xz' open an lzma compressed stream for writing """ if not name and not fileobj: raise ValueError("nothing to open") if mode in ("r", "r:*"): # Find out which *open() is appropriate for opening the file. for comptype in cls.OPEN_METH: func = getattr(cls, cls.OPEN_METH[comptype]) if fileobj is not None: saved_pos = fileobj.tell() try: return func(name, "r", fileobj, **kwargs) except (ReadError, CompressionError) as e: if fileobj is not None: fileobj.seek(saved_pos) continue raise ReadError("file could not be opened successfully") elif ":" in mode: filemode, comptype = mode.split(":", 1) filemode = filemode or "r" comptype = comptype or "tar" # Select the *open() function according to # given compression. if comptype in cls.OPEN_METH: func = getattr(cls, cls.OPEN_METH[comptype]) else: raise CompressionError("unknown compression type %r" % comptype) return func(name, filemode, fileobj, **kwargs) elif "|" in mode: filemode, comptype = mode.split("|", 1) filemode = filemode or "r" comptype = comptype or "tar" if filemode not in "rw": raise ValueError("mode must be 'r' or 'w'") stream = _Stream(name, filemode, comptype, fileobj, bufsize) try: t = cls(name, filemode, stream, **kwargs) except: stream.close() raise t._extfileobj = False return t elif mode in "aw": return cls.taropen(name, mode, fileobj, **kwargs) raise ValueError("undiscernible mode") @classmethod def taropen(cls, name, mode="r", fileobj=None, **kwargs): """Open uncompressed tar archive name for reading or writing. """ if len(mode) > 1 or mode not in "raw": raise ValueError("mode must be 'r', 'a' or 'w'") return cls(name, mode, fileobj, **kwargs) @classmethod def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError("mode must be 'r' or 'w'") try: import gzip gzip.GzipFile except (ImportError, AttributeError): raise CompressionError("gzip module is not available") extfileobj = fileobj is not None try: fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj) t = cls.taropen(name, mode, fileobj, **kwargs) except IOError: if not extfileobj and fileobj is not None: fileobj.close() if fileobj is None: raise raise ReadError("not a gzip file") except: if not extfileobj and fileobj is not None: fileobj.close() raise t._extfileobj = extfileobj return t @classmethod def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs): """Open bzip2 compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError("mode must be 'r' or 'w'.") try: import bz2 except ImportError: raise CompressionError("bz2 module is not available") fileobj = bz2.BZ2File(fileobj or name, mode, compresslevel=compresslevel) try: t = cls.taropen(name, mode, fileobj, **kwargs) except (IOError, EOFError): fileobj.close() raise ReadError("not a bzip2 file") t._extfileobj = False return t @classmethod def xzopen(cls, name, mode="r", fileobj=None, preset=None, **kwargs): """Open lzma compressed tar archive name for reading or writing. Appending is not allowed. """ if mode not in ("r", "w"): raise ValueError("mode must be 'r' or 'w'") try: import lzma except ImportError: raise CompressionError("lzma module is not available") fileobj = lzma.LZMAFile(fileobj or name, mode, preset=preset) try: t = cls.taropen(name, mode, fileobj, **kwargs) except (lzma.LZMAError, EOFError): fileobj.close() raise ReadError("not an lzma file") t._extfileobj = False return t # All *open() methods are registered here. OPEN_METH = { "tar": "taropen", # uncompressed tar "gz": "gzopen", # gzip compressed tar "bz2": "bz2open", # bzip2 compressed tar "xz": "xzopen" # lzma compressed tar } #-------------------------------------------------------------------------- # The public methods which TarFile provides: def close(self): """Close the TarFile. In write-mode, two finishing zero blocks are appended to the archive. """ if self.closed: return if self.mode in "aw": self.fileobj.write(NUL * (BLOCKSIZE * 2)) self.offset += (BLOCKSIZE * 2) # fill up the end with zero-blocks # (like option -b20 for tar does) blocks, remainder = divmod(self.offset, RECORDSIZE) if remainder > 0: self.fileobj.write(NUL * (RECORDSIZE - remainder)) if not self._extfileobj: self.fileobj.close() self.closed = True def getmember(self, name): """Return a TarInfo object for member `name'. If `name' can not be found in the archive, KeyError is raised. If a member occurs more than once in the archive, its last occurrence is assumed to be the most up-to-date version. """ tarinfo = self._getmember(name) if tarinfo is None: raise KeyError("filename %r not found" % name) return tarinfo def getmembers(self): """Return the members of the archive as a list of TarInfo objects. The list has the same order as the members in the archive. """ self._check() if not self._loaded: # if we want to obtain a list of self._load() # all members, we first have to # scan the whole archive. return self.members def getnames(self): """Return the members of the archive as a list of their names. It has the same order as the list returned by getmembers(). """ return [tarinfo.name for tarinfo in self.getmembers()] def gettarinfo(self, name=None, arcname=None, fileobj=None): """Create a TarInfo object for either the file `name' or the file object `fileobj' (using os.fstat on its file descriptor). You can modify some of the TarInfo's attributes before you add it using addfile(). If given, `arcname' specifies an alternative name for the file in the archive. """ self._check("aw") # When fileobj is given, replace name by # fileobj's real name. if fileobj is not None: name = fileobj.name # Building the name of the member in the archive. # Backward slashes are converted to forward slashes, # Absolute paths are turned to relative paths. if arcname is None: arcname = name drv, arcname = os.path.splitdrive(arcname) arcname = arcname.replace(os.sep, "/") arcname = arcname.lstrip("/") # Now, fill the TarInfo object with # information specific for the file. tarinfo = self.tarinfo() tarinfo.tarfile = self # Use os.stat or os.lstat, depending on platform # and if symlinks shall be resolved. if fileobj is None: if hasattr(os, "lstat") and not self.dereference: statres = os.lstat(name) else: statres = os.stat(name) else: statres = os.fstat(fileobj.fileno()) linkname = "" stmd = statres.st_mode if stat.S_ISREG(stmd): inode = (statres.st_ino, statres.st_dev) if not self.dereference and statres.st_nlink > 1 and \ inode in self.inodes and arcname != self.inodes[inode]: # Is it a hardlink to an already # archived file? type = LNKTYPE linkname = self.inodes[inode] else: # The inode is added only if its valid. # For win32 it is always 0. type = REGTYPE if inode[0]: self.inodes[inode] = arcname elif stat.S_ISDIR(stmd): type = DIRTYPE elif stat.S_ISFIFO(stmd): type = FIFOTYPE elif stat.S_ISLNK(stmd): type = SYMTYPE linkname = os.readlink(name) elif stat.S_ISCHR(stmd): type = CHRTYPE elif stat.S_ISBLK(stmd): type = BLKTYPE else: return None # Fill the TarInfo object with all # information we can get. tarinfo.name = arcname tarinfo.mode = stmd tarinfo.uid = statres.st_uid tarinfo.gid = statres.st_gid if type == REGTYPE: tarinfo.size = statres.st_size else: tarinfo.size = 0 tarinfo.mtime = statres.st_mtime tarinfo.type = type tarinfo.linkname = linkname if pwd: try: tarinfo.uname = pwd.getpwuid(tarinfo.uid)[0] except KeyError: pass if grp: try: tarinfo.gname = grp.getgrgid(tarinfo.gid)[0] except KeyError: pass if type in (CHRTYPE, BLKTYPE): if hasattr(os, "major") and hasattr(os, "minor"): tarinfo.devmajor = os.major(statres.st_rdev) tarinfo.devminor = os.minor(statres.st_rdev) return tarinfo def list(self, verbose=True): """Print a table of contents to sys.stdout. If `verbose' is False, only the names of the members are printed. If it is True, an `ls -l'-like output is produced. """ self._check() for tarinfo in self: if verbose: print(stat.filemode(tarinfo.mode), end=' ') print("%s/%s" % (tarinfo.uname or tarinfo.uid, tarinfo.gname or tarinfo.gid), end=' ') if tarinfo.ischr() or tarinfo.isblk(): print("%10s" % ("%d,%d" \ % (tarinfo.devmajor, tarinfo.devminor)), end=' ') else: print("%10d" % tarinfo.size, end=' ') print("%d-%02d-%02d %02d:%02d:%02d" \ % time.localtime(tarinfo.mtime)[:6], end=' ') print(tarinfo.name + ("/" if tarinfo.isdir() else ""), end=' ') if verbose: if tarinfo.issym(): print("->", tarinfo.linkname, end=' ') if tarinfo.islnk(): print("link to", tarinfo.linkname, end=' ') print() def add(self, name, arcname=None, recursive=True, exclude=None, *, filter=None): """Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting `recursive' to False. `exclude' is a function that should return True for each filename to be excluded. `filter' is a function that expects a TarInfo object argument and returns the changed TarInfo object, if it returns None the TarInfo object will be excluded from the archive. """ self._check("aw") if arcname is None: arcname = name # Exclude pathnames. if exclude is not None: import warnings warnings.warn("use the filter argument instead", DeprecationWarning, 2) if exclude(name): self._dbg(2, "tarfile: Excluded %r" % name) return # Skip if somebody tries to archive the archive... if self.name is not None and os.path.abspath(name) == self.name: self._dbg(2, "tarfile: Skipped %r" % name) return self._dbg(1, name) # Create a TarInfo object from the file. tarinfo = self.gettarinfo(name, arcname) if tarinfo is None: self._dbg(1, "tarfile: Unsupported type %r" % name) return # Change or exclude the TarInfo object. if filter is not None: tarinfo = filter(tarinfo) if tarinfo is None: self._dbg(2, "tarfile: Excluded %r" % name) return # Append the tar header and data to the archive. if tarinfo.isreg(): with bltn_open(name, "rb") as f: self.addfile(tarinfo, f) elif tarinfo.isdir(): self.addfile(tarinfo) if recursive: for f in os.listdir(name): self.add(os.path.join(name, f), os.path.join(arcname, f), recursive, exclude, filter=filter) else: self.addfile(tarinfo) def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects using gettarinfo(). On Windows platforms, `fileobj' should always be opened with mode 'rb' to avoid irritation about the file size. """ self._check("aw") tarinfo = copy.copy(tarinfo) buf = tarinfo.tobuf(self.format, self.encoding, self.errors) self.fileobj.write(buf) self.offset += len(buf) # If there's data to follow, append it. if fileobj is not None: copyfileobj(fileobj, self.fileobj, tarinfo.size) blocks, remainder = divmod(tarinfo.size, BLOCKSIZE) if remainder > 0: self.fileobj.write(NUL * (BLOCKSIZE - remainder)) blocks += 1 self.offset += blocks * BLOCKSIZE self.members.append(tarinfo) def extractall(self, path=".", members=None): """Extract all members from the archive to the current working directory and set owner, modification time and permissions on directories afterwards. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the list returned by getmembers(). """ directories = [] if members is None: members = self for tarinfo in members: if tarinfo.isdir(): # Extract directories with a safe mode. directories.append(tarinfo) tarinfo = copy.copy(tarinfo) tarinfo.mode = 0o700 # Do not set_attrs directories, as we will do that further down self.extract(tarinfo, path, set_attrs=not tarinfo.isdir()) # Reverse sort directories. directories.sort(key=lambda a: a.name) directories.reverse() # Set correct owner, mtime and filemode on directories. for tarinfo in directories: dirpath = os.path.join(path, tarinfo.name) try: self.chown(tarinfo, dirpath) self.utime(tarinfo, dirpath) self.chmod(tarinfo, dirpath) except ExtractError as e: if self.errorlevel > 1: raise else: self._dbg(1, "tarfile: %s" % e) def extract(self, member, path="", set_attrs=True): """Extract a member from the archive to the current working directory, using its full name. Its file information is extracted as accurately as possible. `member' may be a filename or a TarInfo object. You can specify a different directory using `path'. File attributes (owner, mtime, mode) are set unless `set_attrs' is False. """ self._check("r") if isinstance(member, str): tarinfo = self.getmember(member) else: tarinfo = member # Prepare the link target for makelink(). if tarinfo.islnk(): tarinfo._link_target = os.path.join(path, tarinfo.linkname) try: self._extract_member(tarinfo, os.path.join(path, tarinfo.name), set_attrs=set_attrs) except EnvironmentError as e: if self.errorlevel > 0: raise else: if e.filename is None: self._dbg(1, "tarfile: %s" % e.strerror) else: self._dbg(1, "tarfile: %s %r" % (e.strerror, e.filename)) except ExtractError as e: if self.errorlevel > 1: raise else: self._dbg(1, "tarfile: %s" % e) def extractfile(self, member): """Extract a member from the archive as a file object. `member' may be a filename or a TarInfo object. If `member' is a regular file or a link, an io.BufferedReader object is returned. Otherwise, None is returned. """ self._check("r") if isinstance(member, str): tarinfo = self.getmember(member) else: tarinfo = member if tarinfo.isreg() or tarinfo.type not in SUPPORTED_TYPES: # Members with unknown types are treated as regular files. return self.fileobject(self, tarinfo) elif tarinfo.islnk() or tarinfo.issym(): if isinstance(self.fileobj, _Stream): # A small but ugly workaround for the case that someone tries # to extract a (sym)link as a file-object from a non-seekable # stream of tar blocks. raise StreamError("cannot extract (sym)link as file object") else: # A (sym)link's file object is its target's file object. return self.extractfile(self._find_link_target(tarinfo)) else: # If there's no data associated with the member (directory, chrdev, # blkdev, etc.), return None instead of a file object. return None def _extract_member(self, tarinfo, targetpath, set_attrs=True): """Extract the TarInfo object tarinfo to a physical file called targetpath. """ # Fetch the TarInfo object for the given name # and build the destination pathname, replacing # forward slashes to platform specific separators. targetpath = targetpath.rstrip("/") targetpath = targetpath.replace("/", os.sep) # Create all upper directories. upperdirs = os.path.dirname(targetpath) if upperdirs and not os.path.exists(upperdirs): # Create directories that are not part of the archive with # default permissions. os.makedirs(upperdirs) if tarinfo.islnk() or tarinfo.issym(): self._dbg(1, "%s -> %s" % (tarinfo.name, tarinfo.linkname)) else: self._dbg(1, tarinfo.name) if tarinfo.isreg(): self.makefile(tarinfo, targetpath) elif tarinfo.isdir(): self.makedir(tarinfo, targetpath) elif tarinfo.isfifo(): self.makefifo(tarinfo, targetpath) elif tarinfo.ischr() or tarinfo.isblk(): self.makedev(tarinfo, targetpath) elif tarinfo.islnk() or tarinfo.issym(): self.makelink(tarinfo, targetpath) elif tarinfo.type not in SUPPORTED_TYPES: self.makeunknown(tarinfo, targetpath) else: self.makefile(tarinfo, targetpath) if set_attrs: self.chown(tarinfo, targetpath) if not tarinfo.issym(): self.chmod(tarinfo, targetpath) self.utime(tarinfo, targetpath) #-------------------------------------------------------------------------- # Below are the different file methods. They are called via # _extract_member() when extract() is called. They can be replaced in a # subclass to implement other functionality. def makedir(self, tarinfo, targetpath): """Make a directory called targetpath. """ try: # Use a safe mode for the directory, the real mode is set # later in _extract_member(). os.mkdir(targetpath, 0o700) except FileExistsError: pass def makefile(self, tarinfo, targetpath): """Make a file called targetpath. """ source = self.fileobj source.seek(tarinfo.offset_data) with bltn_open(targetpath, "wb") as target: if tarinfo.sparse is not None: for offset, size in tarinfo.sparse: target.seek(offset) copyfileobj(source, target, size) else: copyfileobj(source, target, tarinfo.size) target.seek(tarinfo.size) target.truncate() def makeunknown(self, tarinfo, targetpath): """Make a file from a TarInfo object with an unknown type at targetpath. """ self.makefile(tarinfo, targetpath) self._dbg(1, "tarfile: Unknown file type %r, " \ "extracted as regular file." % tarinfo.type) def makefifo(self, tarinfo, targetpath): """Make a fifo called targetpath. """ if hasattr(os, "mkfifo"): os.mkfifo(targetpath) else: raise ExtractError("fifo not supported by system") def makedev(self, tarinfo, targetpath): """Make a character or block device called targetpath. """ if not hasattr(os, "mknod") or not hasattr(os, "makedev"): raise ExtractError("special devices not supported by system") mode = tarinfo.mode if tarinfo.isblk(): mode |= stat.S_IFBLK else: mode |= stat.S_IFCHR os.mknod(targetpath, mode, os.makedev(tarinfo.devmajor, tarinfo.devminor)) def makelink(self, tarinfo, targetpath): """Make a (symbolic) link called targetpath. If it cannot be created (platform limitation), we try to make a copy of the referenced file instead of a link. """ try: # For systems that support symbolic and hard links. if tarinfo.issym(): os.symlink(tarinfo.linkname, targetpath) else: # See extract(). if os.path.exists(tarinfo._link_target): os.link(tarinfo._link_target, targetpath) else: self._extract_member(self._find_link_target(tarinfo), targetpath) except symlink_exception: try: self._extract_member(self._find_link_target(tarinfo), targetpath) except KeyError: raise ExtractError("unable to resolve link inside archive") def chown(self, tarinfo, targetpath): """Set owner of targetpath according to tarinfo. """ if pwd and hasattr(os, "geteuid") and os.geteuid() == 0: # We have to be root to do so. try: g = grp.getgrnam(tarinfo.gname)[2] except KeyError: g = tarinfo.gid try: u = pwd.getpwnam(tarinfo.uname)[2] except KeyError: u = tarinfo.uid try: if tarinfo.issym() and hasattr(os, "lchown"): os.lchown(targetpath, u, g) else: if sys.platform != "os2emx": os.chown(targetpath, u, g) except EnvironmentError as e: raise ExtractError("could not change owner") def chmod(self, tarinfo, targetpath): """Set file permissions of targetpath according to tarinfo. """ if hasattr(os, 'chmod'): try: os.chmod(targetpath, tarinfo.mode) except EnvironmentError as e: raise ExtractError("could not change mode") def utime(self, tarinfo, targetpath): """Set modification time of targetpath according to tarinfo. """ if not hasattr(os, 'utime'): return try: os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime)) except EnvironmentError as e: raise ExtractError("could not change modification time") #-------------------------------------------------------------------------- def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m # Read the next block. self.fileobj.seek(self.offset) tarinfo = None while True: try: tarinfo = self.tarinfo.fromtarfile(self) except EOFHeaderError as e: if self.ignore_zeros: self._dbg(2, "0x%X: %s" % (self.offset, e)) self.offset += BLOCKSIZE continue except InvalidHeaderError as e: if self.ignore_zeros: self._dbg(2, "0x%X: %s" % (self.offset, e)) self.offset += BLOCKSIZE continue elif self.offset == 0: raise ReadError(str(e)) except EmptyHeaderError: if self.offset == 0: raise ReadError("empty file") except TruncatedHeaderError as e: if self.offset == 0: raise ReadError(str(e)) except SubsequentHeaderError as e: raise ReadError(str(e)) break if tarinfo is not None: self.members.append(tarinfo) else: self._loaded = True return tarinfo #-------------------------------------------------------------------------- # Little helper methods: def _getmember(self, name, tarinfo=None, normalize=False): """Find an archive member by name from bottom to top. If tarinfo is given, it is used as the starting point. """ # Ensure that all members have been loaded. members = self.getmembers() # Limit the member search list up to tarinfo. if tarinfo is not None: members = members[:members.index(tarinfo)] if normalize: name = os.path.normpath(name) for member in reversed(members): if normalize: member_name = os.path.normpath(member.name) else: member_name = member.name if name == member_name: return member def _load(self): """Read through the entire archive file and look for readable members. """ while True: tarinfo = self.next() if tarinfo is None: break self._loaded = True def _check(self, mode=None): """Check if TarFile is still open, and if the operation's mode corresponds to TarFile's mode. """ if self.closed: raise IOError("%s is closed" % self.__class__.__name__) if mode is not None and self.mode not in mode: raise IOError("bad operation for mode %r" % self.mode) def _find_link_target(self, tarinfo): """Find the target member of a symlink or hardlink member in the archive. """ if tarinfo.issym(): # Always search the entire archive. linkname = "/".join(filter(None, (os.path.dirname(tarinfo.name), tarinfo.linkname))) limit = None else: # Search the archive before the link, because a hard link is # just a reference to an already archived file. linkname = tarinfo.linkname limit = tarinfo member = self._getmember(linkname, tarinfo=limit, normalize=True) if member is None: raise KeyError("linkname %r not found" % linkname) return member def __iter__(self): """Provide an iterator object. """ if self._loaded: return iter(self.members) else: return TarIter(self) def _dbg(self, level, msg): """Write debugging output to sys.stderr. """ if level <= self.debug: print(msg, file=sys.stderr) def __enter__(self): self._check() return self def __exit__(self, type, value, traceback): if type is None: self.close() else: # An exception occurred. We must not call close() because # it would try to write end-of-archive blocks and padding. if not self._extfileobj: self.fileobj.close() self.closed = True # class TarFile class TarIter: """Iterator Class. for tarinfo in TarFile(...): suite... """ def __init__(self, tarfile): """Construct a TarIter object. """ self.tarfile = tarfile self.index = 0 def __iter__(self): """Return iterator object. """ return self def __next__(self): """Return the next item using TarFile's next() method. When all members have been read, set TarFile as _loaded. """ # Fix for SF #1100429: Under rare circumstances it can # happen that getmembers() is called during iteration, # which will cause TarIter to stop prematurely. if self.index == 0 and self.tarfile.firstmember is not None: tarinfo = self.tarfile.next() elif self.index < len(self.tarfile.members): tarinfo = self.tarfile.members[self.index] elif not self.tarfile._loaded: tarinfo = self.tarfile.next() if not tarinfo: self.tarfile._loaded = True raise StopIteration else: raise StopIteration self.index += 1 return tarinfo #-------------------- # exported functions #-------------------- def is_tarfile(name): """Return True if name points to a tar archive that we are able to handle, else return False. """ try: t = open(name) t.close() return True except TarError: return False bltn_open = open open = TarFile.open
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 7656, 2595, 199, 3, 13608, 14, 647, 199, 7656, 2595, 199, 3, 1898, 334, 35, 9, 14790, 491, 4291, 598, 833, 65, 2871, 352, 665, 31590, 32, 71, 833, 65, 2871, 352, 14, 271, 30, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 8779, 221, 365, 221, 11882, 10009, 12, 221, 2867, 221, 402, 11204, 12, 221, 370, 221, 1263, 4954, 199, 3, 12408, 282, 221, 1331, 402, 221, 642, 2032, 221, 436, 4568, 3794, 199, 3, 1584, 221, 334, 1589, 221, 298, 10337, 1288, 221, 370, 257, 7962, 221, 315, 221, 314, 221, 2290, 257, 1928, 199, 3, 10588, 12, 221, 5893, 221, 1928, 12305, 221, 314, 221, 4481, 370, 221, 675, 12, 199, 3, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 221, 402, 221, 314, 221, 2290, 12, 221, 436, 370, 221, 11291, 221, 12103, 221, 370, 221, 12676, 314, 199, 3, 2290, 221, 365, 221, 13985, 221, 370, 221, 886, 221, 880, 12, 221, 5420, 221, 370, 221, 314, 221, 2569, 199, 3, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 221, 4245, 436, 642, 221, 4983, 4245, 10989, 221, 506, 199, 3, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 221, 2281, 401, 2428, 3408, 1634, 1821, 221, 3826, 12, 199, 3, 7168, 1549, 5292, 12, 6931, 221, 5400, 2845, 5471, 2296, 221, 2334, 2990, 199, 3, 1634, 221, 3169, 12, 221, 3092, 257, 2381, 221, 437, 221, 3115, 257, 3104, 221, 2401, 199, 3, 13229, 14, 221, 1621, 221, 4825, 221, 6461, 7000, 221, 2334, 221, 10610, 221, 1549, 5877, 199, 3, 8164, 221, 6262, 7024, 221, 2381, 1821, 221, 13140, 12, 6736, 221, 1549, 5010, 221, 5603, 12, 199, 3, 7061, 221, 1621, 1261, 221, 9612, 1634, 221, 7066, 12, 7056, 221, 1549, 7334, 12, 221, 7043, 199, 3, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 199, 3, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 624, 3284, 687, 436, 2218, 370, 5330, 1475, 25993, 14, 199, 624, 199, 199, 1023, 258, 275, 298, 16, 14, 25, 14, 16, 2, 199, 363, 2502, 363, 221, 275, 298, 44, 4291, 598, 833, 60, 85, 383, 69, 20, 20621, 334, 31590, 32, 71, 833, 65, 2871, 352, 14, 271, 2924, 199, 363, 602, 363, 259, 275, 7880, 2506, 26, 7760, 13, 996, 13, 821, 5557, 26, 2260, 26, 614, 435, 24215, 334, 22533, 12, 5661, 21141, 7760, 9, 2672, 2, 199, 363, 5107, 4148, 363, 257, 275, 7880, 1304, 26, 13608, 14, 647, 10523, 26888, 7760, 13, 996, 13, 821, 4114, 26, 2260, 26, 614, 58, 7557, 67, 13, 28547, 14, 274, 32649, 2672, 2, 199, 363, 22461, 363, 275, 298, 39, 833, 1214, 79, 653, 1873, 278, 23009, 12, 653, 14769, 83, 598, 833, 60, 85, 383, 69, 20, 20621, 12, 30846, 1005, 377, 944, 2254, 2122, 199, 199, 3, 9960, 199, 3, 24339, 199, 3, 9960, 199, 646, 984, 199, 646, 747, 199, 646, 5890, 199, 646, 5145, 199, 646, 5672, 199, 646, 900, 199, 646, 2702, 199, 646, 1331, 199, 646, 295, 199, 199, 893, 26, 272, 492, 18598, 12, 14374, 199, 2590, 3545, 26, 272, 18598, 275, 14374, 275, 488, 199, 199, 3, 747, 14, 13380, 641, 5417, 6791, 370, 1227, 14, 16, 6534, 4279, 199, 13380, 63, 1971, 275, 334, 10227, 12, 4279, 9, 199, 893, 26, 272, 327, 23950, 334, 969, 1079, 9, 911, 506, 4915, 340, 314, 8025, 1630, 440, 10266, 314, 272, 327, 3240, 2499, 16594, 9670, 3834, 30447, 1979, 17228, 272, 15296, 63, 1971, 847, 334, 8647, 547, 4258, 199, 2590, 12746, 26, 272, 986, 199, 199, 3, 687, 13608, 492, 627, 199, 363, 452, 363, 275, 2097, 24818, 1173, 401, 298, 24818, 2354, 401, 298, 374, 63, 19862, 401, 298, 24818, 547, 937, 199, 199, 504, 12963, 492, 1551, 465, 485, 1490, 327, 9336, 283, 1490, 7, 365, 30227, 14, 1490, 199, 199, 17807, 9960, 199, 3, 5330, 5262, 199, 17807, 9960, 199, 46, 1293, 275, 330, 3212, 16, 2, 9326, 327, 314, 2973, 4528, 199, 8475, 4305, 275, 10574, 463, 327, 2582, 402, 6661, 5664, 199, 15060, 4305, 275, 8068, 4305, 627, 3388, 258, 327, 2582, 402, 5767, 199, 17732, 63, 19973, 275, 330, 2, 833, 285, 221, 971, 16, 2, 263, 327, 10628, 486, 4850, 5330, 1059, 199, 16399, 63, 19973, 275, 330, 2, 833, 285, 60, 88, 993, 2, 259, 327, 10628, 10694, 5330, 1059, 199, 199, 9127, 63, 2339, 275, 2948, 5185, 327, 5696, 2582, 402, 282, 1788, 199, 9127, 63, 7916, 275, 2948, 5185, 327, 5696, 2582, 402, 282, 2142, 354, 199, 9127, 63, 6351, 275, 29710, 3777, 327, 5696, 2582, 402, 314, 2403, 901, 199, 199, 5616, 2711, 275, 330, 2, 16, 2, 8295, 327, 5578, 570, 199, 689, 4680, 2711, 275, 330, 3212, 16, 2, 4483, 327, 5578, 570, 199, 44, 22780, 2711, 275, 330, 2, 17, 2, 8295, 327, 2142, 334, 17183, 13608, 9, 199, 30637, 2711, 275, 330, 2, 18, 2, 8295, 327, 13673, 2142, 199, 1244, 50, 2711, 275, 330, 2, 19, 2, 8295, 327, 4528, 4539, 2243, 199, 7847, 43, 2711, 275, 330, 2, 20, 2, 8295, 327, 1853, 4539, 2243, 199, 3022, 2711, 275, 330, 2, 21, 2, 8295, 327, 2082, 199, 1976, 38, 1387, 4948, 275, 330, 2, 22, 2, 463, 327, 5883, 545, 4539, 2243, 199, 1864, 1481, 4948, 275, 330, 2, 23, 2, 463, 327, 26611, 570, 199, 199, 15306, 934, 4948, 63, 12375, 2339, 275, 330, 2, 44, 2, 260, 327, 1664, 5330, 1846, 354, 199, 15306, 934, 4948, 63, 44, 615, 2226, 12394, 275, 330, 2, 43, 2, 260, 327, 1664, 5330, 1846, 1073, 199, 15306, 934, 4948, 63, 51, 23354, 275, 330, 2, 51, 2, 3698, 327, 1664, 5330, 5178, 570, 199, 199, 56, 14903, 2711, 275, 330, 2, 88, 2, 8295, 327, 18169, 14, 17, 13, 8339, 9243, 1406, 199, 56, 2226, 2711, 275, 330, 2, 71, 2, 8295, 327, 18169, 14, 17, 13, 8339, 2288 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 7656, 2595, 199, 3, 13608, 14, 647, 199, 7656, 2595, 199, 3, 1898, 334, 35, 9, 14790, 491, 4291, 598, 833, 65, 2871, 352, 665, 31590, 32, 71, 833, 65, 2871, 352, 14, 271, 30, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 8779, 221, 365, 221, 11882, 10009, 12, 221, 2867, 221, 402, 11204, 12, 221, 370, 221, 1263, 4954, 199, 3, 12408, 282, 221, 1331, 402, 221, 642, 2032, 221, 436, 4568, 3794, 199, 3, 1584, 221, 334, 1589, 221, 298, 10337, 1288, 221, 370, 257, 7962, 221, 315, 221, 314, 221, 2290, 257, 1928, 199, 3, 10588, 12, 221, 5893, 221, 1928, 12305, 221, 314, 221, 4481, 370, 221, 675, 12, 199, 3, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 221, 402, 221, 314, 221, 2290, 12, 221, 436, 370, 221, 11291, 221, 12103, 221, 370, 221, 12676, 314, 199, 3, 2290, 221, 365, 221, 13985, 221, 370, 221, 886, 221, 880, 12, 221, 5420, 221, 370, 221, 314, 221, 2569, 199, 3, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 221, 4245, 436, 642, 221, 4983, 4245, 10989, 221, 506, 199, 3, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 221, 2281, 401, 2428, 3408, 1634, 1821, 221, 3826, 12, 199, 3, 7168, 1549, 5292, 12, 6931, 221, 5400, 2845, 5471, 2296, 221, 2334, 2990, 199, 3, 1634, 221, 3169, 12, 221, 3092, 257, 2381, 221, 437, 221, 3115, 257, 3104, 221, 2401, 199, 3, 13229, 14, 221, 1621, 221, 4825, 221, 6461, 7000, 221, 2334, 221, 10610, 221, 1549, 5877, 199, 3, 8164, 221, 6262, 7024, 221, 2381, 1821, 221, 13140, 12, 6736, 221, 1549, 5010, 221, 5603, 12, 199, 3, 7061, 221, 1621, 1261, 221, 9612, 1634, 221, 7066, 12, 7056, 221, 1549, 7334, 12, 221, 7043, 199, 3, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 199, 3, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 624, 3284, 687, 436, 2218, 370, 5330, 1475, 25993, 14, 199, 624, 199, 199, 1023, 258, 275, 298, 16, 14, 25, 14, 16, 2, 199, 363, 2502, 363, 221, 275, 298, 44, 4291, 598, 833, 60, 85, 383, 69, 20, 20621, 334, 31590, 32, 71, 833, 65, 2871, 352, 14, 271, 2924, 199, 363, 602, 363, 259, 275, 7880, 2506, 26, 7760, 13, 996, 13, 821, 5557, 26, 2260, 26, 614, 435, 24215, 334, 22533, 12, 5661, 21141, 7760, 9, 2672, 2, 199, 363, 5107, 4148, 363, 257, 275, 7880, 1304, 26, 13608, 14, 647, 10523, 26888, 7760, 13, 996, 13, 821, 4114, 26, 2260, 26, 614, 58, 7557, 67, 13, 28547, 14, 274, 32649, 2672, 2, 199, 363, 22461, 363, 275, 298, 39, 833, 1214, 79, 653, 1873, 278, 23009, 12, 653, 14769, 83, 598, 833, 60, 85, 383, 69, 20, 20621, 12, 30846, 1005, 377, 944, 2254, 2122, 199, 199, 3, 9960, 199, 3, 24339, 199, 3, 9960, 199, 646, 984, 199, 646, 747, 199, 646, 5890, 199, 646, 5145, 199, 646, 5672, 199, 646, 900, 199, 646, 2702, 199, 646, 1331, 199, 646, 295, 199, 199, 893, 26, 272, 492, 18598, 12, 14374, 199, 2590, 3545, 26, 272, 18598, 275, 14374, 275, 488, 199, 199, 3, 747, 14, 13380, 641, 5417, 6791, 370, 1227, 14, 16, 6534, 4279, 199, 13380, 63, 1971, 275, 334, 10227, 12, 4279, 9, 199, 893, 26, 272, 327, 23950, 334, 969, 1079, 9, 911, 506, 4915, 340, 314, 8025, 1630, 440, 10266, 314, 272, 327, 3240, 2499, 16594, 9670, 3834, 30447, 1979, 17228, 272, 15296, 63, 1971, 847, 334, 8647, 547, 4258, 199, 2590, 12746, 26, 272, 986, 199, 199, 3, 687, 13608, 492, 627, 199, 363, 452, 363, 275, 2097, 24818, 1173, 401, 298, 24818, 2354, 401, 298, 374, 63, 19862, 401, 298, 24818, 547, 937, 199, 199, 504, 12963, 492, 1551, 465, 485, 1490, 327, 9336, 283, 1490, 7, 365, 30227, 14, 1490, 199, 199, 17807, 9960, 199, 3, 5330, 5262, 199, 17807, 9960, 199, 46, 1293, 275, 330, 3212, 16, 2, 9326, 327, 314, 2973, 4528, 199, 8475, 4305, 275, 10574, 463, 327, 2582, 402, 6661, 5664, 199, 15060, 4305, 275, 8068, 4305, 627, 3388, 258, 327, 2582, 402, 5767, 199, 17732, 63, 19973, 275, 330, 2, 833, 285, 221, 971, 16, 2, 263, 327, 10628, 486, 4850, 5330, 1059, 199, 16399, 63, 19973, 275, 330, 2, 833, 285, 60, 88, 993, 2, 259, 327, 10628, 10694, 5330, 1059, 199, 199, 9127, 63, 2339, 275, 2948, 5185, 327, 5696, 2582, 402, 282, 1788, 199, 9127, 63, 7916, 275, 2948, 5185, 327, 5696, 2582, 402, 282, 2142, 354, 199, 9127, 63, 6351, 275, 29710, 3777, 327, 5696, 2582, 402, 314, 2403, 901, 199, 199, 5616, 2711, 275, 330, 2, 16, 2, 8295, 327, 5578, 570, 199, 689, 4680, 2711, 275, 330, 3212, 16, 2, 4483, 327, 5578, 570, 199, 44, 22780, 2711, 275, 330, 2, 17, 2, 8295, 327, 2142, 334, 17183, 13608, 9, 199, 30637, 2711, 275, 330, 2, 18, 2, 8295, 327, 13673, 2142, 199, 1244, 50, 2711, 275, 330, 2, 19, 2, 8295, 327, 4528, 4539, 2243, 199, 7847, 43, 2711, 275, 330, 2, 20, 2, 8295, 327, 1853, 4539, 2243, 199, 3022, 2711, 275, 330, 2, 21, 2, 8295, 327, 2082, 199, 1976, 38, 1387, 4948, 275, 330, 2, 22, 2, 463, 327, 5883, 545, 4539, 2243, 199, 1864, 1481, 4948, 275, 330, 2, 23, 2, 463, 327, 26611, 570, 199, 199, 15306, 934, 4948, 63, 12375, 2339, 275, 330, 2, 44, 2, 260, 327, 1664, 5330, 1846, 354, 199, 15306, 934, 4948, 63, 44, 615, 2226, 12394, 275, 330, 2, 43, 2, 260, 327, 1664, 5330, 1846, 1073, 199, 15306, 934, 4948, 63, 51, 23354, 275, 330, 2, 51, 2, 3698, 327, 1664, 5330, 5178, 570, 199, 199, 56, 14903, 2711, 275, 330, 2, 88, 2, 8295, 327, 18169, 14, 17, 13, 8339, 9243, 1406, 199, 56, 2226, 2711, 275, 330, 2, 71, 2, 8295, 327, 18169, 14, 17, 13, 8339, 2288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ryfeus/lambda-packs
Tensorflow_OpenCV_Nightly/source/tensorflow/contrib/learn/python/learn/estimators/tensor_signature.py
134
6730
# Copyright 2016 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. # ============================================================================== """TensorSignature class and utilities.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import collections from tensorflow.python.framework import dtypes from tensorflow.python.framework import sparse_tensor from tensorflow.python.framework import tensor_shape from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import parsing_ops class TensorSignature(collections.namedtuple( "TensorSignature", ["dtype", "shape", "is_sparse"])): """Signature of the `Tensor` object. Useful to check compatibility of tensors. Example: ```python examples = tf.placeholder(...) inputs = {'a': var_a, 'b': var_b} signatures = tensor_signature.create_signatures(inputs) result = tensor_signature.create_example_parser_from_signatures( signatures, examples) self.assertTrue(tensor_signature.tensors_compatible(result, signatures)) ``` Attributes: dtype: `DType` object. shape: `TensorShape` object. """ def __new__(cls, tensor): if isinstance(tensor, sparse_tensor.SparseTensor): return super(TensorSignature, cls).__new__( cls, dtype=tensor.values.dtype, shape=None, is_sparse=True) return super(TensorSignature, cls).__new__( cls, dtype=tensor.dtype, shape=tensor.get_shape(), is_sparse=False) def is_compatible_with(self, other): """Returns True if signatures are compatible.""" def _shape_is_compatible_0dim(this, other): """Checks that shapes are compatible skipping dim 0.""" other = tensor_shape.as_shape(other) # If shapes are None (unknown) they may be compatible. if this.dims is None or other.dims is None: return True if this.ndims != other.ndims: return False for dim, (x_dim, y_dim) in enumerate(zip(this.dims, other.dims)): if dim == 0: continue if not x_dim.is_compatible_with(y_dim): return False return True if other.is_sparse: return self.is_sparse and self.dtype.is_compatible_with(other.dtype) return (self.dtype.is_compatible_with(other.dtype) and _shape_is_compatible_0dim(self.shape, other.shape) and not self.is_sparse) def get_placeholder(self): if self.is_sparse: return array_ops.sparse_placeholder(dtype=self.dtype) return array_ops.placeholder(dtype=self.dtype, shape=[None] + list(self.shape[1:])) def get_feature_spec(self): dtype = self.dtype # Convert, because example parser only supports float32, int64 and string. if dtype == dtypes.int32: dtype = dtypes.int64 if dtype == dtypes.float64: dtype = dtypes.float32 if self.is_sparse: return parsing_ops.VarLenFeature(dtype=dtype) return parsing_ops.FixedLenFeature(shape=self.shape[1:], dtype=dtype) def tensors_compatible(tensors, signatures): """Check that tensors are compatible with signatures. Args: tensors: Dict of `Tensor` objects or single `Tensor` object. signatures: Dict of `TensorSignature` objects or single `TensorSignature` object. Returns: True if all tensors are compatible, False otherwise. """ # Dict of Tensors as input. if tensors is None: return signatures is None if isinstance(tensors, dict): if not isinstance(signatures, dict): return False for key in signatures: if key not in tensors: return False if not TensorSignature(tensors[key]).is_compatible_with(signatures[key]): return False return True # Single tensor as input. if signatures is None or isinstance(signatures, dict): return False return TensorSignature(tensors).is_compatible_with(signatures) def create_signatures(tensors): """Creates TensorSignature objects for given tensors. Args: tensors: Dict of `Tensor` objects or single `Tensor`. Returns: Dict of `TensorSignature` objects or single `TensorSignature`. """ if isinstance(tensors, dict): return { key: TensorSignature(tensors[key]) for key in tensors} if tensors is None: return None return TensorSignature(tensors) def create_placeholders_from_signatures(signatures): """Creates placeholders from given signatures. Args: signatures: Dict of `TensorSignature` objects or single `TensorSignature`, or `None`. Returns: Dict of `tf.placeholder` objects or single `tf.placeholder`, or `None`. """ if signatures is None: return None if not isinstance(signatures, dict): return signatures.get_placeholder() return { key: signatures[key].get_placeholder() for key in signatures} def create_example_parser_from_signatures(signatures, examples_batch, single_feature_name="feature"): """Creates example parser from given signatures. Args: signatures: Dict of `TensorSignature` objects or single `TensorSignature`. examples_batch: string `Tensor` of serialized `Example` proto. single_feature_name: string, single feature name. Returns: features: `Tensor` or `dict` of `Tensor` objects. """ feature_spec = {} if not isinstance(signatures, dict): feature_spec[single_feature_name] = signatures.get_feature_spec() else: feature_spec = {key: signatures[key].get_feature_spec() for key in signatures} features = parsing_ops.parse_example(examples_batch, feature_spec) if not isinstance(signatures, dict): # Returns single feature, casts if needed. features = features[single_feature_name] if not signatures.dtype.is_compatible_with(features.dtype): features = math_ops.cast(features, signatures.dtype) return features # Returns dict of features, casts if needed. for name in features: if not signatures[name].dtype.is_compatible_with(features[name].dtype): features[name] = math_ops.cast(features[name], signatures[name].dtype) return features
mit
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 3861, 10014, 1021, 436, 15841, 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, 5055, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 5178, 63, 3128, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2345, 63, 1392, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 6057, 63, 1483, 421, 199, 533, 5878, 10014, 8, 7882, 14, 18921, 8, 272, 298, 3861, 10014, 401, 2097, 2271, 401, 298, 1392, 401, 298, 374, 63, 4421, 3135, 304, 523, 408, 10014, 402, 314, 658, 3861, 64, 909, 14, 819, 18491, 370, 1104, 7163, 402, 10519, 14, 819, 5679, 26, 819, 10841, 1548, 523, 7251, 275, 2833, 14, 6199, 20186, 523, 4153, 275, 791, 65, 356, 2729, 63, 65, 12, 283, 66, 356, 2729, 63, 66, 93, 523, 17597, 275, 2345, 63, 5233, 14, 981, 63, 15132, 8, 3711, 9, 523, 754, 275, 2345, 63, 5233, 14, 981, 63, 2694, 63, 2087, 63, 504, 63, 15132, 8, 489, 17597, 12, 7251, 9, 523, 291, 14, 1815, 8, 3128, 63, 5233, 14, 10206, 63, 6490, 8, 1099, 12, 17597, 430, 523, 10841, 819, 9382, 26, 272, 2152, 26, 658, 36, 804, 64, 909, 14, 272, 2215, 26, 658, 18592, 64, 909, 14, 523, 408, 819, 347, 636, 1222, 721, 1886, 12, 2345, 304, 272, 340, 1228, 8, 3128, 12, 5178, 63, 3128, 14, 12079, 304, 489, 372, 1613, 8, 3861, 10014, 12, 843, 2843, 1222, 721, 881, 843, 12, 2152, 29, 3128, 14, 1459, 14, 2271, 12, 2215, 29, 403, 12, 365, 63, 4421, 29, 549, 9, 272, 372, 1613, 8, 3861, 10014, 12, 843, 2843, 1222, 721, 267, 843, 12, 2152, 29, 3128, 14, 2271, 12, 2215, 29, 3128, 14, 362, 63, 1392, 1062, 365, 63, 4421, 29, 797, 9, 819, 347, 365, 63, 6490, 63, 1045, 8, 277, 12, 1163, 304, 272, 408, 3407, 715, 340, 17597, 787, 9025, 1041, 339, 347, 485, 1392, 63, 374, 63, 6490, 63, 16, 3572, 8, 3749, 12, 1163, 304, 489, 408, 11834, 626, 11751, 787, 9025, 16068, 8134, 378, 1041, 489, 1163, 275, 2345, 63, 1392, 14, 305, 63, 1392, 8, 1848, 9, 489, 327, 982, 11751, 787, 488, 334, 5187, 9, 2985, 1443, 506, 9025, 14, 489, 340, 642, 14, 5380, 365, 488, 503, 1163, 14, 5380, 365, 488, 26, 267, 372, 715, 489, 340, 642, 14, 13575, 1137, 1163, 14, 13575, 26, 267, 372, 756, 489, 367, 8134, 12, 334, 88, 63, 3572, 12, 612, 63, 3572, 9, 315, 3874, 8, 3065, 8, 3749, 14, 5380, 12, 1163, 14, 5380, 2298, 267, 340, 8134, 508, 378, 26, 881, 1980, 267, 340, 440, 671, 63, 3572, 14, 374, 63, 6490, 63, 1045, 8, 89, 63, 3572, 304, 881, 372, 756, 489, 372, 715, 339, 340, 1163, 14, 374, 63, 4421, 26, 489, 372, 291, 14, 374, 63, 4421, 436, 291, 14, 2271, 14, 374, 63, 6490, 63, 1045, 8, 1848, 14, 2271, 9, 272, 372, 334, 277, 14, 2271, 14, 374, 63, 6490, 63, 1045, 8, 1848, 14, 2271, 9, 436, 288, 485, 1392, 63, 374, 63, 6490, 63, 16, 3572, 8, 277, 14, 1392, 12, 1163, 14, 1392, 9, 436, 288, 440, 291, 14, 374, 63, 4421, 9, 819, 347, 664, 63, 6199, 8, 277, 304, 272, 340, 291, 14, 374, 63, 4421, 26, 489, 372, 1625, 63, 1483, 14, 4421, 63, 6199, 8, 2271, 29, 277, 14, 2271, 9, 272, 372, 1625, 63, 1483, 14, 6199, 8, 2271, 29, 277, 14, 2271, 12, 639, 2215, 1524, 403, 61, 435, 769, 8, 277, 14, 1392, 59, 17, 16720, 819, 347, 664, 63, 4445, 63, 1650, 8, 277, 304, 272, 2152, 275, 291, 14, 2271, 272, 327, 7905, 12, 2952, 2893, 1798, 1454, 5171, 2069, 708, 12, 1109, 772, 436, 1059, 14, 272, 340, 2152, 508, 6674, 14, 442, 708, 26, 489, 2152, 275, 6674, 14, 442, 772, 272, 340, 2152, 508, 6674, 14, 1609, 772, 26, 489, 2152, 275, 6674, 14, 1609, 708, 272, 340, 291, 14, 374, 63, 4421, 26, 489, 372, 6057, 63, 1483, 14, 5894, 28556, 8, 2271, 29, 2271, 9, 272, 372, 6057, 63, 1483, 14, 9515, 28556, 8, 1392, 29, 277, 14, 1392, 59, 17, 8429, 2152, 29, 2271, 9, 421, 199, 318, 10519, 63, 6490, 8, 10206, 12, 17597, 304, 523, 408, 1799, 626, 10519, 787, 9025, 543, 17597, 14, 819, 3033, 26, 272, 10519, 26, 7448, 402, 658, 3861, 64, 2251, 503, 2849, 658, 3861, 64, 909, 14, 272, 17597, 26, 7448, 402, 658, 3861, 10014, 64, 2251, 503, 355, 2849, 658, 3861, 10014, 64, 909, 14, 819, 1803, 26, 272, 715, 340, 1006, 10519, 787, 9025, 12, 756, 4257, 14, 523, 408, 523, 327, 7448, 402, 28373, 465, 1324, 14, 523, 340, 10519, 365, 488, 26, 272, 372, 17597, 365, 488, 819, 340, 1228, 8, 10206, 12, 1211, 304, 272, 340, 440, 1228, 8, 15132, 12, 1211, 304, 489, 372, 756, 272, 367, 790, 315, 17597, 26, 489, 340, 790, 440, 315, 10519, 26, 267, 372, 756, 489, 340 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 3861, 10014, 1021, 436, 15841, 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, 5055, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 5178, 63, 3128, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2345, 63, 1392, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 6057, 63, 1483, 421, 199, 533, 5878, 10014, 8, 7882, 14, 18921, 8, 272, 298, 3861, 10014, 401, 2097, 2271, 401, 298, 1392, 401, 298, 374, 63, 4421, 3135, 304, 523, 408, 10014, 402, 314, 658, 3861, 64, 909, 14, 819, 18491, 370, 1104, 7163, 402, 10519, 14, 819, 5679, 26, 819, 10841, 1548, 523, 7251, 275, 2833, 14, 6199, 20186, 523, 4153, 275, 791, 65, 356, 2729, 63, 65, 12, 283, 66, 356, 2729, 63, 66, 93, 523, 17597, 275, 2345, 63, 5233, 14, 981, 63, 15132, 8, 3711, 9, 523, 754, 275, 2345, 63, 5233, 14, 981, 63, 2694, 63, 2087, 63, 504, 63, 15132, 8, 489, 17597, 12, 7251, 9, 523, 291, 14, 1815, 8, 3128, 63, 5233, 14, 10206, 63, 6490, 8, 1099, 12, 17597, 430, 523, 10841, 819, 9382, 26, 272, 2152, 26, 658, 36, 804, 64, 909, 14, 272, 2215, 26, 658, 18592, 64, 909, 14, 523, 408, 819, 347, 636, 1222, 721, 1886, 12, 2345, 304, 272, 340, 1228, 8, 3128, 12, 5178, 63, 3128, 14, 12079, 304, 489, 372, 1613, 8, 3861, 10014, 12, 843, 2843, 1222, 721, 881, 843, 12, 2152, 29, 3128, 14, 1459, 14, 2271, 12, 2215, 29, 403, 12, 365, 63, 4421, 29, 549, 9, 272, 372, 1613, 8, 3861, 10014, 12, 843, 2843, 1222, 721, 267, 843, 12, 2152, 29, 3128, 14, 2271, 12, 2215, 29, 3128, 14, 362, 63, 1392, 1062, 365, 63, 4421, 29, 797, 9, 819, 347, 365, 63, 6490, 63, 1045, 8, 277, 12, 1163, 304, 272, 408, 3407, 715, 340, 17597, 787, 9025, 1041, 339, 347, 485, 1392, 63, 374, 63, 6490, 63, 16, 3572, 8, 3749, 12, 1163, 304, 489, 408, 11834, 626, 11751, 787, 9025, 16068, 8134, 378, 1041, 489, 1163, 275, 2345, 63, 1392, 14, 305, 63, 1392, 8, 1848, 9, 489, 327, 982, 11751, 787, 488, 334, 5187, 9, 2985, 1443, 506, 9025, 14, 489, 340, 642, 14, 5380, 365, 488, 503, 1163, 14, 5380, 365, 488, 26, 267, 372, 715, 489, 340, 642, 14, 13575, 1137, 1163, 14, 13575, 26, 267, 372, 756, 489, 367, 8134, 12, 334, 88, 63, 3572, 12, 612, 63, 3572, 9, 315, 3874, 8, 3065, 8, 3749, 14, 5380, 12, 1163, 14, 5380, 2298, 267, 340, 8134, 508, 378, 26, 881, 1980, 267, 340, 440, 671, 63, 3572, 14, 374, 63, 6490, 63, 1045, 8, 89, 63, 3572, 304, 881, 372, 756, 489, 372, 715, 339, 340, 1163, 14, 374, 63, 4421, 26, 489, 372, 291, 14, 374, 63, 4421, 436, 291, 14, 2271, 14, 374, 63, 6490, 63, 1045, 8, 1848, 14, 2271, 9, 272, 372, 334, 277, 14, 2271, 14, 374, 63, 6490, 63, 1045, 8, 1848, 14, 2271, 9, 436, 288, 485, 1392, 63, 374, 63, 6490, 63, 16, 3572, 8, 277, 14, 1392, 12, 1163, 14, 1392, 9, 436, 288, 440, 291, 14, 374, 63, 4421, 9, 819, 347, 664, 63, 6199, 8, 277, 304, 272, 340, 291, 14, 374, 63, 4421, 26, 489, 372, 1625, 63, 1483, 14, 4421, 63, 6199, 8, 2271, 29, 277, 14, 2271, 9, 272, 372, 1625, 63, 1483, 14, 6199, 8, 2271, 29, 277, 14, 2271, 12, 639, 2215, 1524, 403, 61, 435, 769, 8, 277, 14, 1392, 59, 17, 16720, 819, 347, 664, 63, 4445, 63, 1650, 8, 277, 304, 272, 2152, 275, 291, 14, 2271, 272, 327, 7905, 12, 2952, 2893, 1798, 1454, 5171, 2069, 708, 12, 1109, 772, 436, 1059, 14, 272, 340, 2152, 508, 6674, 14, 442, 708, 26, 489, 2152, 275, 6674, 14, 442, 772, 272, 340, 2152, 508, 6674, 14, 1609, 772, 26, 489, 2152, 275, 6674, 14, 1609, 708, 272, 340, 291, 14, 374, 63, 4421, 26, 489, 372, 6057, 63, 1483, 14, 5894, 28556, 8, 2271, 29, 2271, 9, 272, 372, 6057, 63, 1483, 14, 9515, 28556, 8, 1392, 29, 277, 14, 1392, 59, 17, 8429, 2152, 29, 2271, 9, 421, 199, 318, 10519, 63, 6490, 8, 10206, 12, 17597, 304, 523, 408, 1799, 626, 10519, 787, 9025, 543, 17597, 14, 819, 3033, 26, 272, 10519, 26, 7448, 402, 658, 3861, 64, 2251, 503, 2849, 658, 3861, 64, 909, 14, 272, 17597, 26, 7448, 402, 658, 3861, 10014, 64, 2251, 503, 355, 2849, 658, 3861, 10014, 64, 909, 14, 819, 1803, 26, 272, 715, 340, 1006, 10519, 787, 9025, 12, 756, 4257, 14, 523, 408, 523, 327, 7448, 402, 28373, 465, 1324, 14, 523, 340, 10519, 365, 488, 26, 272, 372, 17597, 365, 488, 819, 340, 1228, 8, 10206, 12, 1211, 304, 272, 340, 440, 1228, 8, 15132, 12, 1211, 304, 489, 372, 756, 272, 367, 790, 315, 17597, 26, 489, 340, 790, 440, 315, 10519, 26, 267, 372, 756, 489, 340, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
AmrnotAmr/zato
code/zato-server/test/zato/server/service/test_service.py
6
19235
# -*- coding: utf-8 -*- """ Copyright (C) 2013 Dariusz Suchojad <dsuch at zato.io> Licensed under LGPLv3, see LICENSE.txt for terms and conditions. """ from __future__ import absolute_import, division, print_function, unicode_literals # stdlib import ast from json import loads from logging import getLogger, INFO from time import time from unittest import TestCase from uuid import uuid4 # Bunch from bunch import Bunch # faker from faker import Faker # lxml from lxml import etree, objectify # nose from nose.tools import eq_ # retools from retools.lock import LockTimeout # Zato from zato.common import CHANNEL, DATA_FORMAT, KVDB, PARAMS_PRIORITY, \ SCHEDULER, URL_TYPE from zato.common.test import FakeKVDB, rand_string, rand_int, ServiceTestCase from zato.server.service import List, Service from zato.server.service.reqresp import HTTPRequestData, Request logger = getLogger(__name__) faker = Faker() # ################################################################################################################################ class HooksTestCase(ServiceTestCase): def test__hooks(self): class MyJob(Service): def handle(self): pass def before_handle(self): self.environ['before_handle_called'] = True def before_job(self): self.environ['before_job_called'] = True def before_one_time_job(self): self.environ['before_one_time_job_called'] = True def after_handle(self): self.environ['after_handle_called'] = True def after_job(self): self.environ['after_job_called'] = True def after_one_time_job(self): self.environ['after_one_time_job_called'] = True instance = self.invoke(MyJob, {}, {}, channel=CHANNEL.SCHEDULER, job_type=SCHEDULER.JOB_TYPE.ONE_TIME) for name in('before_handle', 'before_job', 'before_one_time_job', 'after_handle', 'after_job', 'after_one_time_job'): eq_(instance.environ['{}_called'.format(name)], True) # ################################################################################################################################ class TestLogInputOutput(ServiceTestCase): def test__log_input_output(self): class MyLogger(object): def __init__(self): self.level = None self.msg = None def log(self, level, msg): self.level = level self.msg = msg class DummyService(Service): def handle(self): self.logger = MyLogger() instance = self.invoke(DummyService, {}, {}) level = uuid4().hex user_msg = uuid4().hex instance._log_input_output(user_msg, level, {}, True) eq_(instance.logger.level, level) self.assertTrue(instance.logger.msg.startswith('{} '.format(user_msg))) instance.log_input() eq_(instance.logger.level, INFO) msg = ast.literal_eval(instance.logger.msg) eq_(sorted(msg), ['channel', 'cid', 'data_format', 'environ', 'impl_name', 'invocation_time', 'job_type', 'name', 'request.payload', 'slow_threshold', u'usage', 'wsgi_environ']) instance.log_output() eq_(instance.logger.level, INFO) msg = ast.literal_eval(instance.logger.msg) eq_(sorted(msg), ['channel', 'cid', 'data_format', 'environ', 'handle_return_time', 'impl_name', 'invocation_time', 'job_type', 'name', 'processing_time', 'processing_time_raw', 'response.payload', 'slow_threshold', 'usage', 'wsgi_environ', 'zato.http.response.headers']) # ################################################################################################################################ class TestLock(ServiceTestCase): def test__lock_ok(self): """ Succesfully grab a service lock. """ my_kvdb = FakeKVDB() my_kvdb.conn.setnx_return_value = True lock_name = rand_string() expires = 500 + rand_int() # It's 500 which means DummyService.invoke has that many seconds to complete timeout = rand_int() class DummyService(Service): kvdb = my_kvdb def handle(self): with self.lock(lock_name, expires, timeout): pass instance = DummyService() instance.handle() eq_(my_kvdb.conn.delete_args, KVDB.LOCK_SERVICE_PREFIX + lock_name) eq_(my_kvdb.conn.expire_args, (KVDB.LOCK_SERVICE_PREFIX + lock_name, expires)) # First arg is the lock_name that can ne checked directly but the other # one is the expiration time that we can check only approximately, # anything within 3 seconds range is OK. The value of 3 is the maximum # time allowed for execution of DummyService's invoke method which is # way more than needed but let's use 3 to be on the safe side when the # test is run on a very slow system. eq_(my_kvdb.conn.setnx_args[0], KVDB.LOCK_SERVICE_PREFIX + lock_name) expires_approx = time() + expires self.assertAlmostEquals(my_kvdb.conn.setnx_args[1], expires_approx, delta=3) def test__lock_timeout(self): """ A timeout is caught while trying to obtain a service lock. """ my_kvdb = FakeKVDB() my_kvdb.conn.setnx_return_value = False lock_name = rand_string() expires = rand_int() timeout = -1 class DummyService(Service): kvdb = my_kvdb def handle(self): with self.lock(lock_name, expires, timeout): pass instance = DummyService() try: instance.handle() except LockTimeout, e: eq_(e.message, 'Timeout while waiting for lock') else: self.fail('LockTimeout not raised') # ################################################################################################################################ class TestHTTPRequestData(TestCase): def test__empty(self): data = HTTPRequestData() self.assertEquals(data.GET, None) self.assertEquals(data.POST, None) self.assertEquals(data.method, None) def test__non_empty(self): get1, get2 = uuid4().hex, uuid4().hex post1, post2 = uuid4().hex, uuid4().hex request_method = uuid4().hex wsgi_environ = { 'REQUEST_METHOD': request_method, 'zato.http.GET': {'get1':get1, 'get2':get2}, 'zato.http.POST': {'post1':post1, 'post2':post2}, } data = HTTPRequestData() data.init(wsgi_environ) self.assertEquals(data.method, request_method) self.assertEquals(sorted(data.GET.items()), [('get1', get1), ('get2', get2)]) self.assertEquals(sorted(data.POST.items()), [('post1', post1), ('post2', post2)]) # ################################################################################################################################ class TestRequest(TestCase): def test__init_no_sio(self): is_sio = False cid = uuid4().hex data_format = uuid4().hex io = uuid4().hex wsgi_environ = { 'zato.http.GET': {uuid4().hex:uuid4().hex}, 'zato.http.POST': {uuid4().hex:uuid4().hex}, 'REQUEST_METHOD': uuid4().hex, } for transport in(None, URL_TYPE.PLAIN_HTTP, URL_TYPE.SOAP): request = Request(None) request.http.init(wsgi_environ) request.init(is_sio, cid, io, data_format, transport, wsgi_environ) eq_(request.http.method, wsgi_environ['REQUEST_METHOD']) eq_(sorted(request.http.GET.items()), sorted(wsgi_environ['zato.http.GET'].items())) eq_(sorted(request.http.POST.items()), sorted(wsgi_environ['zato.http.POST'].items())) def test_init_sio(self): is_sio = True cid = uuid4().hex data_format = uuid4().hex transport = uuid4().hex io_default = {'dummy':'dummy'} io_custom = Bunch({ 'request_elem': uuid4().hex, 'input_required': ['a', 'b', 'c'], 'input_optional': ['d', 'e', 'f'], 'default_value': uuid4().hex, 'use_text': uuid4().hex, }) wsgi_environ = { 'zato.http.GET': {uuid4().hex:uuid4().hex}, 'zato.http.POST': {uuid4().hex:uuid4().hex}, 'REQUEST_METHOD': uuid4().hex, } for io in(io_default, io_custom): for params_priority in PARAMS_PRIORITY: request = Request(logger) request.payload = None request.raw_request = io_default request.channel_params['a'] = 'channel_param_a' request.channel_params['b'] = 'channel_param_b' request.channel_params['c'] = 'channel_param_c' request.channel_params['d'] = 'channel_param_d' request.channel_params['e'] = 'channel_param_e' request.channel_params['f'] = 'channel_param_f' request.channel_params['h'] = 'channel_param_h' # Never overridden def _get_params(request_params, *ignored): # Note that 'g' is never overridden if params_priority == PARAMS_PRIORITY.CHANNEL_PARAMS_OVER_MSG: if request_params is io_custom['input_required']: return {'a':request.channel_params['a'], 'b':request.channel_params['b'], 'c':request.channel_params['c'], 'g':'g-msg'} else: return {'d':request.channel_params['d'], 'e':request.channel_params['e'], 'f':request.channel_params['f'], 'g':'g-msg'} else: if request_params is io_custom['input_required']: return {'a':'a-req', 'b':'b-req', 'c':'c-req', 'g':'g-msg'} else: return {'d':'d-opt', 'e':'e-opt', 'f':'f-opt', 'g':'g-msg'} request.get_params = _get_params request.params_priority = params_priority request.http.init(wsgi_environ) request.payload = io request.init(is_sio, cid, io, data_format, transport, wsgi_environ) if io is io_default: eq_(sorted(request.input.items()), sorted({'a': 'channel_param_a', 'b': 'channel_param_b', 'c':'channel_param_c', 'd': 'channel_param_d', 'e': 'channel_param_e', 'f': 'channel_param_f', 'h':'channel_param_h'}.items())) else: if params_priority == PARAMS_PRIORITY.CHANNEL_PARAMS_OVER_MSG: eq_(sorted(request.input.items()), sorted({'a': 'channel_param_a', 'b': 'channel_param_b', 'c': 'channel_param_c', 'd': 'channel_param_d', 'e': 'channel_param_e', 'f': 'channel_param_f', 'g': 'g-msg', 'h':'channel_param_h'}.items())) else: eq_(sorted(request.input.items()), sorted({'a': 'a-req', 'b': 'b-req', 'c': 'c-req', 'd': 'd-opt', 'e': 'e-opt', 'f': 'f-opt', 'g': 'g-msg', 'h':'channel_param_h'}.items())) # ################################################################################################################################ class TestSIOListDataType(ServiceTestCase): # https://github.com/zatosource/zato/issues/114 def test__sio_list_data_type_input_json(self): cid = rand_string() data_format = DATA_FORMAT.JSON transport = rand_string() sio_config = {'int_parameters': [rand_string()]} # Not really used but needed service_sio = Bunch() service_sio.input_required = ('first_name', 'last_name', List('emails')) expected_first_name = faker.first_name() expected_last_name = faker.last_name() expected_emails = sorted([faker.email(), faker.email()]) r = Request(getLogger(__name__), sio_config) r.payload = { 'first_name': expected_first_name, 'last_name': expected_last_name, 'emails': expected_emails, } r.init(True, cid, service_sio, data_format, transport, {}) eq_(r.input.first_name, expected_first_name) eq_(r.input.last_name, expected_last_name) eq_(r.input.emails, expected_emails) def test__sio_list_data_type_input_xml(self): cid = rand_string() data_format = DATA_FORMAT.XML transport = rand_string() sio_config = {'int_parameters': [rand_string()]} # Not really used but needed service_sio = Bunch() service_sio.input_required = ('first_name', 'last_name', List('emails')) expected_first_name = faker.first_name() expected_last_name = faker.last_name() expected_emails = sorted([faker.email(), faker.email()]) r = Request(getLogger(__name__), sio_config) r.payload = etree.fromstring("""<request> <first_name>{}</first_name> <last_name>{}</last_name> <emails> <item>{}</item> <item>{}</item> </emails> </request>""".format( expected_first_name, expected_last_name, expected_emails[0], expected_emails[1])) r.init(True, cid, service_sio, data_format, transport, {}) eq_(r.input.first_name, expected_first_name) eq_(r.input.last_name, expected_last_name) eq_(r.input.emails, expected_emails) def test__sio_list_data_type_output_json(self): expected_first_name = faker.first_name() expected_last_name = faker.last_name() expected_emails = sorted([faker.email(), faker.email()]) class MyService(Service): class SimpleIO: output_required = ('first_name', 'last_name', List('emails')) def handle(self): self.response.payload.first_name = expected_first_name self.response.payload.last_name = expected_last_name self.response.payload.emails = expected_emails instance = self.invoke(MyService, {}, None, data_format=DATA_FORMAT.JSON) response = loads(instance.response.payload.getvalue(True))['response'] eq_(response['first_name'], expected_first_name) eq_(response['last_name'], expected_last_name) eq_(response['emails'], expected_emails) def test__sio_list_data_type_output_xml(self): expected_first_name = faker.first_name() expected_last_name = faker.last_name() expected_emails = sorted([faker.email(), faker.email()]) class MyService(Service): class SimpleIO: output_required = ('first_name', 'last_name', List('emails')) def handle(self): self.response.payload.first_name = expected_first_name self.response.payload.last_name = expected_last_name self.response.payload.emails = expected_emails instance = self.invoke(MyService, {}, None, data_format=DATA_FORMAT.XML) response = instance.response.payload.getvalue(True) data = objectify.fromstring(response).xpath('/response/item')[0] eq_(data.first_name.text, expected_first_name) eq_(data.last_name.text, expected_last_name) eq_(data.emails.xpath('item'), expected_emails) # ################################################################################################################################ class TestNav(TestCase): # # https://github.com/zatosource/zato/issues/209 def test_dictnav(self): key1, key2, key3 = 'a', 'b', 'c' value = rand_string() d = { 'flat': 123, 'nested':{ key1: {key2: {key3: value}} } } class MyService(Service): def handle(self): dn = self.dictnav(self.request.input) response = { 'key1': sorted(dn.get(['nested', 'a']).items()), 'value': dn.get(['nested', 'a', 'b', 'c']), 'has_key_flat_true': dn.has_key('flat', False), 'has_key_flat_false': dn.has_key(rand_string(), True), 'has_key_nested_true': dn.has_key('b'), 'has_key_nested_false': dn.has_key(rand_string()), 'has_path': dn.has_path(['nested', 'a', 'b', 'c']), } self.response.payload = response service = MyService() service.request.input = d service.handle() eq_(service.response.payload['key1'], [('b', {'c': value})]) eq_(service.response.payload['value'], value) eq_(service.response.payload['has_key_flat_true'], True) eq_(service.response.payload['has_key_flat_false'], False) eq_(service.response.payload['has_key_nested_true'], True) eq_(service.response.payload['has_key_nested_false'], False) eq_(service.response.payload['has_path'], True) def test__listnav(self): self.test_dictnav() # Right now dictnav and listnav do the same thing # ################################################################################################################################ class RESTTargetType(ServiceTestCase): # https://github.com/zatosource/zato/issues/177 def test__add_http_method_handlers(self): class MyService(Service): def handle(self): pass def handle_GET(self): pass def handle_POST(self): pass class MyService2(Service): pass MyService.add_http_method_handlers() self.assertIs(MyService.http_method_handlers['POST'].im_func, MyService.handle_POST.im_func) MyService2.add_http_method_handlers() self.assertDictEqual(MyService2.http_method_handlers, {})
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 7384, 334, 35, 9, 6171, 577, 759, 527, 90, 32753, 79, 74, 350, 665, 795, 2133, 737, 1315, 11318, 14, 2308, 30, 199, 199, 31661, 1334, 491, 28863, 19, 12, 1937, 5113, 14, 2424, 367, 2895, 436, 3704, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 2649, 63, 5955, 199, 199, 3, 26678, 199, 646, 6073, 199, 504, 2022, 492, 14404, 199, 504, 2050, 492, 28138, 12, 24008, 199, 504, 900, 492, 900, 199, 504, 2882, 492, 7640, 199, 504, 5377, 492, 5377, 20, 199, 199, 3, 699, 4689, 199, 504, 22219, 492, 699, 4689, 199, 199, 3, 289, 12630, 199, 504, 289, 12630, 492, 481, 12630, 199, 199, 3, 14490, 199, 504, 14490, 492, 7559, 12, 1559, 825, 3338, 199, 199, 3, 11354, 199, 504, 11354, 14, 2537, 492, 3850, 63, 199, 199, 3, 295, 2537, 199, 504, 295, 2537, 14, 831, 492, 15536, 6372, 199, 199, 3, 3107, 11318, 199, 504, 1315, 11318, 14, 2330, 492, 6624, 13935, 12, 7126, 63, 4807, 12, 1804, 54, 2846, 12, 16565, 51, 63, 25144, 12, 971, 1362, 428, 22492, 1293, 540, 12, 2851, 63, 2711, 199, 504, 1315, 11318, 14, 2330, 14, 396, 492, 7777, 43, 54, 2846, 12, 10261, 63, 875, 12, 10261, 63, 442, 12, 7591, 1746, 199, 504, 1315, 11318, 14, 1000, 14, 1364, 492, 3820, 12, 7591, 199, 504, 1315, 11318, 14, 1000, 14, 1364, 14, 2103, 4518, 492, 3101, 2017, 1451, 12, 4784, 199, 199, 2921, 275, 28138, 3460, 354, 3368, 199, 667, 2570, 275, 481, 12630, 342, 199, 199, 3, 15779, 3060, 199, 199, 533, 24837, 83, 1746, 8, 3167, 1746, 304, 272, 347, 511, 363, 7922, 8, 277, 304, 2728, 1021, 4932, 6694, 8, 3167, 304, 288, 347, 2429, 8, 277, 304, 355, 986, 7846, 347, 2544, 63, 2479, 8, 277, 304, 355, 291, 14, 2314, 459, 5182, 63, 2479, 63, 3527, 418, 275, 715, 7846, 347, 2544, 63, 2423, 8, 277, 304, 355, 291, 14, 2314, 459, 5182, 63, 2423, 63, 3527, 418, 275, 715, 7846, 347, 2544, 63, 368, 63, 521, 63, 2423, 8, 277, 304, 355, 291, 14, 2314, 459, 5182, 63, 368, 63, 521, 63, 2423, 63, 3527, 418, 275, 715, 7846, 347, 2410, 63, 2479, 8, 277, 304, 355, 291, 14, 2314, 459, 4399, 63, 2479, 63, 3527, 418, 275, 715, 7846, 347, 2410, 63, 2423, 8, 277, 304, 355, 291, 14, 2314, 459, 4399, 63, 2423, 63, 3527, 418, 275, 715, 7846, 347, 2410, 63, 368, 63, 521, 63, 2423, 8, 277, 304, 355, 291, 14, 2314, 459, 4399, 63, 368, 63, 521, 63, 2423, 63, 3527, 418, 275, 715, 10631, 1256, 275, 291, 14, 15195, 8, 5713, 6694, 12, 5479, 5479, 3623, 29, 14833, 14, 27944, 1293, 540, 12, 3906, 63, 466, 29, 27944, 1293, 540, 14, 14879, 63, 2711, 14, 4817, 63, 4961, 9, 2728, 367, 536, 315, 360, 5182, 63, 2479, 297, 283, 5182, 63, 2423, 297, 283, 5182, 63, 368, 63, 521, 63, 2423, 297, 283, 4399, 63, 2479, 297, 283, 4399, 63, 2423, 297, 283, 4399, 63, 368, 63, 521, 63, 2423, 735, 288, 3850, 2531, 842, 14, 2314, 459, 2440, 63, 3527, 1370, 908, 8, 354, 4360, 715, 9, 199, 199, 3, 15779, 3060, 199, 199, 533, 1379, 2445, 3205, 2959, 8, 3167, 1746, 304, 272, 347, 511, 363, 793, 63, 1210, 63, 1199, 8, 277, 304, 2728, 1021, 4932, 4455, 8, 785, 304, 288, 347, 636, 826, 721, 277, 304, 355, 291, 14, 1896, 275, 488, 355, 291, 14, 1328, 275, 488, 24850, 347, 943, 8, 277, 12, 2166, 12, 1499, 304, 355, 291, 14, 1896, 275, 2166, 355, 291, 14, 1328, 275, 1499, 21695, 1021, 9762, 3167, 8, 3167, 304, 288, 347, 2429, 8, 277, 304, 355, 291, 14, 2921, 275, 4932, 4455, 342, 2728, 1256, 275, 291, 14, 15195, 8, 11324, 3167, 12, 5479, 5009, 2728, 2166, 275, 5377, 20, 1252, 4097, 267, 922, 63, 1328, 275, 5377, 20, 1252, 4097, 2728, 1256, 423, 793, 63, 1210, 63, 1199, 8, 751, 63, 1328, 12, 2166, 12, 5479, 715, 9, 267, 3850, 2531, 842, 14, 2921, 14, 1896, 12, 2166, 9, 267, 291, 14, 1815, 8, 842, 14, 2921, 14, 1328, 14, 2460, 17519, 1987, 908, 8, 751, 63, 1328, 1724, 2728, 1256, 14, 793, 63, 1210, 342, 267, 3850, 2531, 842, 14, 2921, 14, 1896, 12, 24008, 9, 267, 1499, 275, 6073, 14, 8939, 63, 2579, 8, 842, 14, 2921, 14, 1328, 9, 267, 3850, 2531, 5917, 8, 1328, 395, 788, 2775, 297, 283, 7504, 297, 283, 576, 63, 908, 297, 283, 2314, 297, 221, 2574, 283, 5472, 63, 354, 297, 283, 30158, 63, 521, 297, 283, 2423, 63, 466, 297, 283, 354, 297, 221, 2574, 283, 1069, 14, 4749, 297, 283, 14362, 63, 7227, 297, 399, 7, 3807, 297, 221, 2574, 283, 6508, 63, 2314, 1105, 398, 1256, 14, 793, 63, 1199, 342, 267, 3850, 2531, 842, 14, 2921, 14, 1896, 12, 24008, 9, 267, 1499, 275, 6073, 14, 8939, 63, 2579, 8, 842, 14, 2921, 14, 1328, 9, 267, 3850, 2531, 5917, 8, 1328, 395, 788, 2775, 297, 283, 7504, 297, 283, 576, 63, 908, 297, 283, 2314, 297, 221, 2574, 283, 2479, 63, 1107, 63, 521, 297, 283, 5472, 63, 354, 297, 283, 30158, 63, 521, 297, 221, 2574, 283, 2423, 63, 466, 297, 283, 354, 297, 283, 6338, 63, 521, 297, 283, 6338, 63, 521, 63, 1773, 297, 221, 2574, 283, 1310, 14, 4749, 297, 283, 14362, 63, 7227, 297, 283, 3807, 297, 221, 2574, 283, 6508, 63, 2314, 297, 283, 90, 11318, 14, 1014, 14, 1310, 14, 2139, 1105, 199, 199, 3, 15779, 3060, 199, 199, 533, 1379, 6432, 8, 3167, 1746, 304, 272, 347, 511, 363, 831, 63, 745, 8, 277, 304, 267, 408, 428, 947, 823, 5836, 18200, 282, 2435, 4650, 14, 267, 408, 4960, 3002, 63, 11475, 697, 275, 7777, 43, 54, 2846, 342, 267, 3002, 63, 11475, 697, 14, 1631, 14, 409, 7343, 63, 1107, 63, 585, 275, 715, 2728, 4650, 63, 354, 275, 10261, 63, 875, 342, 267, 12261 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 7384, 334, 35, 9, 6171, 577, 759, 527, 90, 32753, 79, 74, 350, 665, 795, 2133, 737, 1315, 11318, 14, 2308, 30, 199, 199, 31661, 1334, 491, 28863, 19, 12, 1937, 5113, 14, 2424, 367, 2895, 436, 3704, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 2649, 63, 5955, 199, 199, 3, 26678, 199, 646, 6073, 199, 504, 2022, 492, 14404, 199, 504, 2050, 492, 28138, 12, 24008, 199, 504, 900, 492, 900, 199, 504, 2882, 492, 7640, 199, 504, 5377, 492, 5377, 20, 199, 199, 3, 699, 4689, 199, 504, 22219, 492, 699, 4689, 199, 199, 3, 289, 12630, 199, 504, 289, 12630, 492, 481, 12630, 199, 199, 3, 14490, 199, 504, 14490, 492, 7559, 12, 1559, 825, 3338, 199, 199, 3, 11354, 199, 504, 11354, 14, 2537, 492, 3850, 63, 199, 199, 3, 295, 2537, 199, 504, 295, 2537, 14, 831, 492, 15536, 6372, 199, 199, 3, 3107, 11318, 199, 504, 1315, 11318, 14, 2330, 492, 6624, 13935, 12, 7126, 63, 4807, 12, 1804, 54, 2846, 12, 16565, 51, 63, 25144, 12, 971, 1362, 428, 22492, 1293, 540, 12, 2851, 63, 2711, 199, 504, 1315, 11318, 14, 2330, 14, 396, 492, 7777, 43, 54, 2846, 12, 10261, 63, 875, 12, 10261, 63, 442, 12, 7591, 1746, 199, 504, 1315, 11318, 14, 1000, 14, 1364, 492, 3820, 12, 7591, 199, 504, 1315, 11318, 14, 1000, 14, 1364, 14, 2103, 4518, 492, 3101, 2017, 1451, 12, 4784, 199, 199, 2921, 275, 28138, 3460, 354, 3368, 199, 667, 2570, 275, 481, 12630, 342, 199, 199, 3, 15779, 3060, 199, 199, 533, 24837, 83, 1746, 8, 3167, 1746, 304, 272, 347, 511, 363, 7922, 8, 277, 304, 2728, 1021, 4932, 6694, 8, 3167, 304, 288, 347, 2429, 8, 277, 304, 355, 986, 7846, 347, 2544, 63, 2479, 8, 277, 304, 355, 291, 14, 2314, 459, 5182, 63, 2479, 63, 3527, 418, 275, 715, 7846, 347, 2544, 63, 2423, 8, 277, 304, 355, 291, 14, 2314, 459, 5182, 63, 2423, 63, 3527, 418, 275, 715, 7846, 347, 2544, 63, 368, 63, 521, 63, 2423, 8, 277, 304, 355, 291, 14, 2314, 459, 5182, 63, 368, 63, 521, 63, 2423, 63, 3527, 418, 275, 715, 7846, 347, 2410, 63, 2479, 8, 277, 304, 355, 291, 14, 2314, 459, 4399, 63, 2479, 63, 3527, 418, 275, 715, 7846, 347, 2410, 63, 2423, 8, 277, 304, 355, 291, 14, 2314, 459, 4399, 63, 2423, 63, 3527, 418, 275, 715, 7846, 347, 2410, 63, 368, 63, 521, 63, 2423, 8, 277, 304, 355, 291, 14, 2314, 459, 4399, 63, 368, 63, 521, 63, 2423, 63, 3527, 418, 275, 715, 10631, 1256, 275, 291, 14, 15195, 8, 5713, 6694, 12, 5479, 5479, 3623, 29, 14833, 14, 27944, 1293, 540, 12, 3906, 63, 466, 29, 27944, 1293, 540, 14, 14879, 63, 2711, 14, 4817, 63, 4961, 9, 2728, 367, 536, 315, 360, 5182, 63, 2479, 297, 283, 5182, 63, 2423, 297, 283, 5182, 63, 368, 63, 521, 63, 2423, 297, 283, 4399, 63, 2479, 297, 283, 4399, 63, 2423, 297, 283, 4399, 63, 368, 63, 521, 63, 2423, 735, 288, 3850, 2531, 842, 14, 2314, 459, 2440, 63, 3527, 1370, 908, 8, 354, 4360, 715, 9, 199, 199, 3, 15779, 3060, 199, 199, 533, 1379, 2445, 3205, 2959, 8, 3167, 1746, 304, 272, 347, 511, 363, 793, 63, 1210, 63, 1199, 8, 277, 304, 2728, 1021, 4932, 4455, 8, 785, 304, 288, 347, 636, 826, 721, 277, 304, 355, 291, 14, 1896, 275, 488, 355, 291, 14, 1328, 275, 488, 24850, 347, 943, 8, 277, 12, 2166, 12, 1499, 304, 355, 291, 14, 1896, 275, 2166, 355, 291, 14, 1328, 275, 1499, 21695, 1021, 9762, 3167, 8, 3167, 304, 288, 347, 2429, 8, 277, 304, 355, 291, 14, 2921, 275, 4932, 4455, 342, 2728, 1256, 275, 291, 14, 15195, 8, 11324, 3167, 12, 5479, 5009, 2728, 2166, 275, 5377, 20, 1252, 4097, 267, 922, 63, 1328, 275, 5377, 20, 1252, 4097, 2728, 1256, 423, 793, 63, 1210, 63, 1199, 8, 751, 63, 1328, 12, 2166, 12, 5479, 715, 9, 267, 3850, 2531, 842, 14, 2921, 14, 1896, 12, 2166, 9, 267, 291, 14, 1815, 8, 842, 14, 2921, 14, 1328, 14, 2460, 17519, 1987, 908, 8, 751, 63, 1328, 1724, 2728, 1256, 14, 793, 63, 1210, 342, 267, 3850, 2531, 842, 14, 2921, 14, 1896, 12, 24008, 9, 267, 1499, 275, 6073, 14, 8939, 63, 2579, 8, 842, 14, 2921, 14, 1328, 9, 267, 3850, 2531, 5917, 8, 1328, 395, 788, 2775, 297, 283, 7504, 297, 283, 576, 63, 908, 297, 283, 2314, 297, 221, 2574, 283, 5472, 63, 354, 297, 283, 30158, 63, 521, 297, 283, 2423, 63, 466, 297, 283, 354, 297, 221, 2574, 283, 1069, 14, 4749, 297, 283, 14362, 63, 7227, 297, 399, 7, 3807, 297, 221, 2574, 283, 6508, 63, 2314, 1105, 398, 1256, 14, 793, 63, 1199, 342, 267, 3850, 2531, 842, 14, 2921, 14, 1896, 12, 24008, 9, 267, 1499, 275, 6073, 14, 8939, 63, 2579, 8, 842, 14, 2921, 14, 1328, 9, 267, 3850, 2531, 5917, 8, 1328, 395, 788, 2775, 297, 283, 7504, 297, 283, 576, 63, 908, 297, 283, 2314, 297, 221, 2574, 283, 2479, 63, 1107, 63, 521, 297, 283, 5472, 63, 354, 297, 283, 30158, 63, 521, 297, 221, 2574, 283, 2423, 63, 466, 297, 283, 354, 297, 283, 6338, 63, 521, 297, 283, 6338, 63, 521, 63, 1773, 297, 221, 2574, 283, 1310, 14, 4749, 297, 283, 14362, 63, 7227, 297, 283, 3807, 297, 221, 2574, 283, 6508, 63, 2314, 297, 283, 90, 11318, 14, 1014, 14, 1310, 14, 2139, 1105, 199, 199, 3, 15779, 3060, 199, 199, 533, 1379, 6432, 8, 3167, 1746, 304, 272, 347, 511, 363, 831, 63, 745, 8, 277, 304, 267, 408, 428, 947, 823, 5836, 18200, 282, 2435, 4650, 14, 267, 408, 4960, 3002, 63, 11475, 697, 275, 7777, 43, 54, 2846, 342, 267, 3002, 63, 11475, 697, 14, 1631, 14, 409, 7343, 63, 1107, 63, 585, 275, 715, 2728, 4650, 63, 354, 275, 10261, 63, 875, 342, 267, 12261, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
TheTypoMaster/my-vim-set-mac
.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/extra_conf_store.py
20
7323
#!/usr/bin/env python # # Copyright (C) 2011, 2012 Google Inc. # # This file is part of YouCompleteMe. # # YouCompleteMe 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. # # YouCompleteMe 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 YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. # NOTE: This module is used as a Singleton import os import imp import random import string import sys import logging from threading import Lock from ycmd import user_options_store from ycmd.responses import UnknownExtraConf, YCM_EXTRA_CONF_FILENAME from fnmatch import fnmatch # Singleton variables _module_for_module_file = {} _module_for_module_file_lock = Lock() _module_file_for_source_file = {} _module_file_for_source_file_lock = Lock() def Reset(): global _module_for_module_file, _module_file_for_source_file _module_for_module_file = {} _module_file_for_source_file = {} def ModuleForSourceFile( filename ): return Load( ModuleFileForSourceFile( filename ) ) def ModuleFileForSourceFile( filename ): """This will try all files returned by _ExtraConfModuleSourceFilesForFile in order and return the filename of the first module that was allowed to load. If no module was found or allowed to load, None is returned.""" with _module_file_for_source_file_lock: if not filename in _module_file_for_source_file: for module_file in _ExtraConfModuleSourceFilesForFile( filename ): if Load( module_file ): _module_file_for_source_file[ filename ] = module_file break return _module_file_for_source_file.setdefault( filename ) def CallGlobalExtraConfYcmCorePreloadIfExists(): _CallGlobalExtraConfMethod( 'YcmCorePreload' ) def Shutdown(): # VimClose is for the sake of backwards compatibility; it's a no-op when it # doesn't exist. _CallGlobalExtraConfMethod( 'VimClose' ) _CallGlobalExtraConfMethod( 'Shutdown' ) def _CallGlobalExtraConfMethod( function_name ): logger = _Logger() global_ycm_extra_conf = _GlobalYcmExtraConfFileLocation() if not ( global_ycm_extra_conf and os.path.exists( global_ycm_extra_conf ) ): logger.debug( 'No global extra conf, not calling method ' + function_name ) return module = Load( global_ycm_extra_conf, force = True ) if not module or not hasattr( module, function_name ): logger.debug( 'Global extra conf not loaded or no function ' + function_name ) return logger.info( 'Calling global extra conf method {0} on conf file {1}'.format( function_name, global_ycm_extra_conf ) ) getattr( module, function_name )() def Disable( module_file ): """Disables the loading of a module for the current session.""" with _module_for_module_file_lock: _module_for_module_file[ module_file ] = None def _ShouldLoad( module_file ): """Checks if a module is safe to be loaded. By default this will try to decide using a white-/blacklist and ask the user for confirmation as a fallback.""" if ( module_file == _GlobalYcmExtraConfFileLocation() or not user_options_store.Value( 'confirm_extra_conf' ) ): return True globlist = user_options_store.Value( 'extra_conf_globlist' ) for glob in globlist: is_blacklisted = glob[0] == '!' if _MatchesGlobPattern( module_file, glob.lstrip('!') ): return not is_blacklisted raise UnknownExtraConf( module_file ) def Load( module_file, force = False ): """Load and return the module contained in a file. Using force = True the module will be loaded regardless of the criteria in _ShouldLoad. This will return None if the module was not allowed to be loaded.""" if not module_file: return None if not force: with _module_for_module_file_lock: if module_file in _module_for_module_file: return _module_for_module_file[ module_file ] if not _ShouldLoad( module_file ): Disable( module_file ) return None # This has to be here because a long time ago, the ycm_extra_conf.py files # used to import clang_helpers.py from the cpp folder. This is not needed # anymore, but there are a lot of old ycm_extra_conf.py files that we don't # want to break. sys.path.insert( 0, _PathToCppCompleterFolder() ) module = imp.load_source( _RandomName(), module_file ) del sys.path[ 0 ] with _module_for_module_file_lock: _module_for_module_file[ module_file ] = module return module def _MatchesGlobPattern( filename, glob ): """Returns true if a filename matches a given pattern. A '~' in glob will be expanded to the home directory and checking will be performed using absolute paths. See the documentation of fnmatch for the supported patterns.""" abspath = os.path.abspath( filename ) return fnmatch( abspath, os.path.abspath( os.path.expanduser( glob ) ) ) def _ExtraConfModuleSourceFilesForFile( filename ): """For a given filename, search all parent folders for YCM_EXTRA_CONF_FILENAME files that will compute the flags necessary to compile the file. If _GlobalYcmExtraConfFileLocation() exists it is returned as a fallback.""" for folder in _PathsToAllParentFolders( filename ): candidate = os.path.join( folder, YCM_EXTRA_CONF_FILENAME ) if os.path.exists( candidate ): yield candidate global_ycm_extra_conf = _GlobalYcmExtraConfFileLocation() if ( global_ycm_extra_conf and os.path.exists( global_ycm_extra_conf ) ): yield global_ycm_extra_conf def _PathsToAllParentFolders( filename ): """Build a list of all parent folders of a file. The nearest folders will be returned first. Example: _PathsToAllParentFolders( '/home/user/projects/test.c' ) [ '/home/user/projects', '/home/user', '/home', '/' ]""" def PathFolderComponents( filename ): folders = [] path = os.path.dirname( filename ) while True: path, folder = os.path.split( path ) if folder: folders.append( folder ) else: if path: folders.append( path ) break return list( reversed( folders ) ) parent_folders = PathFolderComponents( filename ) parent_folders = [ os.path.join( *parent_folders[:i + 1] ) for i in xrange( len( parent_folders ) ) ] return reversed( parent_folders ) def _PathToCppCompleterFolder(): """Returns the path to the 'cpp' completer folder. This is necessary because ycm_extra_conf files need it on the path.""" return os.path.join( _DirectoryOfThisScript(), 'completers', 'cpp' ) def _DirectoryOfThisScript(): return os.path.dirname( os.path.abspath( __file__ ) ) def _RandomName(): """Generates a random module name.""" return ''.join( random.choice( string.ascii_lowercase ) for x in range( 15 ) ) def _GlobalYcmExtraConfFileLocation(): return os.path.expanduser( user_options_store.Value( 'global_ycm_extra_conf' ) ) def _Logger(): return logging.getLogger( __name__ )
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 35, 9, 7760, 12, 6029, 221, 4475, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2047, 14175, 1352, 14, 199, 3, 199, 3, 2047, 14175, 1352, 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, 2047, 14175, 1352, 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, 2047, 14175, 1352, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 6944, 26, 961, 859, 365, 1202, 465, 282, 13050, 1860, 199, 199, 646, 747, 199, 646, 1742, 199, 646, 2196, 199, 646, 1059, 199, 646, 984, 199, 646, 2050, 199, 504, 5796, 492, 15536, 199, 504, 612, 1760, 492, 922, 63, 1419, 63, 1617, 199, 504, 612, 1760, 14, 10360, 492, 14831, 7426, 8930, 12, 1488, 9249, 63, 18555, 63, 3103, 63, 15440, 199, 504, 15951, 492, 15951, 421, 199, 3, 13050, 1860, 2860, 199, 63, 578, 63, 509, 63, 578, 63, 493, 275, 1052, 199, 63, 578, 63, 509, 63, 578, 63, 493, 63, 831, 275, 15536, 342, 199, 63, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 275, 1052, 199, 63, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 63, 831, 275, 15536, 342, 421, 199, 318, 15510, 837, 523, 2288, 485, 578, 63, 509, 63, 578, 63, 493, 12, 485, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 523, 485, 578, 63, 509, 63, 578, 63, 493, 275, 1052, 523, 485, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 275, 1052, 421, 199, 318, 5673, 1858, 2980, 1173, 8, 1788, 3461, 523, 372, 7190, 8, 5673, 1173, 1858, 2980, 1173, 8, 1788, 776, 776, 421, 199, 318, 5673, 1173, 1858, 2980, 1173, 8, 1788, 3461, 523, 408, 2765, 911, 862, 1006, 1584, 2138, 701, 485, 7426, 8930, 2377, 2980, 5535, 1858, 1173, 315, 523, 1865, 436, 372, 314, 1788, 402, 314, 1642, 859, 626, 1990, 4370, 370, 2248, 14, 523, 982, 949, 859, 1990, 1911, 503, 4370, 370, 2248, 12, 488, 365, 2138, 1041, 819, 543, 485, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 63, 831, 26, 272, 340, 440, 1788, 315, 485, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 26, 489, 367, 859, 63, 493, 315, 485, 7426, 8930, 2377, 2980, 5535, 1858, 1173, 8, 1788, 3461, 267, 340, 7190, 8, 859, 63, 493, 3461, 881, 485, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 59, 1788, 1622, 275, 859, 63, 493, 881, 2059, 819, 372, 485, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 14, 5486, 8, 1788, 776, 421, 199, 318, 6523, 7025, 7426, 8930, 57, 4400, 5402, 2398, 912, 3917, 7965, 837, 523, 485, 2176, 7025, 7426, 8930, 3767, 8, 283, 57, 4400, 5402, 2398, 912, 7, 776, 421, 199, 318, 5244, 6159, 837, 523, 327, 812, 1017, 4724, 365, 367, 314, 308, 1728, 402, 8552, 7163, 27, 652, 1159, 282, 949, 13, 411, 1380, 652, 523, 327, 3181, 1133, 2187, 14, 523, 485, 2176, 7025, 7426, 8930, 3767, 8, 283, 54, 1017, 4724, 7, 776, 523, 485, 2176, 7025, 7426, 8930, 3767, 8, 283, 20043, 7, 776, 421, 199, 318, 485, 2176, 7025, 7426, 8930, 3767, 8, 805, 63, 354, 3461, 523, 2512, 275, 485, 4455, 342, 523, 2288, 63, 89, 4400, 63, 2911, 63, 2190, 275, 485, 7025, 57, 4400, 7426, 8930, 1173, 6592, 342, 523, 340, 440, 334, 2288, 63, 89, 4400, 63, 2911, 63, 2190, 436, 1779, 747, 14, 515, 14, 2444, 8, 2288, 63, 89, 4400, 63, 2911, 63, 2190, 776, 3461, 272, 2512, 14, 1757, 8, 283, 1944, 2288, 2402, 3743, 12, 440, 6358, 1083, 283, 435, 805, 63, 354, 776, 272, 372, 819, 859, 275, 7190, 8, 2288, 63, 89, 4400, 63, 2911, 63, 2190, 12, 3542, 275, 715, 776, 523, 340, 440, 859, 503, 440, 2688, 8, 859, 12, 805, 63, 354, 3461, 272, 2512, 14, 1757, 8, 283, 7025, 2402, 3743, 440, 6511, 503, 949, 805, 283, 435, 2116, 805, 63, 354, 776, 272, 372, 819, 2512, 14, 815, 8, 283, 23796, 2288, 2402, 3743, 1083, 469, 16, 93, 641, 3743, 570, 469, 17, 5285, 908, 8, 489, 805, 63, 354, 12, 2288, 63, 89, 4400, 63, 2911, 63, 2190, 776, 776, 523, 2519, 8, 859, 12, 805, 63, 354, 776, 342, 421, 199, 318, 17534, 8, 859, 63, 493, 3461, 523, 408, 2825, 5921, 314, 8697, 402, 282, 859, 367, 314, 1453, 2351, 1041, 523, 543, 485, 578, 63, 509, 63, 578, 63, 493, 63, 831, 26, 272, 485, 578, 63, 509, 63, 578, 63, 493, 59, 859, 63, 493, 1622, 275, 488, 421, 199, 318, 485, 11408, 6200, 8, 859, 63, 493, 3461, 523, 408, 11834, 340, 282, 859, 365, 5048, 370, 506, 6511, 14, 4885, 849, 642, 911, 862, 370, 523, 19822, 1808, 282, 10424, 13, 15, 22126, 436, 7198, 314, 922, 367, 18791, 465, 282, 523, 9567, 1041, 819, 340, 334, 859, 63, 493, 508, 485, 7025, 57, 4400, 7426, 8930, 1173, 6592, 342, 503, 2126, 440, 922, 63, 1419, 63, 1617, 14, 1110, 8, 283, 9548, 63, 2911, 63, 2190, 7, 776, 3461, 272, 372, 715, 819, 5739, 513, 275, 922, 63, 1419, 63, 1617, 14, 1110, 8, 283, 2911, 63, 2190, 63, 6463, 513, 7, 776, 523, 367, 5739, 315, 5739, 513, 26, 272, 365, 63, 8399, 15023, 275, 5739, 59, 16, 61, 508, 29376, 272, 340, 485, 12962, 25954, 9959, 8, 859, 63, 493, 12, 5739, 14, 10124, 360 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 35, 9, 7760, 12, 6029, 221, 4475, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2047, 14175, 1352, 14, 199, 3, 199, 3, 2047, 14175, 1352, 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, 2047, 14175, 1352, 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, 2047, 14175, 1352, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 6944, 26, 961, 859, 365, 1202, 465, 282, 13050, 1860, 199, 199, 646, 747, 199, 646, 1742, 199, 646, 2196, 199, 646, 1059, 199, 646, 984, 199, 646, 2050, 199, 504, 5796, 492, 15536, 199, 504, 612, 1760, 492, 922, 63, 1419, 63, 1617, 199, 504, 612, 1760, 14, 10360, 492, 14831, 7426, 8930, 12, 1488, 9249, 63, 18555, 63, 3103, 63, 15440, 199, 504, 15951, 492, 15951, 421, 199, 3, 13050, 1860, 2860, 199, 63, 578, 63, 509, 63, 578, 63, 493, 275, 1052, 199, 63, 578, 63, 509, 63, 578, 63, 493, 63, 831, 275, 15536, 342, 199, 63, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 275, 1052, 199, 63, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 63, 831, 275, 15536, 342, 421, 199, 318, 15510, 837, 523, 2288, 485, 578, 63, 509, 63, 578, 63, 493, 12, 485, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 523, 485, 578, 63, 509, 63, 578, 63, 493, 275, 1052, 523, 485, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 275, 1052, 421, 199, 318, 5673, 1858, 2980, 1173, 8, 1788, 3461, 523, 372, 7190, 8, 5673, 1173, 1858, 2980, 1173, 8, 1788, 776, 776, 421, 199, 318, 5673, 1173, 1858, 2980, 1173, 8, 1788, 3461, 523, 408, 2765, 911, 862, 1006, 1584, 2138, 701, 485, 7426, 8930, 2377, 2980, 5535, 1858, 1173, 315, 523, 1865, 436, 372, 314, 1788, 402, 314, 1642, 859, 626, 1990, 4370, 370, 2248, 14, 523, 982, 949, 859, 1990, 1911, 503, 4370, 370, 2248, 12, 488, 365, 2138, 1041, 819, 543, 485, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 63, 831, 26, 272, 340, 440, 1788, 315, 485, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 26, 489, 367, 859, 63, 493, 315, 485, 7426, 8930, 2377, 2980, 5535, 1858, 1173, 8, 1788, 3461, 267, 340, 7190, 8, 859, 63, 493, 3461, 881, 485, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 59, 1788, 1622, 275, 859, 63, 493, 881, 2059, 819, 372, 485, 578, 63, 493, 63, 509, 63, 1365, 63, 493, 14, 5486, 8, 1788, 776, 421, 199, 318, 6523, 7025, 7426, 8930, 57, 4400, 5402, 2398, 912, 3917, 7965, 837, 523, 485, 2176, 7025, 7426, 8930, 3767, 8, 283, 57, 4400, 5402, 2398, 912, 7, 776, 421, 199, 318, 5244, 6159, 837, 523, 327, 812, 1017, 4724, 365, 367, 314, 308, 1728, 402, 8552, 7163, 27, 652, 1159, 282, 949, 13, 411, 1380, 652, 523, 327, 3181, 1133, 2187, 14, 523, 485, 2176, 7025, 7426, 8930, 3767, 8, 283, 54, 1017, 4724, 7, 776, 523, 485, 2176, 7025, 7426, 8930, 3767, 8, 283, 20043, 7, 776, 421, 199, 318, 485, 2176, 7025, 7426, 8930, 3767, 8, 805, 63, 354, 3461, 523, 2512, 275, 485, 4455, 342, 523, 2288, 63, 89, 4400, 63, 2911, 63, 2190, 275, 485, 7025, 57, 4400, 7426, 8930, 1173, 6592, 342, 523, 340, 440, 334, 2288, 63, 89, 4400, 63, 2911, 63, 2190, 436, 1779, 747, 14, 515, 14, 2444, 8, 2288, 63, 89, 4400, 63, 2911, 63, 2190, 776, 3461, 272, 2512, 14, 1757, 8, 283, 1944, 2288, 2402, 3743, 12, 440, 6358, 1083, 283, 435, 805, 63, 354, 776, 272, 372, 819, 859, 275, 7190, 8, 2288, 63, 89, 4400, 63, 2911, 63, 2190, 12, 3542, 275, 715, 776, 523, 340, 440, 859, 503, 440, 2688, 8, 859, 12, 805, 63, 354, 3461, 272, 2512, 14, 1757, 8, 283, 7025, 2402, 3743, 440, 6511, 503, 949, 805, 283, 435, 2116, 805, 63, 354, 776, 272, 372, 819, 2512, 14, 815, 8, 283, 23796, 2288, 2402, 3743, 1083, 469, 16, 93, 641, 3743, 570, 469, 17, 5285, 908, 8, 489, 805, 63, 354, 12, 2288, 63, 89, 4400, 63, 2911, 63, 2190, 776, 776, 523, 2519, 8, 859, 12, 805, 63, 354, 776, 342, 421, 199, 318, 17534, 8, 859, 63, 493, 3461, 523, 408, 2825, 5921, 314, 8697, 402, 282, 859, 367, 314, 1453, 2351, 1041, 523, 543, 485, 578, 63, 509, 63, 578, 63, 493, 63, 831, 26, 272, 485, 578, 63, 509, 63, 578, 63, 493, 59, 859, 63, 493, 1622, 275, 488, 421, 199, 318, 485, 11408, 6200, 8, 859, 63, 493, 3461, 523, 408, 11834, 340, 282, 859, 365, 5048, 370, 506, 6511, 14, 4885, 849, 642, 911, 862, 370, 523, 19822, 1808, 282, 10424, 13, 15, 22126, 436, 7198, 314, 922, 367, 18791, 465, 282, 523, 9567, 1041, 819, 340, 334, 859, 63, 493, 508, 485, 7025, 57, 4400, 7426, 8930, 1173, 6592, 342, 503, 2126, 440, 922, 63, 1419, 63, 1617, 14, 1110, 8, 283, 9548, 63, 2911, 63, 2190, 7, 776, 3461, 272, 372, 715, 819, 5739, 513, 275, 922, 63, 1419, 63, 1617, 14, 1110, 8, 283, 2911, 63, 2190, 63, 6463, 513, 7, 776, 523, 367, 5739, 315, 5739, 513, 26, 272, 365, 63, 8399, 15023, 275, 5739, 59, 16, 61, 508, 29376, 272, 340, 485, 12962, 25954, 9959, 8, 859, 63, 493, 12, 5739, 14, 10124, 360, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
vponomaryov/manila
manila/share/drivers/dell_emc/plugins/vmax/constants.py
1
1753
# Copyright (c) 2016 Dell Inc. or its subsidiaries. # 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. STATUS_OK = 'ok' STATUS_INFO = 'info' STATUS_DEBUG = 'debug' STATUS_WARNING = 'warning' STATUS_ERROR = 'error' STATUS_NOT_FOUND = 'not_found' MSG_GENERAL_ERROR = '13690601492' MSG_INVALID_VDM_ID = '14227341325' MSG_INVALID_MOVER_ID = '14227341323' MSG_FILESYSTEM_NOT_FOUND = "18522112101" MSG_FILESYSTEM_EXIST = '13691191325' MSG_VDM_EXIST = '13421840550' MSG_SNAP_EXIST = '13690535947' MSG_INTERFACE_NAME_EXIST = '13421840550' MSG_INTERFACE_EXIST = '13691781136' MSG_INTERFACE_INVALID_VLAN_ID = '13421850371' MSG_INTERFACE_NON_EXISTENT = '13691781134' MSG_JOIN_DOMAIN = '13157007726' MSG_UNJOIN_DOMAIN = '13157007723' # Necessary to retry when VMAX database is locked for provisioning operation MSG_CODE_RETRY = '13421840537' IP_ALLOCATIONS = 2 CONTENT_TYPE_URLENCODE = {'Content-Type': 'application/x-www-form-urlencoded'} XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' XML_NAMESPACE = 'http://www.emc.com/schemas/celerra/xml_api' CIFS_ACL_FULLCONTROL = 'fullcontrol' CIFS_ACL_READ = 'read' SSH_DEFAULT_RETRY_PATTERN = r'Error 2201:.*: unable to acquire lock\(s\)'
apache-2.0
[ 3, 1898, 334, 67, 9, 7800, 577, 1697, 3277, 14, 503, 2399, 1007, 338, 328, 3433, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 6305, 63, 3593, 275, 283, 745, 7, 199, 6305, 63, 4531, 275, 283, 815, 7, 199, 6305, 63, 5287, 275, 283, 1757, 7, 199, 6305, 63, 9171, 275, 283, 3764, 7, 199, 6305, 63, 3170, 275, 283, 705, 7, 199, 6305, 63, 4609, 63, 13945, 275, 283, 1397, 63, 4214, 7, 199, 199, 9740, 63, 31548, 63, 3170, 275, 283, 969, 1876, 1690, 614, 25722, 7, 199, 9740, 63, 9692, 63, 54, 17751, 63, 998, 275, 283, 1079, 11385, 1082, 6557, 21, 7, 199, 9740, 63, 9692, 63, 2679, 2111, 63, 998, 275, 283, 1079, 11385, 1082, 6557, 19, 7, 199, 199, 9740, 63, 9472, 57, 9757, 63, 4609, 63, 13945, 275, 298, 10233, 1081, 6094, 4893, 2, 199, 9740, 63, 9472, 57, 9757, 63, 13301, 275, 283, 969, 1876, 845, 3328, 13288, 7, 199, 199, 9740, 63, 54, 17751, 63, 13301, 275, 283, 969, 2260, 1085, 2167, 16859, 7, 199, 199, 9740, 63, 22616, 63, 13301, 275, 283, 969, 1876, 1717, 11444, 2417, 7, 199, 199, 9740, 63, 17598, 63, 2339, 63, 13301, 275, 283, 969, 2260, 1085, 2167, 16859, 7, 199, 9740, 63, 17598, 63, 13301, 275, 283, 969, 1876, 11175, 845, 1344, 7, 199, 9740, 63, 17598, 63, 9692, 63, 22716, 63, 998, 275, 283, 969, 2260, 1085, 1400, 16124, 7, 199, 9740, 63, 17598, 63, 13887, 63, 13301, 1309, 275, 283, 969, 1876, 11175, 845, 1082, 7, 199, 199, 9740, 63, 23321, 63, 7378, 275, 283, 969, 10823, 31610, 1479, 7, 199, 9740, 63, 1734, 23321, 63, 7378, 275, 283, 969, 10823, 31610, 1789, 7, 199, 199, 3, 5612, 5205, 370, 7269, 1380, 812, 4283, 3050, 365, 14233, 367, 20118, 3439, 199, 9740, 63, 6012, 63, 27778, 275, 283, 969, 2260, 10078, 1717, 1401, 7, 199, 199, 1772, 63, 28605, 12969, 275, 499, 199, 199, 9663, 63, 2711, 63, 2632, 742, 6012, 275, 791, 2714, 13, 804, 356, 283, 3578, 15, 88, 13, 1544, 13, 964, 13, 21886, 936, 199, 199, 4317, 63, 7311, 275, 2650, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 2, 18042, 628, 5066, 14863, 3524, 199, 4317, 63, 13001, 275, 283, 1014, 921, 1544, 14, 69, 5466, 14, 957, 15, 9482, 15, 11338, 345, 15, 1652, 63, 1246, 7, 199, 199, 3553, 7079, 63, 18765, 63, 14742, 13060, 275, 283, 2861, 2785, 7, 199, 3553, 7079, 63, 18765, 63, 5670, 275, 283, 739, 7, 199, 199, 13716, 63, 3472, 63, 27778, 63, 10764, 275, 519, 7, 547, 499, 1797, 26, 2795, 26, 17329, 370, 16919, 4650, 24805, 83, 60, 3171, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 7800, 577, 1697, 3277, 14, 503, 2399, 1007, 338, 328, 3433, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 6305, 63, 3593, 275, 283, 745, 7, 199, 6305, 63, 4531, 275, 283, 815, 7, 199, 6305, 63, 5287, 275, 283, 1757, 7, 199, 6305, 63, 9171, 275, 283, 3764, 7, 199, 6305, 63, 3170, 275, 283, 705, 7, 199, 6305, 63, 4609, 63, 13945, 275, 283, 1397, 63, 4214, 7, 199, 199, 9740, 63, 31548, 63, 3170, 275, 283, 969, 1876, 1690, 614, 25722, 7, 199, 9740, 63, 9692, 63, 54, 17751, 63, 998, 275, 283, 1079, 11385, 1082, 6557, 21, 7, 199, 9740, 63, 9692, 63, 2679, 2111, 63, 998, 275, 283, 1079, 11385, 1082, 6557, 19, 7, 199, 199, 9740, 63, 9472, 57, 9757, 63, 4609, 63, 13945, 275, 298, 10233, 1081, 6094, 4893, 2, 199, 9740, 63, 9472, 57, 9757, 63, 13301, 275, 283, 969, 1876, 845, 3328, 13288, 7, 199, 199, 9740, 63, 54, 17751, 63, 13301, 275, 283, 969, 2260, 1085, 2167, 16859, 7, 199, 199, 9740, 63, 22616, 63, 13301, 275, 283, 969, 1876, 1717, 11444, 2417, 7, 199, 199, 9740, 63, 17598, 63, 2339, 63, 13301, 275, 283, 969, 2260, 1085, 2167, 16859, 7, 199, 9740, 63, 17598, 63, 13301, 275, 283, 969, 1876, 11175, 845, 1344, 7, 199, 9740, 63, 17598, 63, 9692, 63, 22716, 63, 998, 275, 283, 969, 2260, 1085, 1400, 16124, 7, 199, 9740, 63, 17598, 63, 13887, 63, 13301, 1309, 275, 283, 969, 1876, 11175, 845, 1082, 7, 199, 199, 9740, 63, 23321, 63, 7378, 275, 283, 969, 10823, 31610, 1479, 7, 199, 9740, 63, 1734, 23321, 63, 7378, 275, 283, 969, 10823, 31610, 1789, 7, 199, 199, 3, 5612, 5205, 370, 7269, 1380, 812, 4283, 3050, 365, 14233, 367, 20118, 3439, 199, 9740, 63, 6012, 63, 27778, 275, 283, 969, 2260, 10078, 1717, 1401, 7, 199, 199, 1772, 63, 28605, 12969, 275, 499, 199, 199, 9663, 63, 2711, 63, 2632, 742, 6012, 275, 791, 2714, 13, 804, 356, 283, 3578, 15, 88, 13, 1544, 13, 964, 13, 21886, 936, 199, 199, 4317, 63, 7311, 275, 2650, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 2, 18042, 628, 5066, 14863, 3524, 199, 4317, 63, 13001, 275, 283, 1014, 921, 1544, 14, 69, 5466, 14, 957, 15, 9482, 15, 11338, 345, 15, 1652, 63, 1246, 7, 199, 199, 3553, 7079, 63, 18765, 63, 14742, 13060, 275, 283, 2861, 2785, 7, 199, 3553, 7079, 63, 18765, 63, 5670, 275, 283, 739, 7, 199, 199, 13716, 63, 3472, 63, 27778, 63, 10764, 275, 519, 7, 547, 499, 1797, 26, 2795, 26, 17329, 370, 16919, 4650, 24805, 83, 60, 3171, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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eh
examples/custom/gears/gear.py
14
1873
from __future__ import absolute_import from bokeh.models import Glyph from bokeh.core.properties import NumberSpec, AngleSpec, Include from bokeh.core.property_mixins import LineProps, FillProps class Gear(Glyph): """ Render gears. The details and nomenclature concerning gear construction can be quite involved. For more information, consult the `Wikipedia article for Gear`_. .. _Wikipedia article for Gear: http://en.wikipedia.org/wiki/Gear """ __implementation__ = "gear.coffee" x = NumberSpec(help=""" The x-coordinates of the center of the gears. """) y = NumberSpec(help=""" The y-coordinates of the center of the gears. """) angle = AngleSpec(default=0, help=""" The angle the gears are rotated from horizontal. [rad] """) module = NumberSpec(help=""" A scaling factor, given by:: m = p / pi where *p* is the circular pitch, defined as the distance from one face of a tooth to the corresponding face of an adjacent tooth on the same gear, measured along the pitch circle. [float] """) teeth = NumberSpec(help=""" How many teeth the gears have. [int] """) pressure_angle = NumberSpec(default=20, help=""" The complement of the angle between the direction that the teeth exert force on each other, and the line joining the centers of the two gears. [deg] """) shaft_size = NumberSpec(default=0.3, help=""" The central gear shaft size as a percentage of the overall gear size. [float] """) internal = NumberSpec(default=False, help=""" Whether the gear teeth are internal. [bool] """) line_props = Include(LineProps, use_prefix=False, help=""" The %s values for the gears. """) fill_props = Include(FillProps, use_prefix=False, help=""" The %s values for the gears. """)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 25214, 14, 992, 492, 598, 7234, 199, 504, 25214, 14, 1018, 14, 3282, 492, 4860, 5307, 12, 1626, 3845, 5307, 12, 15783, 199, 504, 25214, 14, 1018, 14, 1829, 63, 30192, 492, 7030, 24188, 12, 24797, 24188, 199, 199, 533, 598, 2210, 8, 15533, 304, 272, 408, 17769, 2312, 4291, 14, 339, 710, 2436, 436, 949, 1410, 429, 1463, 406, 2247, 1835, 2312, 285, 14538, 883, 272, 506, 18794, 28244, 14, 2104, 1655, 2556, 12, 13447, 427, 314, 658, 55, 29386, 272, 9772, 367, 598, 2210, 32578, 339, 2508, 485, 55, 29386, 9772, 367, 598, 2210, 26, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 39, 2210, 272, 408, 339, 636, 12236, 363, 275, 298, 29571, 14, 331, 24715, 2, 339, 671, 275, 4860, 5307, 8, 3437, 11916, 272, 710, 671, 13, 12924, 402, 314, 8126, 402, 314, 2312, 4291, 14, 272, 7857, 339, 612, 275, 4860, 5307, 8, 3437, 11916, 272, 710, 612, 13, 12924, 402, 314, 8126, 402, 314, 2312, 4291, 14, 272, 7857, 339, 9324, 275, 1626, 3845, 5307, 8, 885, 29, 16, 12, 1720, 11916, 272, 710, 9324, 314, 2312, 4291, 787, 7513, 972, 687, 17528, 14, 359, 9525, 61, 272, 7857, 339, 859, 275, 4860, 5307, 8, 3437, 11916, 272, 437, 13690, 6535, 12, 1627, 701, 447, 398, 333, 275, 299, 1182, 6682, 339, 2382, 627, 80, 10, 365, 314, 15032, 20031, 12, 3247, 465, 314, 6033, 687, 1373, 272, 8870, 402, 282, 4634, 273, 370, 314, 5226, 8870, 402, 376, 24113, 4634, 273, 641, 272, 314, 2011, 2312, 285, 12, 27396, 3180, 314, 20031, 17990, 14, 359, 1609, 61, 272, 7857, 339, 1565, 12391, 275, 4860, 5307, 8, 3437, 11916, 272, 7494, 5002, 1565, 12391, 314, 2312, 4291, 1172, 14, 359, 442, 61, 272, 7857, 339, 25471, 63, 4593, 275, 4860, 5307, 8, 885, 29, 1165, 12, 1720, 11916, 272, 710, 2831, 434, 402, 314, 9324, 3382, 314, 7581, 626, 314, 1565, 12391, 272, 444, 15299, 3542, 641, 1924, 1163, 12, 436, 314, 1004, 4263, 316, 314, 19190, 402, 314, 272, 2877, 2312, 4291, 14, 359, 6458, 61, 272, 7857, 339, 7793, 856, 63, 890, 275, 4860, 5307, 8, 885, 29, 16, 14, 19, 12, 1720, 11916, 272, 710, 18796, 2312, 285, 7793, 856, 1568, 465, 282, 16327, 402, 314, 20347, 2312, 285, 272, 1568, 14, 359, 1609, 61, 272, 7857, 339, 5007, 275, 4860, 5307, 8, 885, 29, 797, 12, 1720, 11916, 272, 7480, 314, 2312, 285, 1565, 12391, 787, 5007, 14, 359, 2245, 61, 272, 7857, 339, 1004, 63, 6750, 275, 15783, 8, 3049, 24188, 12, 675, 63, 1861, 29, 797, 12, 1720, 11916, 272, 710, 450, 83, 1338, 367, 314, 2312, 4291, 14, 272, 7857, 339, 5554, 63, 6750, 275, 15783, 8, 12914, 24188, 12, 675, 63, 1861, 29, 797, 12, 1720, 11916, 272, 710, 450, 83, 1338, 367, 314, 2312, 4291, 14, 272, 7857, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 25214, 14, 992, 492, 598, 7234, 199, 504, 25214, 14, 1018, 14, 3282, 492, 4860, 5307, 12, 1626, 3845, 5307, 12, 15783, 199, 504, 25214, 14, 1018, 14, 1829, 63, 30192, 492, 7030, 24188, 12, 24797, 24188, 199, 199, 533, 598, 2210, 8, 15533, 304, 272, 408, 17769, 2312, 4291, 14, 339, 710, 2436, 436, 949, 1410, 429, 1463, 406, 2247, 1835, 2312, 285, 14538, 883, 272, 506, 18794, 28244, 14, 2104, 1655, 2556, 12, 13447, 427, 314, 658, 55, 29386, 272, 9772, 367, 598, 2210, 32578, 339, 2508, 485, 55, 29386, 9772, 367, 598, 2210, 26, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 39, 2210, 272, 408, 339, 636, 12236, 363, 275, 298, 29571, 14, 331, 24715, 2, 339, 671, 275, 4860, 5307, 8, 3437, 11916, 272, 710, 671, 13, 12924, 402, 314, 8126, 402, 314, 2312, 4291, 14, 272, 7857, 339, 612, 275, 4860, 5307, 8, 3437, 11916, 272, 710, 612, 13, 12924, 402, 314, 8126, 402, 314, 2312, 4291, 14, 272, 7857, 339, 9324, 275, 1626, 3845, 5307, 8, 885, 29, 16, 12, 1720, 11916, 272, 710, 9324, 314, 2312, 4291, 787, 7513, 972, 687, 17528, 14, 359, 9525, 61, 272, 7857, 339, 859, 275, 4860, 5307, 8, 3437, 11916, 272, 437, 13690, 6535, 12, 1627, 701, 447, 398, 333, 275, 299, 1182, 6682, 339, 2382, 627, 80, 10, 365, 314, 15032, 20031, 12, 3247, 465, 314, 6033, 687, 1373, 272, 8870, 402, 282, 4634, 273, 370, 314, 5226, 8870, 402, 376, 24113, 4634, 273, 641, 272, 314, 2011, 2312, 285, 12, 27396, 3180, 314, 20031, 17990, 14, 359, 1609, 61, 272, 7857, 339, 1565, 12391, 275, 4860, 5307, 8, 3437, 11916, 272, 7494, 5002, 1565, 12391, 314, 2312, 4291, 1172, 14, 359, 442, 61, 272, 7857, 339, 25471, 63, 4593, 275, 4860, 5307, 8, 885, 29, 1165, 12, 1720, 11916, 272, 710, 2831, 434, 402, 314, 9324, 3382, 314, 7581, 626, 314, 1565, 12391, 272, 444, 15299, 3542, 641, 1924, 1163, 12, 436, 314, 1004, 4263, 316, 314, 19190, 402, 314, 272, 2877, 2312, 4291, 14, 359, 6458, 61, 272, 7857, 339, 7793, 856, 63, 890, 275, 4860, 5307, 8, 885, 29, 16, 14, 19, 12, 1720, 11916, 272, 710, 18796, 2312, 285, 7793, 856, 1568, 465, 282, 16327, 402, 314, 20347, 2312, 285, 272, 1568, 14, 359, 1609, 61, 272, 7857, 339, 5007, 275, 4860, 5307, 8, 885, 29, 797, 12, 1720, 11916, 272, 7480, 314, 2312, 285, 1565, 12391, 787, 5007, 14, 359, 2245, 61, 272, 7857, 339, 1004, 63, 6750, 275, 15783, 8, 3049, 24188, 12, 675, 63, 1861, 29, 797, 12, 1720, 11916, 272, 710, 450, 83, 1338, 367, 314, 2312, 4291, 14, 272, 7857, 339, 5554, 63, 6750, 275, 15783, 8, 12914, 24188, 12, 675, 63, 1861, 29, 797, 12, 1720, 11916, 272, 710, 450, 83, 1338, 367, 314, 2312, 4291, 14, 272, 7857, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
avagin/p.haul
p_haul_ovz.py
1
4646
# # OpenVZ containers hauler module # import os import shutil import p_haul_cgroup import p_haul_netifapi as netif import p_haul_fsapi as fsapi import p_haul_netapi as netapi import fs_haul_shared import fs_haul_subtree name = "ovz" vzpid_dir = "/var/lib/vzctl/vepid/" vz_dir = "/vz" vzpriv_dir = "%s/private" % vz_dir vzroot_dir = "%s/root" % vz_dir vz_conf_dir = "/etc/vz/conf/" vz_pidfiles = "/var/lib/vzctl/vepid/" cg_image_name = "ovzcg.img" class p_haul_type: def __init__(self, id): self._ctid = id # # This list would contain (v_in, v_out, v_br) tuples where # v_in is the name of veth device in CT # v_out is its peer on the host # v_bridge is the bridge to which thie veth is attached # self._veths = [] self._cfg = [] def __load_ct_config(self, dir): print "Loading config file from %s" % dir ifd = open(os.path.join(dir, self.__ct_config())) for line in ifd: self._cfg.append(line) if line.startswith("NETIF="): # # Parse and keep veth pairs, later we will # equip restore request with this data and # will use it while (un)locking the network # v_in = None v_out = None v_bridge = None vs = line.strip().split("=", 1)[1].strip("\"") for parm in vs.split(","): pa = parm.split("=") if pa[0] == "ifname": v_in = pa[1] elif pa[0] == "host_ifname": v_out = pa[1] elif pa[0] == "bridge": v_bridge = pa[1] if v_in and v_out: print "\tCollect %s -> %s (%s) veth" % (v_in, v_out, v_bridge) veth = netapi.net_dev() veth.name = v_in veth.pair = v_out veth.link = v_bridge self._veths.append(veth) ifd.close() def __apply_cg_config(self): print "Applying CT configs" # FIXME -- implement pass def id(self): return (name, self._ctid) def init_src(self): self._fs_mounted = True self._bridged = True self.__load_ct_config(vz_conf_dir) def init_dst(self): self._fs_mounted = False self._bridged = False def root_task_pid(self): pf = open(os.path.join(vzpid_dir, self._ctid)) pid = pf.read() return int(pid) def __ct_priv(self): return "%s/%s" % (vzpriv_dir, self._ctid) def __ct_root(self): return "%s/%s" % (vzroot_dir, self._ctid) def __ct_config(self): return "%s.conf" % self._ctid # # Meta-images for OVZ -- container config and info about CGroups # def get_meta_images(self, dir): cg_img = os.path.join(dir, cg_image_name) p_haul_cgroup.dump_hier(self.root_task_pid(), cg_img) cfg_name = self.__ct_config() return [ (os.path.join(vz_conf_dir, cfg_name), cfg_name), \ (cg_img, cg_image_name) ] def put_meta_images(self, dir): print "Putting config file into %s" % vz_conf_dir self.__load_ct_config(dir) ofd = open(os.path.join(vz_conf_dir, self.__ct_config()), "w") ofd.writelines(self._cfg) ofd.close() # Keep this name, we'll need one in prepare_ct() self.cg_img = os.path.join(dir, cg_image_name) # # Create cgroup hierarchy and put root task into it # Hierarchy is unlimited, we will apply config limitations # in ->restored->__apply_cg_config later # def prepare_ct(self, pid): p_haul_cgroup.restore_hier(pid, self.cg_img) def __umount_root(self): print "Umounting CT root" os.system("umount %s" % self.__ct_root()) self._fs_mounted = False def mount(self): nroot = self.__ct_root() print "Mounting CT root to %s" % nroot if not os.access(nroot, os.F_OK): os.makedirs(nroot) os.system("mount --bind %s %s" % (self.__ct_priv(), nroot)) self._fs_mounted = True return nroot def umount(self): if self._fs_mounted: self.__umount_root() def get_fs(self): rootfs = fsapi.path_to_fs(self.__ct_priv()) if not rootfs: print "CT is on unknown FS" return None print "CT is on %s" % rootfs if rootfs == "nfs": return fs_haul_shared.p_haul_fs() if rootfs == "ext3" or rootfs == "ext4": return fs_haul_subtree.p_haul_fs(self.__ct_priv()) print "Unknown CT FS" return None def restored(self, pid): print "Writing pidfile" pidfile = open(os.path.join(vz_pidfiles, self._ctid), 'w') pidfile.write("%d" % pid) pidfile.close() self.__apply_cg_config() def net_lock(self): for veth in self._veths: netif.ifdown(veth[1]) def net_unlock(self): for veth in self._veths: netif.ifup(veth[1]) if veth[2] and not self._bridged: netif.bridge_add(veth[1], veth[2]) def can_migrate_tcp(self): return True def veths(self): # # Caller wants to see list of tuples with [0] being name # in CT and [1] being name on host. Just return existing # tuples, the [2] with bridge name wouldn't hurt # return self._veths
lgpl-2.1
[ 3, 199, 3, 3232, 54, 58, 15333, 18251, 19345, 859, 199, 3, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 299, 63, 2411, 348, 63, 24483, 199, 646, 299, 63, 2411, 348, 63, 20869, 1246, 465, 1279, 9142, 199, 646, 299, 63, 2411, 348, 63, 2319, 1246, 465, 7449, 1246, 199, 646, 299, 63, 2411, 348, 63, 846, 1246, 465, 1851, 1246, 199, 646, 7449, 63, 2411, 348, 63, 5555, 199, 646, 7449, 63, 2411, 348, 63, 26043, 199, 199, 354, 275, 298, 8822, 90, 2, 199, 31007, 3150, 63, 694, 275, 3286, 1391, 15, 773, 15, 31007, 8077, 15, 432, 3150, 6687, 199, 31007, 63, 694, 275, 3286, 31007, 2, 199, 31007, 10605, 63, 694, 275, 2071, 83, 15, 4239, 2, 450, 373, 90, 63, 694, 199, 31007, 1231, 63, 694, 275, 2071, 83, 15, 1231, 2, 450, 373, 90, 63, 694, 199, 31007, 63, 2190, 63, 694, 275, 3286, 6839, 15, 31007, 15, 2190, 6687, 199, 31007, 63, 3150, 1725, 275, 3286, 1391, 15, 773, 15, 31007, 8077, 15, 432, 3150, 6687, 199, 12595, 63, 1569, 63, 354, 275, 298, 8822, 90, 12595, 14, 4060, 2, 199, 199, 533, 299, 63, 2411, 348, 63, 466, 26, 199, 198, 318, 636, 826, 721, 277, 12, 1305, 304, 507, 198, 277, 423, 67, 5700, 275, 1305, 507, 198, 3, 507, 198, 3, 961, 769, 3955, 1395, 334, 86, 63, 262, 12, 373, 63, 548, 12, 373, 63, 3289, 9, 6346, 2382, 507, 198, 3, 373, 63, 262, 365, 314, 536, 402, 11199, 273, 2243, 315, 24990, 507, 198, 3, 373, 63, 548, 365, 2399, 9104, 641, 314, 1591, 507, 198, 3, 373, 63, 9528, 365, 314, 13928, 370, 1314, 294, 1873, 11199, 273, 365, 10102, 507, 198, 3, 507, 198, 277, 423, 432, 273, 83, 275, 942, 507, 198, 277, 423, 4128, 275, 942, 421, 198, 318, 636, 912, 63, 319, 63, 888, 8, 277, 12, 2935, 304, 507, 198, 1361, 298, 19236, 1101, 570, 687, 450, 83, 2, 450, 2935, 507, 198, 692, 68, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 694, 12, 291, 855, 319, 63, 888, 4059, 507, 198, 509, 1004, 315, 340, 68, 26, 686, 198, 277, 423, 4128, 14, 740, 8, 604, 9, 6319, 198, 692, 1004, 14, 2460, 480, 7278, 4656, 628, 304, 1585, 198, 3, 1585, 198, 3, 6077, 436, 4215, 11199, 273, 6342, 12, 2945, 781, 911, 1585, 198, 3, 11960, 711, 9066, 1056, 543, 642, 666, 436, 1585, 198, 3, 911, 675, 652, 1830, 334, 324, 9, 24056, 314, 2784, 1585, 198, 3, 1585, 198, 86, 63, 262, 275, 488, 1585, 198, 86, 63, 548, 275, 488, 1585, 198, 86, 63, 9528, 275, 488, 1585, 198, 3122, 275, 1004, 14, 1913, 1252, 1294, 480, 11107, 413, 2788, 17, 1055, 1913, 4582, 7230, 1585, 198, 509, 623, 77, 315, 8118, 14, 1294, 8, 2266, 304, 1871, 198, 387, 275, 623, 77, 14, 1294, 480, 23758, 1871, 198, 692, 691, 59, 16, 61, 508, 298, 30702, 582, 4671, 198, 86, 63, 262, 275, 691, 59, 17, 61, 1871, 198, 4164, 691, 59, 16, 61, 508, 298, 1102, 63, 30702, 582, 4671, 198, 86, 63, 548, 275, 691, 59, 17, 61, 1871, 198, 4164, 691, 59, 16, 61, 508, 298, 9528, 582, 4671, 198, 86, 63, 9528, 275, 691, 59, 17, 61, 16737, 198, 692, 373, 63, 262, 436, 373, 63, 548, 26, 1871, 198, 1361, 1867, 84, 25023, 450, 83, 1035, 450, 83, 4366, 83, 9, 11199, 273, 2, 450, 334, 86, 63, 262, 12, 373, 63, 548, 12, 373, 63, 9528, 9, 1871, 198, 432, 273, 275, 1851, 1246, 14, 846, 63, 2374, 342, 1871, 198, 432, 273, 14, 354, 275, 373, 63, 262, 1871, 198, 432, 273, 14, 3852, 275, 373, 63, 548, 1871, 198, 432, 273, 14, 1073, 275, 373, 63, 9528, 1871, 198, 277, 423, 432, 273, 83, 14, 740, 8, 432, 273, 9, 2742, 198, 692, 68, 14, 1600, 342, 421, 198, 318, 636, 4998, 63, 12595, 63, 888, 8, 277, 304, 507, 198, 1361, 298, 2640, 6670, 24990, 11585, 2, 507, 198, 3, 7600, 1553, 5669, 507, 198, 1529, 421, 198, 318, 1305, 8, 277, 304, 507, 198, 1107, 334, 354, 12, 291, 423, 67, 5700, 9, 421, 198, 318, 4205, 63, 2164, 8, 277, 304, 507, 198, 277, 423, 2319, 63, 27919, 275, 715, 507, 198, 277, 423, 14601, 3046, 275, 715, 507, 198, 277, 855, 912, 63, 319, 63, 888, 8, 31007, 63, 2190, 63, 694, 9, 421, 198, 318, 4205, 63, 5119, 8, 277, 304, 507, 198, 277, 423, 2319, 63, 27919, 275, 756, 507, 198, 277, 423, 14601, 3046, 275, 756, 421, 198, 318, 1738, 63, 1765, 63, 3150, 8, 277, 304, 507, 198, 9928, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 31007, 3150, 63, 694, 12, 291, 423, 67, 5700, 430, 507, 198, 3150, 275, 18258, 14, 739, 342, 507, 198, 1107, 1109, 8, 3150, 9, 421, 198, 318, 636, 319, 63, 10605, 8, 277, 304, 507, 198, 1107, 2071, 83, 3149, 83, 2, 450, 334, 31007, 10605, 63, 694, 12, 291, 423, 67, 5700, 9, 421, 198, 318, 636, 319, 63, 1231, 8, 277, 304, 507, 198, 1107, 2071, 83, 3149, 83, 2, 450, 334, 31007, 1231, 63, 694, 12, 291, 423, 67, 5700, 9, 421, 198, 318, 636, 319, 63, 888, 8, 277, 304, 507, 198, 1107, 2071, 83, 14, 2190, 2, 450, 291, 423, 67, 5700, 421, 198, 3, 199, 198, 3, 6288, 13, 4782, 367, 593, 54, 58, 1553, 3970, 1101, 436, 2256, 3595, 445, 10177, 199, 198, 3, 199, 198, 318, 664, 63, 2024, 63, 4782, 8, 277, 12, 2935, 304, 507, 198, 12595, 63, 4060, 275, 747, 14, 515, 14, 904, 8, 694, 12, 19711, 63, 1569, 63, 354, 9, 507, 198, 80, 63, 2411, 348, 63, 24483, 14, 2724, 63, 31184, 8, 277, 14, 1231, 63, 1765, 63, 3150, 1062, 19711, 63, 4060, 9, 507, 198, 4128, 63, 354, 275, 291, 855, 319, 63, 888, 342, 507, 198, 1107, 359, 334, 736, 14, 515, 14, 904, 8, 31007, 63, 2190, 63, 694, 12, 4810, 63, 354, 395, 4810, 63, 354, 395, 971, 1585, 334 ]
[ 199, 3, 3232, 54, 58, 15333, 18251, 19345, 859, 199, 3, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 299, 63, 2411, 348, 63, 24483, 199, 646, 299, 63, 2411, 348, 63, 20869, 1246, 465, 1279, 9142, 199, 646, 299, 63, 2411, 348, 63, 2319, 1246, 465, 7449, 1246, 199, 646, 299, 63, 2411, 348, 63, 846, 1246, 465, 1851, 1246, 199, 646, 7449, 63, 2411, 348, 63, 5555, 199, 646, 7449, 63, 2411, 348, 63, 26043, 199, 199, 354, 275, 298, 8822, 90, 2, 199, 31007, 3150, 63, 694, 275, 3286, 1391, 15, 773, 15, 31007, 8077, 15, 432, 3150, 6687, 199, 31007, 63, 694, 275, 3286, 31007, 2, 199, 31007, 10605, 63, 694, 275, 2071, 83, 15, 4239, 2, 450, 373, 90, 63, 694, 199, 31007, 1231, 63, 694, 275, 2071, 83, 15, 1231, 2, 450, 373, 90, 63, 694, 199, 31007, 63, 2190, 63, 694, 275, 3286, 6839, 15, 31007, 15, 2190, 6687, 199, 31007, 63, 3150, 1725, 275, 3286, 1391, 15, 773, 15, 31007, 8077, 15, 432, 3150, 6687, 199, 12595, 63, 1569, 63, 354, 275, 298, 8822, 90, 12595, 14, 4060, 2, 199, 199, 533, 299, 63, 2411, 348, 63, 466, 26, 199, 198, 318, 636, 826, 721, 277, 12, 1305, 304, 507, 198, 277, 423, 67, 5700, 275, 1305, 507, 198, 3, 507, 198, 3, 961, 769, 3955, 1395, 334, 86, 63, 262, 12, 373, 63, 548, 12, 373, 63, 3289, 9, 6346, 2382, 507, 198, 3, 373, 63, 262, 365, 314, 536, 402, 11199, 273, 2243, 315, 24990, 507, 198, 3, 373, 63, 548, 365, 2399, 9104, 641, 314, 1591, 507, 198, 3, 373, 63, 9528, 365, 314, 13928, 370, 1314, 294, 1873, 11199, 273, 365, 10102, 507, 198, 3, 507, 198, 277, 423, 432, 273, 83, 275, 942, 507, 198, 277, 423, 4128, 275, 942, 421, 198, 318, 636, 912, 63, 319, 63, 888, 8, 277, 12, 2935, 304, 507, 198, 1361, 298, 19236, 1101, 570, 687, 450, 83, 2, 450, 2935, 507, 198, 692, 68, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 694, 12, 291, 855, 319, 63, 888, 4059, 507, 198, 509, 1004, 315, 340, 68, 26, 686, 198, 277, 423, 4128, 14, 740, 8, 604, 9, 6319, 198, 692, 1004, 14, 2460, 480, 7278, 4656, 628, 304, 1585, 198, 3, 1585, 198, 3, 6077, 436, 4215, 11199, 273, 6342, 12, 2945, 781, 911, 1585, 198, 3, 11960, 711, 9066, 1056, 543, 642, 666, 436, 1585, 198, 3, 911, 675, 652, 1830, 334, 324, 9, 24056, 314, 2784, 1585, 198, 3, 1585, 198, 86, 63, 262, 275, 488, 1585, 198, 86, 63, 548, 275, 488, 1585, 198, 86, 63, 9528, 275, 488, 1585, 198, 3122, 275, 1004, 14, 1913, 1252, 1294, 480, 11107, 413, 2788, 17, 1055, 1913, 4582, 7230, 1585, 198, 509, 623, 77, 315, 8118, 14, 1294, 8, 2266, 304, 1871, 198, 387, 275, 623, 77, 14, 1294, 480, 23758, 1871, 198, 692, 691, 59, 16, 61, 508, 298, 30702, 582, 4671, 198, 86, 63, 262, 275, 691, 59, 17, 61, 1871, 198, 4164, 691, 59, 16, 61, 508, 298, 1102, 63, 30702, 582, 4671, 198, 86, 63, 548, 275, 691, 59, 17, 61, 1871, 198, 4164, 691, 59, 16, 61, 508, 298, 9528, 582, 4671, 198, 86, 63, 9528, 275, 691, 59, 17, 61, 16737, 198, 692, 373, 63, 262, 436, 373, 63, 548, 26, 1871, 198, 1361, 1867, 84, 25023, 450, 83, 1035, 450, 83, 4366, 83, 9, 11199, 273, 2, 450, 334, 86, 63, 262, 12, 373, 63, 548, 12, 373, 63, 9528, 9, 1871, 198, 432, 273, 275, 1851, 1246, 14, 846, 63, 2374, 342, 1871, 198, 432, 273, 14, 354, 275, 373, 63, 262, 1871, 198, 432, 273, 14, 3852, 275, 373, 63, 548, 1871, 198, 432, 273, 14, 1073, 275, 373, 63, 9528, 1871, 198, 277, 423, 432, 273, 83, 14, 740, 8, 432, 273, 9, 2742, 198, 692, 68, 14, 1600, 342, 421, 198, 318, 636, 4998, 63, 12595, 63, 888, 8, 277, 304, 507, 198, 1361, 298, 2640, 6670, 24990, 11585, 2, 507, 198, 3, 7600, 1553, 5669, 507, 198, 1529, 421, 198, 318, 1305, 8, 277, 304, 507, 198, 1107, 334, 354, 12, 291, 423, 67, 5700, 9, 421, 198, 318, 4205, 63, 2164, 8, 277, 304, 507, 198, 277, 423, 2319, 63, 27919, 275, 715, 507, 198, 277, 423, 14601, 3046, 275, 715, 507, 198, 277, 855, 912, 63, 319, 63, 888, 8, 31007, 63, 2190, 63, 694, 9, 421, 198, 318, 4205, 63, 5119, 8, 277, 304, 507, 198, 277, 423, 2319, 63, 27919, 275, 756, 507, 198, 277, 423, 14601, 3046, 275, 756, 421, 198, 318, 1738, 63, 1765, 63, 3150, 8, 277, 304, 507, 198, 9928, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 31007, 3150, 63, 694, 12, 291, 423, 67, 5700, 430, 507, 198, 3150, 275, 18258, 14, 739, 342, 507, 198, 1107, 1109, 8, 3150, 9, 421, 198, 318, 636, 319, 63, 10605, 8, 277, 304, 507, 198, 1107, 2071, 83, 3149, 83, 2, 450, 334, 31007, 10605, 63, 694, 12, 291, 423, 67, 5700, 9, 421, 198, 318, 636, 319, 63, 1231, 8, 277, 304, 507, 198, 1107, 2071, 83, 3149, 83, 2, 450, 334, 31007, 1231, 63, 694, 12, 291, 423, 67, 5700, 9, 421, 198, 318, 636, 319, 63, 888, 8, 277, 304, 507, 198, 1107, 2071, 83, 14, 2190, 2, 450, 291, 423, 67, 5700, 421, 198, 3, 199, 198, 3, 6288, 13, 4782, 367, 593, 54, 58, 1553, 3970, 1101, 436, 2256, 3595, 445, 10177, 199, 198, 3, 199, 198, 318, 664, 63, 2024, 63, 4782, 8, 277, 12, 2935, 304, 507, 198, 12595, 63, 4060, 275, 747, 14, 515, 14, 904, 8, 694, 12, 19711, 63, 1569, 63, 354, 9, 507, 198, 80, 63, 2411, 348, 63, 24483, 14, 2724, 63, 31184, 8, 277, 14, 1231, 63, 1765, 63, 3150, 1062, 19711, 63, 4060, 9, 507, 198, 4128, 63, 354, 275, 291, 855, 319, 63, 888, 342, 507, 198, 1107, 359, 334, 736, 14, 515, 14, 904, 8, 31007, 63, 2190, 63, 694, 12, 4810, 63, 354, 395, 4810, 63, 354, 395, 971, 1585, 334, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
vertigo235/Sick-Beard-XEM
lib/unidecode/x09a.py
253
4623
data = ( 'E ', # 0x00 'Cheng ', # 0x01 'Xin ', # 0x02 'Ai ', # 0x03 'Lu ', # 0x04 'Zhui ', # 0x05 'Zhou ', # 0x06 'She ', # 0x07 'Pian ', # 0x08 'Kun ', # 0x09 'Tao ', # 0x0a 'Lai ', # 0x0b 'Zong ', # 0x0c 'Ke ', # 0x0d 'Qi ', # 0x0e 'Qi ', # 0x0f 'Yan ', # 0x10 'Fei ', # 0x11 'Sao ', # 0x12 'Yan ', # 0x13 'Jie ', # 0x14 'Yao ', # 0x15 'Wu ', # 0x16 'Pian ', # 0x17 'Cong ', # 0x18 'Pian ', # 0x19 'Qian ', # 0x1a 'Fei ', # 0x1b 'Huang ', # 0x1c 'Jian ', # 0x1d 'Huo ', # 0x1e 'Yu ', # 0x1f 'Ti ', # 0x20 'Quan ', # 0x21 'Xia ', # 0x22 'Zong ', # 0x23 'Kui ', # 0x24 'Rou ', # 0x25 'Si ', # 0x26 'Gua ', # 0x27 'Tuo ', # 0x28 'Kui ', # 0x29 'Sou ', # 0x2a 'Qian ', # 0x2b 'Cheng ', # 0x2c 'Zhi ', # 0x2d 'Liu ', # 0x2e 'Pang ', # 0x2f 'Teng ', # 0x30 'Xi ', # 0x31 'Cao ', # 0x32 'Du ', # 0x33 'Yan ', # 0x34 'Yuan ', # 0x35 'Zou ', # 0x36 'Sao ', # 0x37 'Shan ', # 0x38 'Li ', # 0x39 'Zhi ', # 0x3a 'Shuang ', # 0x3b 'Lu ', # 0x3c 'Xi ', # 0x3d 'Luo ', # 0x3e 'Zhang ', # 0x3f 'Mo ', # 0x40 'Ao ', # 0x41 'Can ', # 0x42 'Piao ', # 0x43 'Cong ', # 0x44 'Qu ', # 0x45 'Bi ', # 0x46 'Zhi ', # 0x47 'Yu ', # 0x48 'Xu ', # 0x49 'Hua ', # 0x4a 'Bo ', # 0x4b 'Su ', # 0x4c 'Xiao ', # 0x4d 'Lin ', # 0x4e 'Chan ', # 0x4f 'Dun ', # 0x50 'Liu ', # 0x51 'Tuo ', # 0x52 'Zeng ', # 0x53 'Tan ', # 0x54 'Jiao ', # 0x55 'Tie ', # 0x56 'Yan ', # 0x57 'Luo ', # 0x58 'Zhan ', # 0x59 'Jing ', # 0x5a 'Yi ', # 0x5b 'Ye ', # 0x5c 'Tuo ', # 0x5d 'Bin ', # 0x5e 'Zou ', # 0x5f 'Yan ', # 0x60 'Peng ', # 0x61 'Lu ', # 0x62 'Teng ', # 0x63 'Xiang ', # 0x64 'Ji ', # 0x65 'Shuang ', # 0x66 'Ju ', # 0x67 'Xi ', # 0x68 'Huan ', # 0x69 'Li ', # 0x6a 'Biao ', # 0x6b 'Ma ', # 0x6c 'Yu ', # 0x6d 'Tuo ', # 0x6e 'Xun ', # 0x6f 'Chi ', # 0x70 'Qu ', # 0x71 'Ri ', # 0x72 'Bo ', # 0x73 'Lu ', # 0x74 'Zang ', # 0x75 'Shi ', # 0x76 'Si ', # 0x77 'Fu ', # 0x78 'Ju ', # 0x79 'Zou ', # 0x7a 'Zhu ', # 0x7b 'Tuo ', # 0x7c 'Nu ', # 0x7d 'Jia ', # 0x7e 'Yi ', # 0x7f 'Tai ', # 0x80 'Xiao ', # 0x81 'Ma ', # 0x82 'Yin ', # 0x83 'Jiao ', # 0x84 'Hua ', # 0x85 'Luo ', # 0x86 'Hai ', # 0x87 'Pian ', # 0x88 'Biao ', # 0x89 'Li ', # 0x8a 'Cheng ', # 0x8b 'Yan ', # 0x8c 'Xin ', # 0x8d 'Qin ', # 0x8e 'Jun ', # 0x8f 'Qi ', # 0x90 'Qi ', # 0x91 'Ke ', # 0x92 'Zhui ', # 0x93 'Zong ', # 0x94 'Su ', # 0x95 'Can ', # 0x96 'Pian ', # 0x97 'Zhi ', # 0x98 'Kui ', # 0x99 'Sao ', # 0x9a 'Wu ', # 0x9b 'Ao ', # 0x9c 'Liu ', # 0x9d 'Qian ', # 0x9e 'Shan ', # 0x9f 'Piao ', # 0xa0 'Luo ', # 0xa1 'Cong ', # 0xa2 'Chan ', # 0xa3 'Zou ', # 0xa4 'Ji ', # 0xa5 'Shuang ', # 0xa6 'Xiang ', # 0xa7 'Gu ', # 0xa8 'Wei ', # 0xa9 'Wei ', # 0xaa 'Wei ', # 0xab 'Yu ', # 0xac 'Gan ', # 0xad 'Yi ', # 0xae 'Ang ', # 0xaf 'Tou ', # 0xb0 'Xie ', # 0xb1 'Bao ', # 0xb2 'Bi ', # 0xb3 'Chi ', # 0xb4 'Ti ', # 0xb5 'Di ', # 0xb6 'Ku ', # 0xb7 'Hai ', # 0xb8 'Qiao ', # 0xb9 'Gou ', # 0xba 'Kua ', # 0xbb 'Ge ', # 0xbc 'Tui ', # 0xbd 'Geng ', # 0xbe 'Pian ', # 0xbf 'Bi ', # 0xc0 'Ke ', # 0xc1 'Ka ', # 0xc2 'Yu ', # 0xc3 'Sui ', # 0xc4 'Lou ', # 0xc5 'Bo ', # 0xc6 'Xiao ', # 0xc7 'Pang ', # 0xc8 'Bo ', # 0xc9 'Ci ', # 0xca 'Kuan ', # 0xcb 'Bin ', # 0xcc 'Mo ', # 0xcd 'Liao ', # 0xce 'Lou ', # 0xcf 'Nao ', # 0xd0 'Du ', # 0xd1 'Zang ', # 0xd2 'Sui ', # 0xd3 'Ti ', # 0xd4 'Bin ', # 0xd5 'Kuan ', # 0xd6 'Lu ', # 0xd7 'Gao ', # 0xd8 'Gao ', # 0xd9 'Qiao ', # 0xda 'Kao ', # 0xdb 'Qiao ', # 0xdc 'Lao ', # 0xdd 'Zao ', # 0xde 'Biao ', # 0xdf 'Kun ', # 0xe0 'Kun ', # 0xe1 'Ti ', # 0xe2 'Fang ', # 0xe3 'Xiu ', # 0xe4 'Ran ', # 0xe5 'Mao ', # 0xe6 'Dan ', # 0xe7 'Kun ', # 0xe8 'Bin ', # 0xe9 'Fa ', # 0xea 'Tiao ', # 0xeb 'Peng ', # 0xec 'Zi ', # 0xed 'Fa ', # 0xee 'Ran ', # 0xef 'Ti ', # 0xf0 'Pao ', # 0xf1 'Pi ', # 0xf2 'Mao ', # 0xf3 'Fu ', # 0xf4 'Er ', # 0xf5 'Rong ', # 0xf6 'Qu ', # 0xf7 'Gong ', # 0xf8 'Xiu ', # 0xf9 'Gua ', # 0xfa 'Ji ', # 0xfb 'Peng ', # 0xfc 'Zhua ', # 0xfd 'Shao ', # 0xfe 'Sha ', # 0xff )
gpl-3.0
[ 576, 275, 334, 199, 7, 37, 1656, 259, 327, 378, 88, 383, 199, 7, 1049, 7420, 1656, 259, 327, 378, 88, 614, 199, 7, 56, 262, 1656, 259, 327, 378, 88, 996, 199, 7, 28960, 1656, 259, 327, 378, 88, 1644, 199, 7, 18176, 1656, 259, 327, 378, 88, 966, 199, 7, 12674, 1907, 1656, 259, 327, 378, 88, 1717, 199, 7, 58, 11586, 1656, 259, 327, 378, 88, 1690, 199, 7, 31306, 1656, 259, 327, 378, 88, 1780, 199, 7, 48, 5653, 1656, 259, 327, 378, 88, 2036, 199, 7, 43, 324, 1656, 259, 327, 378, 88, 1643, 199, 7, 52, 8035, 1656, 259, 327, 378, 88, 16, 65, 199, 7, 44, 5789, 1656, 259, 327, 378, 88, 16, 66, 199, 7, 58, 951, 1656, 259, 327, 378, 88, 16, 67, 199, 7, 1136, 1656, 259, 327, 378, 88, 16, 68, 199, 7, 19910, 1656, 259, 327, 378, 88, 16, 69, 199, 7, 19910, 1656, 259, 327, 378, 88, 16, 70, 199, 7, 26797, 1656, 259, 327, 378, 88, 709, 199, 7, 3456, 73, 1656, 259, 327, 378, 88, 845, 199, 7, 51, 8035, 1656, 259, 327, 378, 88, 713, 199, 7, 26797, 1656, 259, 327, 378, 88, 969, 199, 7, 42, 1873, 1656, 259, 327, 378, 88, 1079, 199, 7, 57, 8035, 1656, 259, 327, 378, 88, 1046, 199, 7, 25728, 1656, 259, 327, 378, 88, 975, 199, 7, 48, 5653, 1656, 259, 327, 378, 88, 1196, 199, 7, 714, 71, 1656, 259, 327, 378, 88, 1085, 199, 7, 48, 5653, 1656, 259, 327, 378, 88, 1167, 199, 7, 49, 5653, 1656, 259, 327, 378, 88, 17, 65, 199, 7, 3456, 73, 1656, 259, 327, 378, 88, 17, 66, 199, 7, 25542, 621, 1656, 259, 327, 378, 88, 17, 67, 199, 7, 42, 5653, 1656, 259, 327, 378, 88, 17, 68, 199, 7, 40, 13780, 1656, 259, 327, 378, 88, 17, 69, 199, 7, 24388, 1656, 259, 327, 378, 88, 17, 70, 199, 7, 22731, 1656, 259, 327, 378, 88, 1165, 199, 7, 2371, 290, 1656, 259, 327, 378, 88, 2025, 199, 7, 56, 4674, 1656, 259, 327, 378, 88, 1081, 199, 7, 58, 951, 1656, 259, 327, 378, 88, 1789, 199, 7, 43, 1907, 1656, 259, 327, 378, 88, 1194, 199, 7, 5407, 1656, 259, 327, 378, 88, 821, 199, 7, 18934, 1656, 259, 327, 378, 88, 1479, 199, 7, 39, 1458, 1656, 259, 327, 378, 88, 1465, 199, 7, 52, 13780, 1656, 259, 327, 378, 88, 1651, 199, 7, 43, 1907, 1656, 259, 327, 378, 88, 1398, 199, 7, 51, 810, 1656, 259, 327, 378, 88, 18, 65, 199, 7, 49, 5653, 1656, 259, 327, 378, 88, 18, 66, 199, 7, 1049, 7420, 1656, 259, 327, 378, 88, 18, 67, 199, 7, 58, 5812, 1656, 259, 327, 378, 88, 18, 68, 199, 7, 13009, 85, 1656, 259, 327, 378, 88, 18, 69, 199, 7, 48, 621, 1656, 259, 327, 378, 88, 18, 70, 199, 7, 52, 7420, 1656, 259, 327, 378, 88, 1216, 199, 7, 14828, 1656, 259, 327, 378, 88, 2192, 199, 7, 3630, 79, 1656, 259, 327, 378, 88, 708, 199, 7, 36, 85, 1656, 259, 327, 378, 88, 1153, 199, 7, 26797, 1656, 259, 327, 378, 88, 1082, 199, 7, 57, 7856, 1656, 259, 327, 378, 88, 1276, 199, 7, 58, 810, 1656, 259, 327, 378, 88, 1344, 199, 7, 51, 8035, 1656, 259, 327, 378, 88, 1401, 199, 7, 2662, 290, 1656, 259, 327, 378, 88, 1703, 199, 7, 13009, 1656, 259, 327, 378, 88, 1355, 199, 7, 58, 5812, 1656, 259, 327, 378, 88, 19, 65, 199, 7, 2662, 85, 621, 1656, 259, 327, 378, 88, 19, 66, 199, 7, 18176, 1656, 259, 327, 378, 88, 19, 67, 199, 7, 14828, 1656, 259, 327, 378, 88, 19, 68, 199, 7, 44, 13780, 1656, 259, 327, 378, 88, 19, 69, 199, 7, 12674, 621, 1656, 259, 327, 378, 88, 19, 70, 199, 7, 3716, 1656, 259, 327, 378, 88, 2167, 199, 7, 31707, 1656, 259, 327, 378, 88, 2953, 199, 7, 6049, 1656, 259, 327, 378, 88, 2260, 199, 7, 48, 18939, 1656, 259, 327, 378, 88, 2824, 199, 7, 714, 71, 1656, 259, 327, 378, 88, 1602, 199, 7, 2371, 1656, 259, 327, 378, 88, 2322, 199, 7, 17975, 1656, 259, 327, 378, 88, 2466, 199, 7, 58, 5812, 1656, 259, 327, 378, 88, 2417, 199, 7, 24388, 1656, 259, 327, 378, 88, 2006, 199, 7, 56, 85, 1656, 259, 327, 378, 88, 1887, 199, 7, 40, 1458, 1656, 259, 327, 378, 88, 20, 65, 199, 7, 2208, 1656, 259, 327, 378, 88, 20, 66, 199, 7, 27032, 1656, 259, 327, 378, 88, 20, 67, 199, 7, 56, 18939, 1656, 259, 327, 378, 88, 20, 68, 199, 7, 27889, 1656, 259, 327, 378, 88, 20, 69, 199, 7, 27039, 1656, 259, 327, 378, 88, 20, 70, 199, 7, 36, 324, 1656, 259, 327, 378, 88, 1400, 199, 7, 13009, 85, 1656, 259, 327, 378, 88, 2869, 199, 7, 52, 13780, 1656, 259, 327, 378, 88, 2528, 199, 7, 58, 7420, 1656, 259, 327, 378, 88, 2481, 199, 7, 52, 290, 1656, 259, 327, 378, 88, 1477, 199, 7, 42, 18939, 1656, 259, 327, 378, 88, 1229, 199, 7, 52, 1873, 1656, 259, 327, 378, 88, 1367, 199, 7, 26797, 1656, 259, 327, 378, 88, 1641, 199, 7, 44, 13780, 1656, 259, 327, 378, 88, 2010, 199, 7, 12674, 290, 1656, 259, 327, 378, 88, 1427, 199, 7, 42, 316, 1656, 259, 327, 378, 88, 21, 65, 199, 7, 21001, 1656, 259, 327, 378, 88, 21, 66, 199, 7, 57, 69, 1656, 259, 327, 378, 88, 21, 67, 199, 7, 52, 13780, 1656, 259, 327, 378, 88, 21, 68, 199, 7, 13394, 1656, 259, 327, 378, 88, 21, 69, 199, 7, 58, 810, 1656, 259, 327, 378, 88, 21, 70, 199, 7, 26797, 1656, 259, 327, 378, 88, 2259, 199, 7, 48, 7420, 1656, 259, 327, 378, 88, 2976, 199, 7, 18176, 1656, 259, 327, 378, 88, 2789, 199, 7, 52, 7420, 1656, 259, 327, 378, 88, 2766, 199, 7, 14828, 621, 1656, 259, 327, 378, 88, 772, 199, 7, 16911, 1656, 259, 327, 378, 88 ]
[ 275, 334, 199, 7, 37, 1656, 259, 327, 378, 88, 383, 199, 7, 1049, 7420, 1656, 259, 327, 378, 88, 614, 199, 7, 56, 262, 1656, 259, 327, 378, 88, 996, 199, 7, 28960, 1656, 259, 327, 378, 88, 1644, 199, 7, 18176, 1656, 259, 327, 378, 88, 966, 199, 7, 12674, 1907, 1656, 259, 327, 378, 88, 1717, 199, 7, 58, 11586, 1656, 259, 327, 378, 88, 1690, 199, 7, 31306, 1656, 259, 327, 378, 88, 1780, 199, 7, 48, 5653, 1656, 259, 327, 378, 88, 2036, 199, 7, 43, 324, 1656, 259, 327, 378, 88, 1643, 199, 7, 52, 8035, 1656, 259, 327, 378, 88, 16, 65, 199, 7, 44, 5789, 1656, 259, 327, 378, 88, 16, 66, 199, 7, 58, 951, 1656, 259, 327, 378, 88, 16, 67, 199, 7, 1136, 1656, 259, 327, 378, 88, 16, 68, 199, 7, 19910, 1656, 259, 327, 378, 88, 16, 69, 199, 7, 19910, 1656, 259, 327, 378, 88, 16, 70, 199, 7, 26797, 1656, 259, 327, 378, 88, 709, 199, 7, 3456, 73, 1656, 259, 327, 378, 88, 845, 199, 7, 51, 8035, 1656, 259, 327, 378, 88, 713, 199, 7, 26797, 1656, 259, 327, 378, 88, 969, 199, 7, 42, 1873, 1656, 259, 327, 378, 88, 1079, 199, 7, 57, 8035, 1656, 259, 327, 378, 88, 1046, 199, 7, 25728, 1656, 259, 327, 378, 88, 975, 199, 7, 48, 5653, 1656, 259, 327, 378, 88, 1196, 199, 7, 714, 71, 1656, 259, 327, 378, 88, 1085, 199, 7, 48, 5653, 1656, 259, 327, 378, 88, 1167, 199, 7, 49, 5653, 1656, 259, 327, 378, 88, 17, 65, 199, 7, 3456, 73, 1656, 259, 327, 378, 88, 17, 66, 199, 7, 25542, 621, 1656, 259, 327, 378, 88, 17, 67, 199, 7, 42, 5653, 1656, 259, 327, 378, 88, 17, 68, 199, 7, 40, 13780, 1656, 259, 327, 378, 88, 17, 69, 199, 7, 24388, 1656, 259, 327, 378, 88, 17, 70, 199, 7, 22731, 1656, 259, 327, 378, 88, 1165, 199, 7, 2371, 290, 1656, 259, 327, 378, 88, 2025, 199, 7, 56, 4674, 1656, 259, 327, 378, 88, 1081, 199, 7, 58, 951, 1656, 259, 327, 378, 88, 1789, 199, 7, 43, 1907, 1656, 259, 327, 378, 88, 1194, 199, 7, 5407, 1656, 259, 327, 378, 88, 821, 199, 7, 18934, 1656, 259, 327, 378, 88, 1479, 199, 7, 39, 1458, 1656, 259, 327, 378, 88, 1465, 199, 7, 52, 13780, 1656, 259, 327, 378, 88, 1651, 199, 7, 43, 1907, 1656, 259, 327, 378, 88, 1398, 199, 7, 51, 810, 1656, 259, 327, 378, 88, 18, 65, 199, 7, 49, 5653, 1656, 259, 327, 378, 88, 18, 66, 199, 7, 1049, 7420, 1656, 259, 327, 378, 88, 18, 67, 199, 7, 58, 5812, 1656, 259, 327, 378, 88, 18, 68, 199, 7, 13009, 85, 1656, 259, 327, 378, 88, 18, 69, 199, 7, 48, 621, 1656, 259, 327, 378, 88, 18, 70, 199, 7, 52, 7420, 1656, 259, 327, 378, 88, 1216, 199, 7, 14828, 1656, 259, 327, 378, 88, 2192, 199, 7, 3630, 79, 1656, 259, 327, 378, 88, 708, 199, 7, 36, 85, 1656, 259, 327, 378, 88, 1153, 199, 7, 26797, 1656, 259, 327, 378, 88, 1082, 199, 7, 57, 7856, 1656, 259, 327, 378, 88, 1276, 199, 7, 58, 810, 1656, 259, 327, 378, 88, 1344, 199, 7, 51, 8035, 1656, 259, 327, 378, 88, 1401, 199, 7, 2662, 290, 1656, 259, 327, 378, 88, 1703, 199, 7, 13009, 1656, 259, 327, 378, 88, 1355, 199, 7, 58, 5812, 1656, 259, 327, 378, 88, 19, 65, 199, 7, 2662, 85, 621, 1656, 259, 327, 378, 88, 19, 66, 199, 7, 18176, 1656, 259, 327, 378, 88, 19, 67, 199, 7, 14828, 1656, 259, 327, 378, 88, 19, 68, 199, 7, 44, 13780, 1656, 259, 327, 378, 88, 19, 69, 199, 7, 12674, 621, 1656, 259, 327, 378, 88, 19, 70, 199, 7, 3716, 1656, 259, 327, 378, 88, 2167, 199, 7, 31707, 1656, 259, 327, 378, 88, 2953, 199, 7, 6049, 1656, 259, 327, 378, 88, 2260, 199, 7, 48, 18939, 1656, 259, 327, 378, 88, 2824, 199, 7, 714, 71, 1656, 259, 327, 378, 88, 1602, 199, 7, 2371, 1656, 259, 327, 378, 88, 2322, 199, 7, 17975, 1656, 259, 327, 378, 88, 2466, 199, 7, 58, 5812, 1656, 259, 327, 378, 88, 2417, 199, 7, 24388, 1656, 259, 327, 378, 88, 2006, 199, 7, 56, 85, 1656, 259, 327, 378, 88, 1887, 199, 7, 40, 1458, 1656, 259, 327, 378, 88, 20, 65, 199, 7, 2208, 1656, 259, 327, 378, 88, 20, 66, 199, 7, 27032, 1656, 259, 327, 378, 88, 20, 67, 199, 7, 56, 18939, 1656, 259, 327, 378, 88, 20, 68, 199, 7, 27889, 1656, 259, 327, 378, 88, 20, 69, 199, 7, 27039, 1656, 259, 327, 378, 88, 20, 70, 199, 7, 36, 324, 1656, 259, 327, 378, 88, 1400, 199, 7, 13009, 85, 1656, 259, 327, 378, 88, 2869, 199, 7, 52, 13780, 1656, 259, 327, 378, 88, 2528, 199, 7, 58, 7420, 1656, 259, 327, 378, 88, 2481, 199, 7, 52, 290, 1656, 259, 327, 378, 88, 1477, 199, 7, 42, 18939, 1656, 259, 327, 378, 88, 1229, 199, 7, 52, 1873, 1656, 259, 327, 378, 88, 1367, 199, 7, 26797, 1656, 259, 327, 378, 88, 1641, 199, 7, 44, 13780, 1656, 259, 327, 378, 88, 2010, 199, 7, 12674, 290, 1656, 259, 327, 378, 88, 1427, 199, 7, 42, 316, 1656, 259, 327, 378, 88, 21, 65, 199, 7, 21001, 1656, 259, 327, 378, 88, 21, 66, 199, 7, 57, 69, 1656, 259, 327, 378, 88, 21, 67, 199, 7, 52, 13780, 1656, 259, 327, 378, 88, 21, 68, 199, 7, 13394, 1656, 259, 327, 378, 88, 21, 69, 199, 7, 58, 810, 1656, 259, 327, 378, 88, 21, 70, 199, 7, 26797, 1656, 259, 327, 378, 88, 2259, 199, 7, 48, 7420, 1656, 259, 327, 378, 88, 2976, 199, 7, 18176, 1656, 259, 327, 378, 88, 2789, 199, 7, 52, 7420, 1656, 259, 327, 378, 88, 2766, 199, 7, 14828, 621, 1656, 259, 327, 378, 88, 772, 199, 7, 16911, 1656, 259, 327, 378, 88, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jima80525/pyres
pyres/filemanager.py
1
4287
""" manages the files on the mp3 player """ import os import re import logging import shutil import pyres.utils as utils def _double_digit_name(name): """ Makes all numbers two digit numbers by adding a leading 0 where necessary. Three digit or longer numbers are unaffected. """ # do a little clean up to start with name = name.rstrip().replace('\\', '/') name = name.rstrip('/') # make sure we don't have trailing / chars # now pull of the trailing '3' on .mp3 filenames so we don't convert that mp3suffix = '' if name.endswith('mp3'): name = name[:-1] mp3suffix = '3' # the regex produces a empty string at the end, skip that or zfill will # expand it to 00. Note we cannot just remove the last element from the # split as it does not always produce an empty element. Joy elements = re.split(r'(\d+)', name) if elements[-1] == '': elements.pop() result = "" # this next section is a bit goofy. We need to tell whether a given # element is a number (\d+) or not. Only if it's a number do we want to do # the zfill on it. Else a name like '1b1a1z.1mp3' ends up adding a zero to # the b a and z elements as well as the 1s. (in other words that string # ends up with '010b010a010z.01mp3' instead of '01b01a01z.01mp3') # It might be possible to be clever about the regex grouping on the split, # but that idea is escaping me presently. for element in elements: try: int(element) except ValueError: result += element else: result += element.zfill(2) result += mp3suffix return re.sub(' +', ' ', result) # remove double spaces class FileManager(object): """ Class to manage filesystem on mp3 player """ def __init__(self, base_dir): # set default value for mp3 player # base_dir = base_dir or "TestFiles" base_dir = base_dir or "/media/jima/3C33-7AC4/" self.base_dir = base_dir utils.mkdir_p(self.base_dir) def does_filesystem_exist(self): """ Tests for existence - this is unused in real code, but it's handy for unit tests. It was originally added to keep lint happy. """ return os.path.exists(self.base_dir) def copy_audiobook(self, source_dir, dest_dir=None): """ Main routine to convert and copy files to mp3 player """ if not dest_dir: dest_dir = source_dir print("Copying audiobook from %s" % source_dir) else: print("Coping audiobook from %s to %s" % (source_dir, dest_dir)) for root, dirs, files in os.walk(source_dir): dirs.sort() for dir_name in dirs: full_dir = os.path.join(root, _double_digit_name(dir_name)) utils.mkdir_p(os.path.join(self.base_dir, full_dir)) for filename in sorted(files): file_name = os.path.join(root, filename) newfile = _double_digit_name(os.path.join(self.base_dir, dest_dir, file_name)) logging.debug("copying %s to %s", file_name, newfile) print("copying to %s" % (newfile)) shutil.copyfile(file_name, newfile) def copy_episodes_to_player(self, episodes): """ Copies the episodes to the mp3 player """ # make sure the podcast directory exists podcast_dir = os.path.join(self.base_dir, "podcasts_" + utils.current_date_time_as_string()) utils.mkdir_p(podcast_dir) total = len(episodes) counter = 0 for episode in sorted(episodes, key=lambda x: x.date): episode.file_name = episode.file_name.replace('\\', '/') (_, tail) = os.path.split(episode.file_name) newfile = os.path.join(podcast_dir, tail) logging.debug("copying %s to %s", episode.file_name, newfile) shutil.copyfile(episode.file_name, newfile) counter += 1 logging.debug("copied %s to %s", episode.file_name, newfile) print("%2d/%d: copied %s to %s" % (counter, total, episode.file_name, newfile))
mit
[ 624, 199, 1237, 7441, 314, 1584, 641, 314, 6118, 19, 7748, 199, 624, 199, 646, 747, 199, 646, 295, 199, 646, 2050, 199, 646, 5145, 199, 646, 1134, 470, 14, 1208, 465, 3778, 421, 199, 318, 485, 3157, 63, 8573, 63, 354, 8, 354, 304, 272, 408, 23365, 1006, 5579, 2877, 10964, 5579, 701, 7791, 282, 9186, 378, 2382, 272, 5784, 14, 221, 30467, 10964, 503, 8088, 5579, 787, 625, 26653, 14, 408, 272, 327, 886, 282, 12050, 3633, 1536, 370, 1343, 543, 272, 536, 275, 536, 14, 6735, 1252, 1814, 20786, 15107, 272, 536, 275, 536, 14, 6735, 7825, 221, 327, 1852, 3238, 781, 2793, 1133, 1172, 8520, 1182, 8365, 272, 327, 3063, 10299, 402, 314, 8520, 283, 19, 7, 641, 1275, 311, 19, 6203, 880, 781, 2793, 1133, 3957, 626, 272, 6118, 19, 4511, 275, 2125, 272, 340, 536, 14, 4130, 360, 311, 19, 735, 267, 536, 275, 536, 4439, 17, 61, 267, 6118, 19, 4511, 275, 283, 19, 7, 339, 327, 314, 5163, 16904, 282, 2701, 1059, 737, 314, 1284, 12, 3372, 626, 503, 1315, 4498, 911, 272, 327, 6544, 652, 370, 8733, 14, 221, 3390, 781, 3913, 2951, 2813, 314, 2061, 1819, 687, 314, 272, 327, 3715, 465, 652, 1630, 440, 3544, 7389, 376, 2701, 1819, 14, 221, 7135, 89, 272, 4008, 275, 295, 14, 1294, 8, 82, 13445, 68, 14705, 536, 9, 272, 340, 4008, 1988, 17, 61, 508, 8061, 267, 4008, 14, 1935, 342, 272, 754, 275, 3087, 272, 327, 642, 2163, 3420, 365, 282, 4546, 486, 1534, 1399, 14, 221, 2136, 1929, 370, 11480, 3775, 282, 1627, 272, 327, 1819, 365, 282, 1329, 14749, 68, 8771, 503, 440, 14, 221, 5972, 340, 652, 1159, 282, 1329, 886, 781, 2934, 370, 886, 272, 327, 314, 1315, 4498, 641, 652, 14, 221, 19524, 282, 536, 2839, 283, 17, 66, 17, 65, 17, 90, 14, 17, 311, 19, 7, 11187, 1536, 7791, 282, 4697, 370, 272, 327, 314, 330, 282, 436, 1315, 4008, 465, 5521, 465, 314, 413, 83, 14, 334, 262, 1163, 5932, 626, 1059, 272, 327, 11187, 1536, 543, 283, 9523, 66, 9523, 65, 9523, 90, 14, 614, 311, 19, 7, 3140, 402, 283, 614, 66, 614, 65, 614, 90, 14, 614, 311, 19, 358, 272, 327, 2779, 5594, 506, 3962, 370, 506, 15158, 422, 3595, 314, 5163, 17786, 641, 314, 3715, 12, 272, 327, 1325, 626, 16819, 365, 21375, 562, 3451, 590, 14, 272, 367, 1819, 315, 4008, 26, 267, 862, 26, 288, 1109, 8, 2108, 9, 267, 871, 1722, 26, 288, 754, 847, 1819, 267, 587, 26, 288, 754, 847, 1819, 14, 26626, 8, 18, 9, 272, 754, 847, 6118, 19, 4511, 272, 372, 295, 14, 954, 360, 435, 297, 283, 1656, 754, 9, 221, 327, 2813, 4270, 7883, 421, 199, 533, 3814, 2988, 8, 785, 304, 272, 408, 8089, 370, 9635, 10036, 641, 6118, 19, 7748, 408, 272, 347, 636, 826, 721, 277, 12, 1300, 63, 694, 304, 267, 327, 663, 849, 574, 367, 6118, 19, 7748, 267, 327, 1300, 63, 694, 275, 1300, 63, 694, 503, 298, 774, 5535, 2, 267, 1300, 63, 694, 275, 1300, 63, 694, 503, 3286, 4603, 15, 8047, 391, 15, 19, 35, 1153, 13, 23, 1348, 20, 6687, 267, 291, 14, 1095, 63, 694, 275, 1300, 63, 694, 267, 3778, 14, 8215, 63, 80, 8, 277, 14, 1095, 63, 694, 9, 339, 347, 1630, 63, 11381, 63, 4494, 8, 277, 304, 267, 408, 6496, 367, 23780, 221, 446, 642, 365, 9563, 315, 3363, 1233, 12, 1325, 652, 1159, 4926, 89, 267, 367, 4137, 2295, 14, 221, 2779, 1990, 20657, 3483, 370, 4215, 24620, 394, 18869, 14, 408, 267, 372, 747, 14, 515, 14, 2444, 8, 277, 14, 1095, 63, 694, 9, 339, 347, 1331, 63, 8130, 2706, 8, 277, 12, 1350, 63, 694, 12, 2053, 63, 694, 29, 403, 304, 267, 408, 11298, 12981, 370, 3957, 436, 1331, 1584, 370, 6118, 19, 7748, 408, 267, 340, 440, 2053, 63, 694, 26, 288, 2053, 63, 694, 275, 1350, 63, 694, 288, 870, 480, 32596, 10491, 2706, 687, 450, 83, 2, 450, 1350, 63, 694, 9, 267, 587, 26, 288, 870, 480, 18268, 316, 10491, 2706, 687, 450, 83, 370, 450, 83, 2, 450, 334, 1365, 63, 694, 12, 2053, 63, 694, 430, 398, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 1365, 63, 694, 304, 288, 7606, 14, 3191, 342, 288, 367, 2935, 63, 354, 315, 7606, 26, 355, 2615, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 485, 3157, 63, 8573, 63, 354, 8, 694, 63, 354, 430, 355, 3778, 14, 8215, 63, 80, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1095, 63, 694, 12, 2615, 63, 694, 430, 288, 367, 1788, 315, 3355, 8, 1725, 304, 355, 570, 63, 354, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 1788, 9, 355, 892, 493, 275, 485, 3157, 63, 8573, 63, 354, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1095, 63, 694, 12, 12933, 2053, 63, 694, 12, 570, 63, 354, 430, 355, 2050, 14, 1757, 480, 1574, 316, 450, 83, 370, 450, 83, 401, 570, 63, 354, 12, 892, 493, 9, 355, 870, 480, 1574, 316, 370, 450, 83, 2, 450, 334, 1222, 493, 430, 355, 5145, 14, 21997, 8, 493, 63, 354, 12, 892, 493, 9, 339, 347, 1331, 63, 22027, 63, 475, 63, 6147, 8, 277, 12, 30060, 304, 267, 408, 29622, 1500, 314, 30060, 370, 314, 6118, 19, 7748, 408, 267, 327, 1852, 3238, 314, 15329, 2931, 2082, 3495, 267, 15329, 2931, 63, 694, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1095, 63, 694, 12, 298, 12656, 2931, 83, 12172, 435, 3521, 3778, 14, 1818, 63, 602, 63, 521, 63, 305, 63, 875, 1012, 267, 3778, 14, 8215, 63, 80, 8, 12656, 2931, 63, 694, 9, 398, 3141, 275, 822, 8, 22027, 9, 267, 7055, 275, 378, 267, 367, 11052, 315, 3355, 8, 22027, 12, 790, 29, 2734, 671, 26, 671, 14, 602, 304, 288, 11052, 14, 493, 63, 354, 275, 11052, 14, 493, 63, 354, 14, 1814, 20786, 15107, 288, 27017, 9483, 9, 275, 747, 14, 515, 14, 1294, 8, 9544, 14 ]
[ 199, 1237, 7441, 314, 1584, 641, 314, 6118, 19, 7748, 199, 624, 199, 646, 747, 199, 646, 295, 199, 646, 2050, 199, 646, 5145, 199, 646, 1134, 470, 14, 1208, 465, 3778, 421, 199, 318, 485, 3157, 63, 8573, 63, 354, 8, 354, 304, 272, 408, 23365, 1006, 5579, 2877, 10964, 5579, 701, 7791, 282, 9186, 378, 2382, 272, 5784, 14, 221, 30467, 10964, 503, 8088, 5579, 787, 625, 26653, 14, 408, 272, 327, 886, 282, 12050, 3633, 1536, 370, 1343, 543, 272, 536, 275, 536, 14, 6735, 1252, 1814, 20786, 15107, 272, 536, 275, 536, 14, 6735, 7825, 221, 327, 1852, 3238, 781, 2793, 1133, 1172, 8520, 1182, 8365, 272, 327, 3063, 10299, 402, 314, 8520, 283, 19, 7, 641, 1275, 311, 19, 6203, 880, 781, 2793, 1133, 3957, 626, 272, 6118, 19, 4511, 275, 2125, 272, 340, 536, 14, 4130, 360, 311, 19, 735, 267, 536, 275, 536, 4439, 17, 61, 267, 6118, 19, 4511, 275, 283, 19, 7, 339, 327, 314, 5163, 16904, 282, 2701, 1059, 737, 314, 1284, 12, 3372, 626, 503, 1315, 4498, 911, 272, 327, 6544, 652, 370, 8733, 14, 221, 3390, 781, 3913, 2951, 2813, 314, 2061, 1819, 687, 314, 272, 327, 3715, 465, 652, 1630, 440, 3544, 7389, 376, 2701, 1819, 14, 221, 7135, 89, 272, 4008, 275, 295, 14, 1294, 8, 82, 13445, 68, 14705, 536, 9, 272, 340, 4008, 1988, 17, 61, 508, 8061, 267, 4008, 14, 1935, 342, 272, 754, 275, 3087, 272, 327, 642, 2163, 3420, 365, 282, 4546, 486, 1534, 1399, 14, 221, 2136, 1929, 370, 11480, 3775, 282, 1627, 272, 327, 1819, 365, 282, 1329, 14749, 68, 8771, 503, 440, 14, 221, 5972, 340, 652, 1159, 282, 1329, 886, 781, 2934, 370, 886, 272, 327, 314, 1315, 4498, 641, 652, 14, 221, 19524, 282, 536, 2839, 283, 17, 66, 17, 65, 17, 90, 14, 17, 311, 19, 7, 11187, 1536, 7791, 282, 4697, 370, 272, 327, 314, 330, 282, 436, 1315, 4008, 465, 5521, 465, 314, 413, 83, 14, 334, 262, 1163, 5932, 626, 1059, 272, 327, 11187, 1536, 543, 283, 9523, 66, 9523, 65, 9523, 90, 14, 614, 311, 19, 7, 3140, 402, 283, 614, 66, 614, 65, 614, 90, 14, 614, 311, 19, 358, 272, 327, 2779, 5594, 506, 3962, 370, 506, 15158, 422, 3595, 314, 5163, 17786, 641, 314, 3715, 12, 272, 327, 1325, 626, 16819, 365, 21375, 562, 3451, 590, 14, 272, 367, 1819, 315, 4008, 26, 267, 862, 26, 288, 1109, 8, 2108, 9, 267, 871, 1722, 26, 288, 754, 847, 1819, 267, 587, 26, 288, 754, 847, 1819, 14, 26626, 8, 18, 9, 272, 754, 847, 6118, 19, 4511, 272, 372, 295, 14, 954, 360, 435, 297, 283, 1656, 754, 9, 221, 327, 2813, 4270, 7883, 421, 199, 533, 3814, 2988, 8, 785, 304, 272, 408, 8089, 370, 9635, 10036, 641, 6118, 19, 7748, 408, 272, 347, 636, 826, 721, 277, 12, 1300, 63, 694, 304, 267, 327, 663, 849, 574, 367, 6118, 19, 7748, 267, 327, 1300, 63, 694, 275, 1300, 63, 694, 503, 298, 774, 5535, 2, 267, 1300, 63, 694, 275, 1300, 63, 694, 503, 3286, 4603, 15, 8047, 391, 15, 19, 35, 1153, 13, 23, 1348, 20, 6687, 267, 291, 14, 1095, 63, 694, 275, 1300, 63, 694, 267, 3778, 14, 8215, 63, 80, 8, 277, 14, 1095, 63, 694, 9, 339, 347, 1630, 63, 11381, 63, 4494, 8, 277, 304, 267, 408, 6496, 367, 23780, 221, 446, 642, 365, 9563, 315, 3363, 1233, 12, 1325, 652, 1159, 4926, 89, 267, 367, 4137, 2295, 14, 221, 2779, 1990, 20657, 3483, 370, 4215, 24620, 394, 18869, 14, 408, 267, 372, 747, 14, 515, 14, 2444, 8, 277, 14, 1095, 63, 694, 9, 339, 347, 1331, 63, 8130, 2706, 8, 277, 12, 1350, 63, 694, 12, 2053, 63, 694, 29, 403, 304, 267, 408, 11298, 12981, 370, 3957, 436, 1331, 1584, 370, 6118, 19, 7748, 408, 267, 340, 440, 2053, 63, 694, 26, 288, 2053, 63, 694, 275, 1350, 63, 694, 288, 870, 480, 32596, 10491, 2706, 687, 450, 83, 2, 450, 1350, 63, 694, 9, 267, 587, 26, 288, 870, 480, 18268, 316, 10491, 2706, 687, 450, 83, 370, 450, 83, 2, 450, 334, 1365, 63, 694, 12, 2053, 63, 694, 430, 398, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 1365, 63, 694, 304, 288, 7606, 14, 3191, 342, 288, 367, 2935, 63, 354, 315, 7606, 26, 355, 2615, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 485, 3157, 63, 8573, 63, 354, 8, 694, 63, 354, 430, 355, 3778, 14, 8215, 63, 80, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1095, 63, 694, 12, 2615, 63, 694, 430, 288, 367, 1788, 315, 3355, 8, 1725, 304, 355, 570, 63, 354, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 1788, 9, 355, 892, 493, 275, 485, 3157, 63, 8573, 63, 354, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1095, 63, 694, 12, 12933, 2053, 63, 694, 12, 570, 63, 354, 430, 355, 2050, 14, 1757, 480, 1574, 316, 450, 83, 370, 450, 83, 401, 570, 63, 354, 12, 892, 493, 9, 355, 870, 480, 1574, 316, 370, 450, 83, 2, 450, 334, 1222, 493, 430, 355, 5145, 14, 21997, 8, 493, 63, 354, 12, 892, 493, 9, 339, 347, 1331, 63, 22027, 63, 475, 63, 6147, 8, 277, 12, 30060, 304, 267, 408, 29622, 1500, 314, 30060, 370, 314, 6118, 19, 7748, 408, 267, 327, 1852, 3238, 314, 15329, 2931, 2082, 3495, 267, 15329, 2931, 63, 694, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1095, 63, 694, 12, 298, 12656, 2931, 83, 12172, 435, 3521, 3778, 14, 1818, 63, 602, 63, 521, 63, 305, 63, 875, 1012, 267, 3778, 14, 8215, 63, 80, 8, 12656, 2931, 63, 694, 9, 398, 3141, 275, 822, 8, 22027, 9, 267, 7055, 275, 378, 267, 367, 11052, 315, 3355, 8, 22027, 12, 790, 29, 2734, 671, 26, 671, 14, 602, 304, 288, 11052, 14, 493, 63, 354, 275, 11052, 14, 493, 63, 354, 14, 1814, 20786, 15107, 288, 27017, 9483, 9, 275, 747, 14, 515, 14, 1294, 8, 9544, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
derekhe/huawei-g330d-u8825d-kernel
scripts/gcc-wrapper.py
33
4591
#! /usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Code Aurora nor # the names of its contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Invoke gcc, looking for warnings, and causing a failure if there are # non-whitelisted warnings. import errno import re import os import sys import subprocess # Note that gcc uses unicode, which may depend on the locale. TODO: # force LANG to be set to en_US.UTF-8 to get consistent warnings. allowed_warnings = set([ "alignment.c:298", "alignment.c:720", "async.c:122", "async.c:270", "block.c:885", "block.c:886", "dir.c:43", "dm.c:1053", "dm.c:1080", "dm-table.c:1120", "dm-table.c:1126", "drm_edid.c:1303", "eventpoll.c:1143", "f_mass_storage.c:3368", "inode.c:72", "inode.c:73", "inode.c:74", "msm_sdcc.c:126", "msm_sdcc.c:128", "nf_conntrack_core.c:1579", "nf_conntrack_core.c:1580", "nf_conntrack_netlink.c:790", "nf_conntrack_proto.c:210", "nf_conntrack_proto.c:345", "nf_conntrack_proto.c:370", "nf_nat_core.c:528", "nf_nat_core.c:739", "nf_nat_core.c:740", "nf_nat_core.c:741", "nf_nat_core.c:742", "nf_nat_core.c:751", "nf_nat_core.c:753", "nf_nat_core.c:756", "nf_nat_ftp.c:123", "nf_nat_pptp.c:285", "nf_nat_pptp.c:288", "nf_nat_pptp.c:291", "nf_nat_pptp.c:294", "nf_nat_sip.c:550", "nf_nat_sip.c:551", "nf_nat_sip.c:552", "nf_nat_sip.c:553", "nf_nat_sip.c:555", "nf_nat_sip.c:556", "nf_nat_sip.c:554", "nf_nat_standalone.c:118", "nf_nat_tftp.c:46", "return_address.c:62", "sch_generic.c:678", "soc-core.c:1719", "xt_log.h:50", "vx6953.c:3124", ]) # Capture the name of the object file, can find it. ofile = None warning_re = re.compile(r'''(.*/|)([^/]+\.[a-z]+:\d+):(\d+:)? warning:''') def interpret_warning(line): """Decode the message from gcc. The messages we care about have a filename, and a warning""" line = line.rstrip('\n') m = warning_re.match(line) if m and m.group(2) not in allowed_warnings: print "error, forbidden warning:", m.group(2) # If there is a warning, remove any object if it exists. if ofile: try: os.remove(ofile) except OSError: pass sys.exit(1) def run_gcc(): args = sys.argv[1:] # Look for -o try: i = args.index('-o') global ofile ofile = args[i+1] except (ValueError, IndexError): pass compiler = sys.argv[0] try: proc = subprocess.Popen(args, stderr=subprocess.PIPE) for line in proc.stderr: print line, interpret_warning(line) result = proc.wait() except OSError as e: result = e.errno if result == errno.ENOENT: print args[0] + ':',e.strerror print 'Is your PATH set correctly?' else: print ' '.join(args), str(e) return result if __name__ == '__main__': status = run_gcc() sys.exit(status)
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 7760, 13, 7409, 12, 5495, 437, 300, 11131, 2104, 453, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 5495, 437, 300, 11131, 6590, 199, 3, 755, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 755, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 755, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 11214, 13, 12799, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 199, 3, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 199, 3, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 199, 3, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 199, 3, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 31049, 19443, 12, 10023, 367, 3598, 12, 436, 25498, 282, 5988, 340, 2337, 787, 199, 3, 2222, 13, 7510, 15023, 3598, 14, 199, 199, 646, 7554, 199, 646, 295, 199, 646, 747, 199, 646, 984, 199, 646, 3873, 199, 199, 3, 3390, 626, 19443, 4440, 2649, 12, 1314, 1443, 11687, 641, 314, 5867, 14, 221, 3254, 26, 199, 3, 3542, 25029, 370, 506, 663, 370, 655, 63, 1668, 14, 6610, 13, 24, 370, 664, 12137, 3598, 14, 199, 199, 6541, 63, 5451, 275, 663, 779, 272, 298, 13699, 14, 67, 26, 12877, 401, 272, 298, 13699, 14, 67, 26, 18386, 401, 272, 298, 4146, 14, 67, 26, 7507, 401, 272, 298, 4146, 14, 67, 26, 13299, 401, 272, 298, 1457, 14, 67, 26, 15889, 401, 272, 298, 1457, 14, 67, 26, 31830, 401, 272, 298, 694, 14, 67, 26, 2824, 401, 272, 298, 6428, 14, 67, 26, 709, 2481, 401, 272, 298, 6428, 14, 67, 26, 23514, 401, 272, 298, 6428, 13, 1224, 14, 67, 26, 6094, 16, 401, 272, 298, 6428, 13, 1224, 14, 67, 26, 6094, 22, 401, 272, 298, 5012, 77, 63, 6297, 68, 14, 67, 26, 969, 1644, 401, 272, 298, 1430, 6843, 14, 67, 26, 845, 2824, 401, 272, 298, 70, 63, 11535, 63, 3494, 14, 67, 26, 1153, 2333, 401, 272, 298, 15993, 14, 67, 26, 2819, 401, 272, 298, 15993, 14, 67, 26, 2898, 401, 272, 298, 15993, 14, 67, 26, 1342, 401, 272, 298, 706, 77, 63, 3893, 2055, 14, 67, 26, 7957, 401, 272, 298, 706, 77, 63, 3893, 2055, 14, 67, 26, 3933, 401, 272, 298, 9914, 63, 388, 343, 8085, 63, 1018, 14, 67, 26, 1046, 1965, 401, 272, 298, 9914, 63, 388, 343, 8085, 63, 1018, 14, 67, 26, 1046, 1257, 401, 272, 298, 9914, 63, 388, 343, 8085, 63, 846, 1073, 14, 67, 26, 22252, 401, 272, 298, 9914, 63, 388, 343, 8085, 63, 2625, 14, 67, 26, 12725, 401, 272, 298, 9914, 63, 388, 343, 8085, 63, 2625, 14, 67, 26, 9908, 401, 272, 298, 9914, 63, 388, 343, 8085, 63, 2625, 14, 67, 26, 13812, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 28032, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 32257, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 17702, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 21996, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 16498, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 24595, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 22566, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 29152, 401, 272, 298, 9914, 63, 9468, 63, 8915, 14, 67, 26, 4288, 401, 272, 298, 9914, 63, 9468, 63, 80, 541, 80, 14, 67, 26, 14523, 401, 272, 298, 9914, 63, 9468, 63, 80, 541, 80, 14, 67, 26, 10740, 401, 272, 298, 9914, 63, 9468, 63, 80, 541, 80, 14, 67, 26, 16319, 401, 272, 298, 9914, 63, 9468, 63, 80, 541, 80, 14, 67, 26, 10693, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 16859, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 23327, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 19414, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 24412, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 15722, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 18683, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 19264, 401, 272, 298, 9914, 63, 9468, 63, 20323, 14, 67, 26, 7906, 401, 272, 298, 9914, 63, 9468, 63, 3249, 683, 14, 67, 26, 2466, 401, 272, 298, 1107, 63, 1562, 14, 67, 26, 2789, 401, 272, 298, 15820, 63, 6767, 14, 67, 26, 17237, 401, 272, 298, 83, 679, 13, 1018, 14, 67, 26, 1196, 1167, 401, 272, 298, 400, 63, 793, 14, 72, 26, 1400, 401, 272 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 7760, 13, 7409, 12, 5495, 437, 300, 11131, 2104, 453, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 5495, 437, 300, 11131, 6590, 199, 3, 755, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 755, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 755, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 11214, 13, 12799, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 199, 3, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 199, 3, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 199, 3, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 199, 3, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 31049, 19443, 12, 10023, 367, 3598, 12, 436, 25498, 282, 5988, 340, 2337, 787, 199, 3, 2222, 13, 7510, 15023, 3598, 14, 199, 199, 646, 7554, 199, 646, 295, 199, 646, 747, 199, 646, 984, 199, 646, 3873, 199, 199, 3, 3390, 626, 19443, 4440, 2649, 12, 1314, 1443, 11687, 641, 314, 5867, 14, 221, 3254, 26, 199, 3, 3542, 25029, 370, 506, 663, 370, 655, 63, 1668, 14, 6610, 13, 24, 370, 664, 12137, 3598, 14, 199, 199, 6541, 63, 5451, 275, 663, 779, 272, 298, 13699, 14, 67, 26, 12877, 401, 272, 298, 13699, 14, 67, 26, 18386, 401, 272, 298, 4146, 14, 67, 26, 7507, 401, 272, 298, 4146, 14, 67, 26, 13299, 401, 272, 298, 1457, 14, 67, 26, 15889, 401, 272, 298, 1457, 14, 67, 26, 31830, 401, 272, 298, 694, 14, 67, 26, 2824, 401, 272, 298, 6428, 14, 67, 26, 709, 2481, 401, 272, 298, 6428, 14, 67, 26, 23514, 401, 272, 298, 6428, 13, 1224, 14, 67, 26, 6094, 16, 401, 272, 298, 6428, 13, 1224, 14, 67, 26, 6094, 22, 401, 272, 298, 5012, 77, 63, 6297, 68, 14, 67, 26, 969, 1644, 401, 272, 298, 1430, 6843, 14, 67, 26, 845, 2824, 401, 272, 298, 70, 63, 11535, 63, 3494, 14, 67, 26, 1153, 2333, 401, 272, 298, 15993, 14, 67, 26, 2819, 401, 272, 298, 15993, 14, 67, 26, 2898, 401, 272, 298, 15993, 14, 67, 26, 1342, 401, 272, 298, 706, 77, 63, 3893, 2055, 14, 67, 26, 7957, 401, 272, 298, 706, 77, 63, 3893, 2055, 14, 67, 26, 3933, 401, 272, 298, 9914, 63, 388, 343, 8085, 63, 1018, 14, 67, 26, 1046, 1965, 401, 272, 298, 9914, 63, 388, 343, 8085, 63, 1018, 14, 67, 26, 1046, 1257, 401, 272, 298, 9914, 63, 388, 343, 8085, 63, 846, 1073, 14, 67, 26, 22252, 401, 272, 298, 9914, 63, 388, 343, 8085, 63, 2625, 14, 67, 26, 12725, 401, 272, 298, 9914, 63, 388, 343, 8085, 63, 2625, 14, 67, 26, 9908, 401, 272, 298, 9914, 63, 388, 343, 8085, 63, 2625, 14, 67, 26, 13812, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 28032, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 32257, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 17702, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 21996, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 16498, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 24595, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 22566, 401, 272, 298, 9914, 63, 9468, 63, 1018, 14, 67, 26, 29152, 401, 272, 298, 9914, 63, 9468, 63, 8915, 14, 67, 26, 4288, 401, 272, 298, 9914, 63, 9468, 63, 80, 541, 80, 14, 67, 26, 14523, 401, 272, 298, 9914, 63, 9468, 63, 80, 541, 80, 14, 67, 26, 10740, 401, 272, 298, 9914, 63, 9468, 63, 80, 541, 80, 14, 67, 26, 16319, 401, 272, 298, 9914, 63, 9468, 63, 80, 541, 80, 14, 67, 26, 10693, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 16859, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 23327, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 19414, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 24412, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 15722, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 18683, 401, 272, 298, 9914, 63, 9468, 63, 17839, 14, 67, 26, 19264, 401, 272, 298, 9914, 63, 9468, 63, 20323, 14, 67, 26, 7906, 401, 272, 298, 9914, 63, 9468, 63, 3249, 683, 14, 67, 26, 2466, 401, 272, 298, 1107, 63, 1562, 14, 67, 26, 2789, 401, 272, 298, 15820, 63, 6767, 14, 67, 26, 17237, 401, 272, 298, 83, 679, 13, 1018, 14, 67, 26, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
rchakra3/mase
python101/code/Subject.py
14
2318
"""Example of the Observer pattern using Pyro. Copyright 2010 Allen B. Downey License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html """ from copy import copy # this import has to be here in case we get a Pyro error from an RMI import Pyro.errors from remote_object import RemoteObject, NameServer class Subject(RemoteObject): """A Subject is an object that keeps track of the Observers watching it. When the state of a subject changes, it notifies each Observer on the list.""" def __init__(self, name): RemoteObject.__init__(self, name) self.observers = [] def notify_observers(self): """notify all registered observers when the state of the subject changes""" for observer in copy(self.observers): try: print 'Notifying', observer ns = NameServer() proxy = ns.get_proxy(observer) proxy.notify() except Exception, x: # this clause should catch errors that occur # in the Observer code. print ''.join(Pyro.util.getPyroTraceback(x)) except: # this clause should catch Pyro NamingErrors, # which occur when an observer dies. print 'Removing ' + observer self.observers.remove(observer) # the following methods are intended to be invoked remotely def register(self, name): """Registers a new Observer (invoked by the Observer).""" self.observers.append(name) print 'Registered ' + name class SimpleSubject(Subject): def __init__(self, name, state=0): """The state of a SimpleSubject is a single integer named 'state' In a real application, the state would be a more elaborate data structure.""" Subject.__init__(self, name) self.state = 0 # the following methods are intended to be invoked remotely def set_state(self, state): """Changes the state of the Subject.""" print 'New state', state self.state = state self.notify_observers() def get_state(self): """Gets the current state of the Subject.""" return self.state sub = SimpleSubject('simple_subject') sub.requestLoop()
unlicense
[ 624, 9846, 402, 314, 17985, 1000, 3851, 1808, 1611, 293, 14, 199, 199, 7384, 7129, 4580, 552, 699, 14, 577, 583, 23263, 199, 3761, 26, 1664, 14629, 86, 19, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 199, 199, 624, 199, 199, 504, 1331, 492, 1331, 199, 199, 3, 642, 492, 965, 370, 506, 2348, 315, 1930, 781, 664, 282, 1611, 293, 1125, 687, 376, 820, 10709, 199, 646, 1611, 293, 14, 2550, 199, 504, 3982, 63, 785, 492, 17283, 1692, 12, 2812, 3120, 421, 199, 533, 26793, 8, 6713, 1692, 304, 272, 408, 33, 26793, 365, 376, 909, 626, 18578, 4426, 402, 314, 17985, 5871, 272, 9626, 316, 652, 14, 221, 3979, 314, 1174, 402, 282, 5420, 4493, 12, 652, 272, 949, 1428, 397, 1924, 17985, 1000, 641, 314, 769, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 17283, 1692, 855, 826, 721, 277, 12, 536, 9, 267, 291, 14, 2873, 5871, 275, 942, 339, 347, 11705, 63, 2873, 5871, 8, 277, 304, 267, 408, 6814, 1006, 7264, 2607, 5871, 1380, 314, 1174, 402, 267, 314, 5420, 4493, 624, 2728, 367, 27336, 315, 1331, 8, 277, 14, 2873, 5871, 304, 288, 862, 26, 355, 870, 283, 8645, 316, 297, 27336, 355, 700, 275, 2812, 3120, 342, 355, 4566, 275, 700, 14, 362, 63, 3280, 8, 23968, 9, 355, 4566, 14, 6814, 342, 288, 871, 2186, 12, 671, 26, 355, 327, 642, 8502, 1077, 8579, 2552, 626, 4781, 355, 327, 315, 314, 17985, 1000, 1233, 14, 355, 870, 6522, 904, 8, 2713, 293, 14, 1974, 14, 362, 2713, 293, 15905, 8, 88, 430, 288, 871, 26, 355, 327, 642, 8502, 1077, 8579, 1611, 293, 653, 9568, 9298, 12, 355, 327, 1314, 4781, 1380, 376, 27336, 487, 397, 14, 355, 870, 283, 23420, 283, 435, 27336, 355, 291, 14, 2873, 5871, 14, 2168, 8, 23968, 9, 339, 327, 314, 2569, 3102, 787, 11619, 370, 506, 10302, 3982, 590, 339, 347, 2274, 8, 277, 12, 536, 304, 267, 408, 31136, 282, 892, 17985, 1000, 334, 5350, 7620, 701, 314, 17985, 1000, 10477, 267, 291, 14, 2873, 5871, 14, 740, 8, 354, 9, 267, 870, 283, 20341, 283, 435, 536, 421, 199, 533, 5870, 13528, 8, 13528, 304, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1174, 29, 16, 304, 267, 408, 1918, 1174, 402, 282, 5870, 13528, 365, 282, 2849, 3000, 4310, 283, 929, 7, 267, 1010, 282, 3363, 4223, 12, 314, 1174, 3955, 506, 282, 1655, 579, 371, 269, 323, 267, 666, 5523, 1041, 267, 26793, 855, 826, 721, 277, 12, 536, 9, 267, 291, 14, 929, 275, 378, 339, 327, 314, 2569, 3102, 787, 11619, 370, 506, 10302, 3982, 590, 5493, 347, 663, 63, 929, 8, 277, 12, 1174, 304, 267, 408, 13907, 314, 1174, 402, 314, 26793, 1041, 267, 870, 283, 4665, 1174, 297, 1174, 267, 291, 14, 929, 275, 1174, 267, 291, 14, 6814, 63, 2873, 5871, 342, 339, 347, 664, 63, 929, 8, 277, 304, 267, 408, 14426, 314, 1453, 1174, 402, 314, 26793, 1041, 267, 372, 291, 14, 929, 199, 199, 954, 275, 5870, 13528, 360, 4129, 63, 5875, 358, 199, 954, 14, 1069, 7382, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 9846, 402, 314, 17985, 1000, 3851, 1808, 1611, 293, 14, 199, 199, 7384, 7129, 4580, 552, 699, 14, 577, 583, 23263, 199, 3761, 26, 1664, 14629, 86, 19, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 199, 199, 624, 199, 199, 504, 1331, 492, 1331, 199, 199, 3, 642, 492, 965, 370, 506, 2348, 315, 1930, 781, 664, 282, 1611, 293, 1125, 687, 376, 820, 10709, 199, 646, 1611, 293, 14, 2550, 199, 504, 3982, 63, 785, 492, 17283, 1692, 12, 2812, 3120, 421, 199, 533, 26793, 8, 6713, 1692, 304, 272, 408, 33, 26793, 365, 376, 909, 626, 18578, 4426, 402, 314, 17985, 5871, 272, 9626, 316, 652, 14, 221, 3979, 314, 1174, 402, 282, 5420, 4493, 12, 652, 272, 949, 1428, 397, 1924, 17985, 1000, 641, 314, 769, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 17283, 1692, 855, 826, 721, 277, 12, 536, 9, 267, 291, 14, 2873, 5871, 275, 942, 339, 347, 11705, 63, 2873, 5871, 8, 277, 304, 267, 408, 6814, 1006, 7264, 2607, 5871, 1380, 314, 1174, 402, 267, 314, 5420, 4493, 624, 2728, 367, 27336, 315, 1331, 8, 277, 14, 2873, 5871, 304, 288, 862, 26, 355, 870, 283, 8645, 316, 297, 27336, 355, 700, 275, 2812, 3120, 342, 355, 4566, 275, 700, 14, 362, 63, 3280, 8, 23968, 9, 355, 4566, 14, 6814, 342, 288, 871, 2186, 12, 671, 26, 355, 327, 642, 8502, 1077, 8579, 2552, 626, 4781, 355, 327, 315, 314, 17985, 1000, 1233, 14, 355, 870, 6522, 904, 8, 2713, 293, 14, 1974, 14, 362, 2713, 293, 15905, 8, 88, 430, 288, 871, 26, 355, 327, 642, 8502, 1077, 8579, 1611, 293, 653, 9568, 9298, 12, 355, 327, 1314, 4781, 1380, 376, 27336, 487, 397, 14, 355, 870, 283, 23420, 283, 435, 27336, 355, 291, 14, 2873, 5871, 14, 2168, 8, 23968, 9, 339, 327, 314, 2569, 3102, 787, 11619, 370, 506, 10302, 3982, 590, 339, 347, 2274, 8, 277, 12, 536, 304, 267, 408, 31136, 282, 892, 17985, 1000, 334, 5350, 7620, 701, 314, 17985, 1000, 10477, 267, 291, 14, 2873, 5871, 14, 740, 8, 354, 9, 267, 870, 283, 20341, 283, 435, 536, 421, 199, 533, 5870, 13528, 8, 13528, 304, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1174, 29, 16, 304, 267, 408, 1918, 1174, 402, 282, 5870, 13528, 365, 282, 2849, 3000, 4310, 283, 929, 7, 267, 1010, 282, 3363, 4223, 12, 314, 1174, 3955, 506, 282, 1655, 579, 371, 269, 323, 267, 666, 5523, 1041, 267, 26793, 855, 826, 721, 277, 12, 536, 9, 267, 291, 14, 929, 275, 378, 339, 327, 314, 2569, 3102, 787, 11619, 370, 506, 10302, 3982, 590, 5493, 347, 663, 63, 929, 8, 277, 12, 1174, 304, 267, 408, 13907, 314, 1174, 402, 314, 26793, 1041, 267, 870, 283, 4665, 1174, 297, 1174, 267, 291, 14, 929, 275, 1174, 267, 291, 14, 6814, 63, 2873, 5871, 342, 339, 347, 664, 63, 929, 8, 277, 304, 267, 408, 14426, 314, 1453, 1174, 402, 314, 26793, 1041, 267, 372, 291, 14, 929, 199, 199, 954, 275, 5870, 13528, 360, 4129, 63, 5875, 358, 199, 954, 14, 1069, 7382, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
mrrrgn/AutobahnPython
examples/twisted/websocket/streaming/frame_based_client.py
18
3407
############################################################################### ## ## Copyright (C) 2011-2013 Tavendo GmbH ## ## 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 hashlib from pprint import pprint from ranstring import randomByteString from twisted.internet import reactor from autobahn.twisted.websocket import WebSocketClientFactory, \ WebSocketClientProtocol, \ connectWS FRAME_SIZE = 1 * 2**20 FRAME_COUNT = 10 class FrameBasedHashClientProtocol(WebSocketClientProtocol): """ Message-based WebSockets client that generates stream of random octets sent to WebSockets server as a sequence of frames all in one message. The server will respond to us with the SHA-256 computed over frames. When we receive response, we repeat by sending a new frame. """ def sendOneFrame(self): data = randomByteString(FRAME_SIZE) self.sha256.update(data) digest = self.sha256.hexdigest() print("Digest for frame {} computed by client: {}".format(self.count, digest)) self.sendMessageFrame(data) def onOpen(self): self.count = 0 self.finished = False self.beginMessage(isBinary = True) self.sha256 = hashlib.sha256() self.sendOneFrame() def onMessage(self, payload, isBinary): print("Digest for frame {} computed by server: {}".format(self.count, payload.decode('utf8'))) #pprint(self.trafficStats.__json__()) self.count += 1 if self.count < FRAME_COUNT: self.sendOneFrame() elif not self.finished: self.endMessage() self.finished = True if self.count >= FRAME_COUNT: self.sendClose() def onClose(self, wasClean, code, reason): reactor.stop() if __name__ == '__main__': factory = WebSocketClientFactory("ws://localhost:9000") factory.protocol = FrameBasedHashClientProtocol enableCompression = False if enableCompression: from autobahn.websocket.compress import PerMessageDeflateOffer, \ PerMessageDeflateResponse, \ PerMessageDeflateResponseAccept ## The extensions offered to the server .. offers = [PerMessageDeflateOffer()] factory.setProtocolOptions(perMessageCompressionOffers = offers) ## Function to accept responses from the server .. def accept(response): if isinstance(response, PerMessageDeflateResponse): return PerMessageDeflateResponseAccept(response) factory.setProtocolOptions(perMessageCompressionAccept = accept) connectWS(factory) reactor.run()
apache-2.0
[ 11490, 202, 199, 309, 202, 199, 309, 221, 1898, 334, 35, 9, 7760, 13, 6965, 377, 1214, 500, 79, 23428, 202, 199, 309, 202, 199, 309, 221, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 202, 199, 309, 221, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 202, 199, 309, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 202, 199, 309, 202, 199, 309, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 202, 199, 309, 202, 199, 309, 221, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 202, 199, 309, 221, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 202, 199, 309, 221, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 202, 199, 309, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 202, 199, 309, 221, 4204, 1334, 314, 844, 14, 202, 199, 309, 202, 199, 11490, 2999, 199, 646, 8337, 202, 199, 504, 10933, 492, 10933, 202, 199, 504, 21471, 875, 492, 2196, 4861, 1558, 2999, 199, 504, 7390, 14, 4901, 492, 9655, 2999, 199, 504, 2599, 2470, 6164, 14, 12145, 14, 13508, 492, 18846, 30115, 12, 971, 202, 4318, 18846, 3041, 3658, 12, 971, 202, 4318, 4907, 5035, 8065, 199, 12683, 63, 4305, 275, 413, 627, 499, 538, 1165, 202, 199, 12683, 63, 8760, 275, 1616, 8065, 199, 533, 11726, 20409, 3476, 3041, 3658, 8, 18477, 3041, 3658, 304, 15497, 408, 15497, 6430, 13, 6788, 18846, 83, 1890, 626, 12821, 2547, 402, 2196, 27135, 15497, 4847, 370, 18846, 83, 1654, 465, 282, 3414, 402, 11223, 1006, 315, 1373, 1245, 14, 15497, 710, 1654, 911, 22722, 370, 2739, 543, 314, 12002, 13, 3912, 9235, 1806, 11223, 14, 15497, 3979, 781, 9128, 1177, 12, 781, 11982, 701, 10209, 282, 892, 2787, 14, 15497, 408, 10060, 257, 347, 3222, 4395, 3160, 8, 277, 304, 8608, 666, 275, 2196, 4861, 1558, 8, 12683, 63, 4305, 9, 2999, 489, 291, 14, 4835, 3912, 14, 873, 8, 576, 9, 8608, 10017, 275, 291, 14, 4835, 3912, 14, 11453, 342, 8608, 870, 480, 18541, 367, 2787, 1052, 9235, 701, 1890, 26, 8352, 908, 8, 277, 14, 835, 12, 10017, 430, 2999, 489, 291, 14, 2254, 2209, 3160, 8, 576, 9, 10060, 257, 347, 641, 4299, 8, 277, 304, 8608, 291, 14, 835, 275, 378, 8608, 291, 14, 8669, 275, 756, 8608, 291, 14, 5037, 2209, 8, 374, 6636, 275, 715, 9, 8608, 291, 14, 4835, 3912, 275, 8337, 14, 4835, 3912, 342, 8608, 291, 14, 2254, 4395, 3160, 342, 10060, 257, 347, 641, 2209, 8, 277, 12, 4886, 12, 365, 6636, 304, 8608, 870, 480, 18541, 367, 2787, 1052, 9235, 701, 1654, 26, 8352, 908, 8, 277, 14, 835, 12, 4886, 14, 2708, 360, 1624, 24, 7058, 8608, 327, 15380, 8, 277, 14, 17297, 8257, 855, 1001, 29133, 8608, 291, 14, 835, 847, 413, 2999, 489, 340, 291, 14, 835, 665, 28671, 1991, 63, 8760, 26, 8740, 291, 14, 2254, 4395, 3160, 342, 8608, 916, 440, 291, 14, 8669, 26, 8740, 291, 14, 500, 2209, 342, 8740, 291, 14, 8669, 275, 715, 2999, 489, 340, 291, 14, 835, 2356, 28671, 1991, 63, 8760, 26, 8740, 291, 14, 2254, 4724, 342, 10060, 257, 347, 641, 4724, 8, 277, 12, 1990, 6580, 12, 1233, 12, 4499, 304, 8608, 9655, 14, 2379, 342, 8065, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 10060, 257, 6434, 275, 18846, 30115, 480, 3569, 921, 5967, 26, 25, 1493, 531, 15497, 6434, 14, 3922, 275, 11726, 20409, 3476, 3041, 3658, 10060, 257, 4756, 25551, 275, 756, 15497, 340, 4756, 25551, 26, 8608, 687, 2599, 2470, 6164, 14, 13508, 14, 6447, 492, 3492, 2209, 6172, 750, 22154, 12, 971, 202, 6343, 3492, 2209, 6172, 750, 2364, 12, 971, 202, 6343, 3492, 2209, 6172, 750, 2364, 8422, 2999, 489, 925, 710, 5478, 402, 22941, 370, 314, 1654, 2508, 8608, 32563, 275, 359, 2623, 2209, 6172, 750, 22154, 5106, 8608, 6434, 14, 409, 3658, 4558, 8, 529, 2209, 25551, 5195, 1192, 275, 32563, 9, 2999, 489, 925, 6801, 370, 4729, 9320, 687, 314, 1654, 2508, 8608, 347, 4729, 8, 1310, 304, 8740, 340, 1228, 8, 1310, 12, 3492, 2209, 6172, 750, 2364, 304, 1675, 372, 3492, 2209, 6172, 750, 2364, 8422, 8, 1310, 9, 2999, 489, 6434, 14, 409, 3658, 4558, 8, 529, 2209, 25551, 8422, 275, 4729, 9, 10060, 257, 4907, 5035, 8, 3702, 9, 15497, 9655, 14, 1065, 342, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 202, 199, 309, 202, 199, 309, 221, 1898, 334, 35, 9, 7760, 13, 6965, 377, 1214, 500, 79, 23428, 202, 199, 309, 202, 199, 309, 221, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 202, 199, 309, 221, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 202, 199, 309, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 202, 199, 309, 202, 199, 309, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 202, 199, 309, 202, 199, 309, 221, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 202, 199, 309, 221, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 202, 199, 309, 221, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 202, 199, 309, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 202, 199, 309, 221, 4204, 1334, 314, 844, 14, 202, 199, 309, 202, 199, 11490, 2999, 199, 646, 8337, 202, 199, 504, 10933, 492, 10933, 202, 199, 504, 21471, 875, 492, 2196, 4861, 1558, 2999, 199, 504, 7390, 14, 4901, 492, 9655, 2999, 199, 504, 2599, 2470, 6164, 14, 12145, 14, 13508, 492, 18846, 30115, 12, 971, 202, 4318, 18846, 3041, 3658, 12, 971, 202, 4318, 4907, 5035, 8065, 199, 12683, 63, 4305, 275, 413, 627, 499, 538, 1165, 202, 199, 12683, 63, 8760, 275, 1616, 8065, 199, 533, 11726, 20409, 3476, 3041, 3658, 8, 18477, 3041, 3658, 304, 15497, 408, 15497, 6430, 13, 6788, 18846, 83, 1890, 626, 12821, 2547, 402, 2196, 27135, 15497, 4847, 370, 18846, 83, 1654, 465, 282, 3414, 402, 11223, 1006, 315, 1373, 1245, 14, 15497, 710, 1654, 911, 22722, 370, 2739, 543, 314, 12002, 13, 3912, 9235, 1806, 11223, 14, 15497, 3979, 781, 9128, 1177, 12, 781, 11982, 701, 10209, 282, 892, 2787, 14, 15497, 408, 10060, 257, 347, 3222, 4395, 3160, 8, 277, 304, 8608, 666, 275, 2196, 4861, 1558, 8, 12683, 63, 4305, 9, 2999, 489, 291, 14, 4835, 3912, 14, 873, 8, 576, 9, 8608, 10017, 275, 291, 14, 4835, 3912, 14, 11453, 342, 8608, 870, 480, 18541, 367, 2787, 1052, 9235, 701, 1890, 26, 8352, 908, 8, 277, 14, 835, 12, 10017, 430, 2999, 489, 291, 14, 2254, 2209, 3160, 8, 576, 9, 10060, 257, 347, 641, 4299, 8, 277, 304, 8608, 291, 14, 835, 275, 378, 8608, 291, 14, 8669, 275, 756, 8608, 291, 14, 5037, 2209, 8, 374, 6636, 275, 715, 9, 8608, 291, 14, 4835, 3912, 275, 8337, 14, 4835, 3912, 342, 8608, 291, 14, 2254, 4395, 3160, 342, 10060, 257, 347, 641, 2209, 8, 277, 12, 4886, 12, 365, 6636, 304, 8608, 870, 480, 18541, 367, 2787, 1052, 9235, 701, 1654, 26, 8352, 908, 8, 277, 14, 835, 12, 4886, 14, 2708, 360, 1624, 24, 7058, 8608, 327, 15380, 8, 277, 14, 17297, 8257, 855, 1001, 29133, 8608, 291, 14, 835, 847, 413, 2999, 489, 340, 291, 14, 835, 665, 28671, 1991, 63, 8760, 26, 8740, 291, 14, 2254, 4395, 3160, 342, 8608, 916, 440, 291, 14, 8669, 26, 8740, 291, 14, 500, 2209, 342, 8740, 291, 14, 8669, 275, 715, 2999, 489, 340, 291, 14, 835, 2356, 28671, 1991, 63, 8760, 26, 8740, 291, 14, 2254, 4724, 342, 10060, 257, 347, 641, 4724, 8, 277, 12, 1990, 6580, 12, 1233, 12, 4499, 304, 8608, 9655, 14, 2379, 342, 8065, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 10060, 257, 6434, 275, 18846, 30115, 480, 3569, 921, 5967, 26, 25, 1493, 531, 15497, 6434, 14, 3922, 275, 11726, 20409, 3476, 3041, 3658, 10060, 257, 4756, 25551, 275, 756, 15497, 340, 4756, 25551, 26, 8608, 687, 2599, 2470, 6164, 14, 13508, 14, 6447, 492, 3492, 2209, 6172, 750, 22154, 12, 971, 202, 6343, 3492, 2209, 6172, 750, 2364, 12, 971, 202, 6343, 3492, 2209, 6172, 750, 2364, 8422, 2999, 489, 925, 710, 5478, 402, 22941, 370, 314, 1654, 2508, 8608, 32563, 275, 359, 2623, 2209, 6172, 750, 22154, 5106, 8608, 6434, 14, 409, 3658, 4558, 8, 529, 2209, 25551, 5195, 1192, 275, 32563, 9, 2999, 489, 925, 6801, 370, 4729, 9320, 687, 314, 1654, 2508, 8608, 347, 4729, 8, 1310, 304, 8740, 340, 1228, 8, 1310, 12, 3492, 2209, 6172, 750, 2364, 304, 1675, 372, 3492, 2209, 6172, 750, 2364, 8422, 8, 1310, 9, 2999, 489, 6434, 14, 409, 3658, 4558, 8, 529, 2209, 25551, 8422, 275, 4729, 9, 10060, 257, 4907, 5035, 8, 3702, 9, 15497, 9655, 14, 1065, 342, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
M4sse/chromium.src
tools/memory_inspector/memory_inspector/classification/rules.py
109
5039
# 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. """This module defines the core structure of the classification rules. This module does NOT specify how the rules filter the data: this responsibility is of to the concrete classifiers, which have to override the Rule class herein defined and know how to do the math. This module, instead, defines the format of the rules and the way they are encoded and loaded (in a python-style dictionary file). Rules are organized in a tree, where the root is always represented by a 'Total' node, and the leaves are arbitrarily defined by the user, according to the following principles: - Order of siblings rules matter: what is caught by a rule will not be caught by the next ones, but it is propagated to its children rules if any. - Every non-leaf node X gets an implicit extra-children named X-other. This catch-all child catches everything (within the parent rule scope) that is not caught by the other siblings. This is to guarantee that, when doing the math (the aggregation), at any level, the sum of the values in the leaves match the value of their parent. The format of a rule dictionary is the following: [ { 'name': 'Name of the rule', 'filter-X': 'The embedder will know how to interpret this value and will use it to filter the data' 'filter-Y': 'Idem' children: [ { 'name': 'Name of the sub-rule 1' ... and so on recursively , }, ] }, ] And a typical resulting rule tree looks like this: +----------------------+ | Total | |----------------------| +------------------+ Match all. +--------------------+ | +----------+-----------+ | | | | +-----v-----+ +-----v-----+ +------v----+ | Foo | | Bar | |Total-other| |-----------| |-----------| |-----------| |File: foo* | +---+File: bar* +-----+ | Match all | +-----------+ | +-----------+ | +-----------+ | | +------v------+ +------v----+ | Bar::Coffee | | Bar-other | |-------------| |-----------| |File: bar*cof| | Match all | +-------------+ +-----------+ """ import ast def Load(content, rule_builder): """Construct a rule tree from a python-style dict representation. Args: content: a string containing the dict (i.e. content of the rule file). rule_builder: a method which takes two arguments (rule_name, filters_dict) and returns a subclass of |Rule|. |filters_dict| is a dict of the keys (filter-foo, filter-bar in the example above) for the rule node. """ rules_dict = ast.literal_eval(content) root = Rule('Total') _MakeRuleNodeFromDictNode(root, rules_dict, rule_builder) return root class Rule(object): """ An abstract class representing a rule node in the rules tree. Embedders must override the Match method when deriving this class. """ def __init__(self, name): self.name = name self.children = [] def Match(self, _): # pylint: disable=R0201 """ The rationale of this default implementation is modeling the root ('Total') and the catch-all (*-other) rules that every |RuleTree| must have, regardless of the embedder-specific children rules. This is to guarantee that the totals match at any level of the tree. """ return True def AppendChild(self, child_rule): assert(isinstance(child_rule, Rule)) duplicates = filter(lambda x: x.name == child_rule.name, self.children) assert(not duplicates), 'Duplicate rule ' + child_rule.name self.children.append(child_rule) def _MakeRuleNodeFromDictNode(rule_node, dict_nodes, rule_builder): """Recursive rule tree builder for traversing the rule dict.""" for dict_node in dict_nodes: assert('name' in dict_node) # Extract the filter keys (e.g., mmap-file, mmap-prot) that will be passed # to the |rule_builder| filter_keys = set(dict_node.keys()) - set(('name', 'children')) filters = dict((k, dict_node[k]) for k in filter_keys) child_rule = rule_builder(dict_node['name'], filters) rule_node.AppendChild(child_rule) dict_children = dict_node.get('children', {}) _MakeRuleNodeFromDictNode(child_rule, dict_children, rule_builder) # If the rule_node isn't a leaf, add the 'name-other' catch-all sibling to # catch all the entries that matched this node but none of its children. if len(rule_node.children): rule_node.AppendChild(Rule(rule_node.name + '-other'))
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, 2765, 859, 7890, 314, 6170, 5523, 402, 314, 12505, 4713, 14, 199, 199, 2765, 859, 1630, 2845, 4165, 4212, 314, 4713, 2457, 314, 666, 26, 642, 9163, 4783, 199, 374, 402, 370, 314, 13801, 19137, 12, 1314, 1172, 370, 4278, 314, 11949, 1021, 2348, 262, 199, 4037, 436, 5715, 4212, 370, 886, 314, 3473, 14, 199, 199, 2765, 859, 12, 3140, 12, 7890, 314, 1475, 402, 314, 4713, 436, 314, 4340, 2985, 787, 199, 8167, 436, 6511, 334, 262, 282, 2366, 13, 2487, 2600, 570, 680, 199, 12920, 787, 20765, 1759, 315, 282, 3123, 12, 2382, 314, 1738, 365, 3544, 11159, 701, 282, 283, 7316, 7, 199, 932, 12, 436, 314, 16733, 787, 601, 2075, 82, 11406, 3247, 701, 314, 922, 12, 7182, 370, 314, 199, 21589, 5448, 10352, 2978, 26, 199, 13, 9240, 402, 31871, 4713, 17247, 26, 4052, 365, 15604, 701, 282, 2332, 911, 440, 506, 15604, 523, 701, 314, 2163, 7869, 12, 1325, 652, 365, 25350, 370, 2399, 4978, 4713, 340, 1263, 14, 199, 13, 18414, 2222, 13, 8914, 1031, 1323, 7545, 376, 9227, 2402, 13, 3223, 4310, 1323, 13, 1848, 14, 961, 523, 8579, 13, 452, 1982, 8579, 397, 8137, 334, 12541, 314, 1676, 2332, 4194, 9, 626, 365, 523, 440, 15604, 701, 314, 1163, 31871, 14, 961, 365, 370, 24197, 626, 12, 1380, 9689, 314, 523, 3473, 334, 1589, 18384, 395, 737, 1263, 2166, 12, 314, 3089, 402, 314, 1338, 315, 314, 16733, 523, 1336, 314, 574, 402, 3932, 1676, 14, 199, 199, 1918, 1475, 402, 282, 2332, 2600, 365, 314, 2569, 26, 199, 59, 199, 91, 523, 283, 354, 356, 755, 283, 985, 402, 314, 2332, 297, 523, 283, 1541, 13, 56, 356, 257, 283, 1918, 6441, 424, 911, 5715, 4212, 370, 15579, 642, 574, 436, 911, 675, 326, 652, 370, 2457, 314, 666, 7, 523, 283, 1541, 13, 57, 356, 257, 283, 41, 23522, 7, 523, 4978, 26, 359, 272, 469, 489, 283, 354, 356, 257, 283, 985, 402, 314, 1007, 13, 2200, 413, 7, 489, 2263, 436, 880, 641, 15035, 2360, 272, 1660, 523, 1622, 199, 1386, 199, 61, 199, 199, 3325, 282, 25780, 9183, 2332, 3123, 10734, 2839, 642, 26, 2079, 24680, 28712, 2079, 1204, 263, 19271, 260, 1204, 2079, 1204, 777, 8648, 92, 2126, 24680, 12557, 420, 9814, 1006, 14, 420, 24680, 32752, 2126, 1204, 8295, 435, 30978, 27592, 8540, 1204, 2126, 1204, 17907, 1204, 13293, 1204, 199, 435, 9858, 86, 28699, 463, 435, 9858, 86, 28699, 7861, 435, 8648, 86, 32752, 199, 1204, 259, 8024, 259, 1204, 463, 1204, 259, 12377, 259, 1204, 7861, 1204, 7316, 13, 1848, 92, 199, 1204, 13715, 92, 463, 1204, 13715, 92, 7861, 1204, 13715, 92, 199, 1204, 1173, 26, 3925, 10, 1204, 3777, 435, 9018, 1173, 26, 4681, 10, 435, 28699, 3777, 1204, 9814, 1006, 1204, 199, 435, 27592, 3777, 1204, 257, 435, 27592, 258, 1204, 3777, 435, 27592, 2574, 1204, 9326, 1204, 490, 435, 8648, 86, 28712, 755, 435, 8648, 86, 32752, 490, 1204, 12377, 447, 967, 24715, 1204, 755, 1204, 12377, 13, 1848, 1204, 490, 1204, 8684, 92, 755, 1204, 13715, 92, 490, 1204, 1173, 26, 4681, 10, 331, 70, 92, 755, 1204, 9814, 1006, 1204, 490, 435, 4559, 6793, 755, 435, 27592, 199, 624, 199, 199, 646, 6073, 421, 199, 318, 7190, 8, 1317, 12, 2332, 63, 5649, 304, 523, 408, 11493, 282, 2332, 3123, 687, 282, 2366, 13, 2487, 1211, 6025, 14, 819, 3033, 26, 272, 1564, 26, 282, 1059, 3035, 314, 1211, 334, 73, 14, 69, 14, 1564, 402, 314, 2332, 570, 680, 272, 2332, 63, 5649, 26, 282, 1083, 1314, 6181, 2877, 2368, 334, 2200, 63, 354, 12, 4766, 63, 807, 9, 267, 436, 2529, 282, 5516, 402, 1204, 5065, 18257, 1204, 4273, 63, 807, 92, 365, 282, 1211, 402, 314, 2883, 267, 334, 1541, 13, 1421, 12, 2457, 13, 1700, 315, 314, 2893, 3432, 9, 367, 314, 2332, 1031, 14, 523, 408, 523, 4713, 63, 807, 275, 6073, 14, 8939, 63, 2579, 8, 1317, 9, 523, 1738, 275, 11949, 360, 7316, 358, 523, 485, 5483, 5065, 1716, 2532, 2141, 1716, 8, 1231, 12, 4713, 63, 807, 12, 2332, 63, 5649, 9, 523, 372, 1738, 421, 199, 533, 11949, 8, 785, 304, 523, 408, 1626, 9006, 1021, 6144, 282, 2332, 1031, 315, 314, 4713, 3123, 14, 819, 24297, 7735, 1471, 4278, 314, 9814, 1083, 1380, 5405, 4007, 642, 1021, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 536, 304, 272, 291, 14, 354, 275, 536, 272, 291, 14, 3223, 275, 942, 819, 347, 9814, 8, 277, 12, 27574, 221, 327, 4287, 26, 3507, 29, 50, 996, 614, 272, 408, 710, 660, 296, 1895, 402, 642, 849, 4514, 365, 1402, 316, 314, 1738, 272, 661, 7316, 358, 436, 314, 8579, 13, 452, 334, 1837, 1848, 9, 4713, 626, 4036, 1204, 5065, 3987, 92, 1471, 1172, 12, 272, 15270, 402, 314, 6441, 424, 13, 6100, 4978, 4713, 14, 961, 365, 370, 24197, 272, 626, 314, 23576, 1336, 737, 1263, 2166, 402, 314, 3123, 14, 272, 408, 272, 372, 715, 819, 347, 18726, 3493, 8, 277, 12, 1982, 63, 2200, 304, 272, 702, 8, 6074, 8, 1739, 63, 2200, 12, 11949, 430, 272, 15755, 275, 2457, 8, 2734, 671, 26, 671, 14, 354, 508, 1982, 63, 2200, 14, 354, 12, 291, 14, 3223, 9, 272, 702, 8, 1397, 15755, 395, 283, 14773, 2332, 283, 435, 1982, 63, 2200, 14, 354, 272, 291, 14, 3223, 14, 740, 8, 1739, 63, 2200, 9, 421, 199, 318, 485, 5483, 5065, 1716, 2532, 2141, 1716, 8, 2200, 63, 932, 12, 1211, 63, 2415, 12, 2332, 63, 5649, 304, 523, 408, 25122, 2332, 3123, 6545, 367, 1468, 422, 1044, 314, 2332, 1211, 1041, 523, 367, 1211, 63, 932, 315, 1211, 63, 2415, 26, 272, 702, 360, 354, 7, 315, 1211, 63, 932, 9, 272, 327, 12892, 314, 2457, 2883, 334, 69, 14, 71, 2020, 21991, 13, 493, 12, 21991, 13, 2745, 9, 626, 911, 506, 3032, 272 ]
[ 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, 2765, 859, 7890, 314, 6170, 5523, 402, 314, 12505, 4713, 14, 199, 199, 2765, 859, 1630, 2845, 4165, 4212, 314, 4713, 2457, 314, 666, 26, 642, 9163, 4783, 199, 374, 402, 370, 314, 13801, 19137, 12, 1314, 1172, 370, 4278, 314, 11949, 1021, 2348, 262, 199, 4037, 436, 5715, 4212, 370, 886, 314, 3473, 14, 199, 199, 2765, 859, 12, 3140, 12, 7890, 314, 1475, 402, 314, 4713, 436, 314, 4340, 2985, 787, 199, 8167, 436, 6511, 334, 262, 282, 2366, 13, 2487, 2600, 570, 680, 199, 12920, 787, 20765, 1759, 315, 282, 3123, 12, 2382, 314, 1738, 365, 3544, 11159, 701, 282, 283, 7316, 7, 199, 932, 12, 436, 314, 16733, 787, 601, 2075, 82, 11406, 3247, 701, 314, 922, 12, 7182, 370, 314, 199, 21589, 5448, 10352, 2978, 26, 199, 13, 9240, 402, 31871, 4713, 17247, 26, 4052, 365, 15604, 701, 282, 2332, 911, 440, 506, 15604, 523, 701, 314, 2163, 7869, 12, 1325, 652, 365, 25350, 370, 2399, 4978, 4713, 340, 1263, 14, 199, 13, 18414, 2222, 13, 8914, 1031, 1323, 7545, 376, 9227, 2402, 13, 3223, 4310, 1323, 13, 1848, 14, 961, 523, 8579, 13, 452, 1982, 8579, 397, 8137, 334, 12541, 314, 1676, 2332, 4194, 9, 626, 365, 523, 440, 15604, 701, 314, 1163, 31871, 14, 961, 365, 370, 24197, 626, 12, 1380, 9689, 314, 523, 3473, 334, 1589, 18384, 395, 737, 1263, 2166, 12, 314, 3089, 402, 314, 1338, 315, 314, 16733, 523, 1336, 314, 574, 402, 3932, 1676, 14, 199, 199, 1918, 1475, 402, 282, 2332, 2600, 365, 314, 2569, 26, 199, 59, 199, 91, 523, 283, 354, 356, 755, 283, 985, 402, 314, 2332, 297, 523, 283, 1541, 13, 56, 356, 257, 283, 1918, 6441, 424, 911, 5715, 4212, 370, 15579, 642, 574, 436, 911, 675, 326, 652, 370, 2457, 314, 666, 7, 523, 283, 1541, 13, 57, 356, 257, 283, 41, 23522, 7, 523, 4978, 26, 359, 272, 469, 489, 283, 354, 356, 257, 283, 985, 402, 314, 1007, 13, 2200, 413, 7, 489, 2263, 436, 880, 641, 15035, 2360, 272, 1660, 523, 1622, 199, 1386, 199, 61, 199, 199, 3325, 282, 25780, 9183, 2332, 3123, 10734, 2839, 642, 26, 2079, 24680, 28712, 2079, 1204, 263, 19271, 260, 1204, 2079, 1204, 777, 8648, 92, 2126, 24680, 12557, 420, 9814, 1006, 14, 420, 24680, 32752, 2126, 1204, 8295, 435, 30978, 27592, 8540, 1204, 2126, 1204, 17907, 1204, 13293, 1204, 199, 435, 9858, 86, 28699, 463, 435, 9858, 86, 28699, 7861, 435, 8648, 86, 32752, 199, 1204, 259, 8024, 259, 1204, 463, 1204, 259, 12377, 259, 1204, 7861, 1204, 7316, 13, 1848, 92, 199, 1204, 13715, 92, 463, 1204, 13715, 92, 7861, 1204, 13715, 92, 199, 1204, 1173, 26, 3925, 10, 1204, 3777, 435, 9018, 1173, 26, 4681, 10, 435, 28699, 3777, 1204, 9814, 1006, 1204, 199, 435, 27592, 3777, 1204, 257, 435, 27592, 258, 1204, 3777, 435, 27592, 2574, 1204, 9326, 1204, 490, 435, 8648, 86, 28712, 755, 435, 8648, 86, 32752, 490, 1204, 12377, 447, 967, 24715, 1204, 755, 1204, 12377, 13, 1848, 1204, 490, 1204, 8684, 92, 755, 1204, 13715, 92, 490, 1204, 1173, 26, 4681, 10, 331, 70, 92, 755, 1204, 9814, 1006, 1204, 490, 435, 4559, 6793, 755, 435, 27592, 199, 624, 199, 199, 646, 6073, 421, 199, 318, 7190, 8, 1317, 12, 2332, 63, 5649, 304, 523, 408, 11493, 282, 2332, 3123, 687, 282, 2366, 13, 2487, 1211, 6025, 14, 819, 3033, 26, 272, 1564, 26, 282, 1059, 3035, 314, 1211, 334, 73, 14, 69, 14, 1564, 402, 314, 2332, 570, 680, 272, 2332, 63, 5649, 26, 282, 1083, 1314, 6181, 2877, 2368, 334, 2200, 63, 354, 12, 4766, 63, 807, 9, 267, 436, 2529, 282, 5516, 402, 1204, 5065, 18257, 1204, 4273, 63, 807, 92, 365, 282, 1211, 402, 314, 2883, 267, 334, 1541, 13, 1421, 12, 2457, 13, 1700, 315, 314, 2893, 3432, 9, 367, 314, 2332, 1031, 14, 523, 408, 523, 4713, 63, 807, 275, 6073, 14, 8939, 63, 2579, 8, 1317, 9, 523, 1738, 275, 11949, 360, 7316, 358, 523, 485, 5483, 5065, 1716, 2532, 2141, 1716, 8, 1231, 12, 4713, 63, 807, 12, 2332, 63, 5649, 9, 523, 372, 1738, 421, 199, 533, 11949, 8, 785, 304, 523, 408, 1626, 9006, 1021, 6144, 282, 2332, 1031, 315, 314, 4713, 3123, 14, 819, 24297, 7735, 1471, 4278, 314, 9814, 1083, 1380, 5405, 4007, 642, 1021, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 536, 304, 272, 291, 14, 354, 275, 536, 272, 291, 14, 3223, 275, 942, 819, 347, 9814, 8, 277, 12, 27574, 221, 327, 4287, 26, 3507, 29, 50, 996, 614, 272, 408, 710, 660, 296, 1895, 402, 642, 849, 4514, 365, 1402, 316, 314, 1738, 272, 661, 7316, 358, 436, 314, 8579, 13, 452, 334, 1837, 1848, 9, 4713, 626, 4036, 1204, 5065, 3987, 92, 1471, 1172, 12, 272, 15270, 402, 314, 6441, 424, 13, 6100, 4978, 4713, 14, 961, 365, 370, 24197, 272, 626, 314, 23576, 1336, 737, 1263, 2166, 402, 314, 3123, 14, 272, 408, 272, 372, 715, 819, 347, 18726, 3493, 8, 277, 12, 1982, 63, 2200, 304, 272, 702, 8, 6074, 8, 1739, 63, 2200, 12, 11949, 430, 272, 15755, 275, 2457, 8, 2734, 671, 26, 671, 14, 354, 508, 1982, 63, 2200, 14, 354, 12, 291, 14, 3223, 9, 272, 702, 8, 1397, 15755, 395, 283, 14773, 2332, 283, 435, 1982, 63, 2200, 14, 354, 272, 291, 14, 3223, 14, 740, 8, 1739, 63, 2200, 9, 421, 199, 318, 485, 5483, 5065, 1716, 2532, 2141, 1716, 8, 2200, 63, 932, 12, 1211, 63, 2415, 12, 2332, 63, 5649, 304, 523, 408, 25122, 2332, 3123, 6545, 367, 1468, 422, 1044, 314, 2332, 1211, 1041, 523, 367, 1211, 63, 932, 315, 1211, 63, 2415, 26, 272, 702, 360, 354, 7, 315, 1211, 63, 932, 9, 272, 327, 12892, 314, 2457, 2883, 334, 69, 14, 71, 2020, 21991, 13, 493, 12, 21991, 13, 2745, 9, 626, 911, 506, 3032, 272, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
junmin-kim/TizenRT
external/gmock/gtest/scripts/fuse_gtest_files.py
2577
8813
#!/usr/bin/env python # # Copyright 2009, 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. """fuse_gtest_files.py v0.2.0 Fuses Google Test source code into a .h file and a .cc file. SYNOPSIS fuse_gtest_files.py [GTEST_ROOT_DIR] OUTPUT_DIR Scans GTEST_ROOT_DIR for Google Test source code, and generates two files: OUTPUT_DIR/gtest/gtest.h and OUTPUT_DIR/gtest/gtest-all.cc. Then you can build your tests by adding OUTPUT_DIR to the include search path and linking with OUTPUT_DIR/gtest/gtest-all.cc. These two files contain everything you need to use Google Test. Hence you can "install" Google Test by copying them to wherever you want. GTEST_ROOT_DIR can be omitted and defaults to the parent directory of the directory holding this script. EXAMPLES ./fuse_gtest_files.py fused_gtest ./fuse_gtest_files.py path/to/unpacked/gtest fused_gtest This tool is experimental. In particular, it assumes that there is no conditional inclusion of Google Test headers. Please report any problems to googletestframework@googlegroups.com. You can read http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide for more information. """ __author__ = 'wan@google.com (Zhanyong Wan)' import os import re import sets import sys # We assume that this file is in the scripts/ directory in the Google # Test root directory. DEFAULT_GTEST_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..') # Regex for matching '#include "gtest/..."'. INCLUDE_GTEST_FILE_REGEX = re.compile(r'^\s*#\s*include\s*"(gtest/.+)"') # Regex for matching '#include "src/..."'. INCLUDE_SRC_FILE_REGEX = re.compile(r'^\s*#\s*include\s*"(src/.+)"') # Where to find the source seed files. GTEST_H_SEED = 'include/gtest/gtest.h' GTEST_SPI_H_SEED = 'include/gtest/gtest-spi.h' GTEST_ALL_CC_SEED = 'src/gtest-all.cc' # Where to put the generated files. GTEST_H_OUTPUT = 'gtest/gtest.h' GTEST_ALL_CC_OUTPUT = 'gtest/gtest-all.cc' def VerifyFileExists(directory, relative_path): """Verifies that the given file exists; aborts on failure. relative_path is the file path relative to the given directory. """ if not os.path.isfile(os.path.join(directory, relative_path)): print 'ERROR: Cannot find %s in directory %s.' % (relative_path, directory) print ('Please either specify a valid project root directory ' 'or omit it on the command line.') sys.exit(1) def ValidateGTestRootDir(gtest_root): """Makes sure gtest_root points to a valid gtest root directory. The function aborts the program on failure. """ VerifyFileExists(gtest_root, GTEST_H_SEED) VerifyFileExists(gtest_root, GTEST_ALL_CC_SEED) def VerifyOutputFile(output_dir, relative_path): """Verifies that the given output file path is valid. relative_path is relative to the output_dir directory. """ # Makes sure the output file either doesn't exist or can be overwritten. output_file = os.path.join(output_dir, relative_path) if os.path.exists(output_file): # TODO(wan@google.com): The following user-interaction doesn't # work with automated processes. We should provide a way for the # Makefile to force overwriting the files. print ('%s already exists in directory %s - overwrite it? (y/N) ' % (relative_path, output_dir)) answer = sys.stdin.readline().strip() if answer not in ['y', 'Y']: print 'ABORTED.' sys.exit(1) # Makes sure the directory holding the output file exists; creates # it and all its ancestors if necessary. parent_directory = os.path.dirname(output_file) if not os.path.isdir(parent_directory): os.makedirs(parent_directory) def ValidateOutputDir(output_dir): """Makes sure output_dir points to a valid output directory. The function aborts the program on failure. """ VerifyOutputFile(output_dir, GTEST_H_OUTPUT) VerifyOutputFile(output_dir, GTEST_ALL_CC_OUTPUT) def FuseGTestH(gtest_root, output_dir): """Scans folder gtest_root to generate gtest/gtest.h in output_dir.""" output_file = file(os.path.join(output_dir, GTEST_H_OUTPUT), 'w') processed_files = sets.Set() # Holds all gtest headers we've processed. def ProcessFile(gtest_header_path): """Processes the given gtest header file.""" # We don't process the same header twice. if gtest_header_path in processed_files: return processed_files.add(gtest_header_path) # Reads each line in the given gtest header. for line in file(os.path.join(gtest_root, gtest_header_path), 'r'): m = INCLUDE_GTEST_FILE_REGEX.match(line) if m: # It's '#include "gtest/..."' - let's process it recursively. ProcessFile('include/' + m.group(1)) else: # Otherwise we copy the line unchanged to the output file. output_file.write(line) ProcessFile(GTEST_H_SEED) output_file.close() def FuseGTestAllCcToFile(gtest_root, output_file): """Scans folder gtest_root to generate gtest/gtest-all.cc in output_file.""" processed_files = sets.Set() def ProcessFile(gtest_source_file): """Processes the given gtest source file.""" # We don't process the same #included file twice. if gtest_source_file in processed_files: return processed_files.add(gtest_source_file) # Reads each line in the given gtest source file. for line in file(os.path.join(gtest_root, gtest_source_file), 'r'): m = INCLUDE_GTEST_FILE_REGEX.match(line) if m: if 'include/' + m.group(1) == GTEST_SPI_H_SEED: # It's '#include "gtest/gtest-spi.h"'. This file is not # #included by "gtest/gtest.h", so we need to process it. ProcessFile(GTEST_SPI_H_SEED) else: # It's '#include "gtest/foo.h"' where foo is not gtest-spi. # We treat it as '#include "gtest/gtest.h"', as all other # gtest headers are being fused into gtest.h and cannot be # #included directly. # There is no need to #include "gtest/gtest.h" more than once. if not GTEST_H_SEED in processed_files: processed_files.add(GTEST_H_SEED) output_file.write('#include "%s"\n' % (GTEST_H_OUTPUT,)) else: m = INCLUDE_SRC_FILE_REGEX.match(line) if m: # It's '#include "src/foo"' - let's process it recursively. ProcessFile(m.group(1)) else: output_file.write(line) ProcessFile(GTEST_ALL_CC_SEED) def FuseGTestAllCc(gtest_root, output_dir): """Scans folder gtest_root to generate gtest/gtest-all.cc in output_dir.""" output_file = file(os.path.join(output_dir, GTEST_ALL_CC_OUTPUT), 'w') FuseGTestAllCcToFile(gtest_root, output_file) output_file.close() def FuseGTest(gtest_root, output_dir): """Fuses gtest.h and gtest-all.cc.""" ValidateGTestRootDir(gtest_root) ValidateOutputDir(output_dir) FuseGTestH(gtest_root, output_dir) FuseGTestAllCc(gtest_root, output_dir) def main(): argc = len(sys.argv) if argc == 2: # fuse_gtest_files.py OUTPUT_DIR FuseGTest(DEFAULT_GTEST_ROOT_DIR, sys.argv[1]) elif argc == 3: # fuse_gtest_files.py GTEST_ROOT_DIR OUTPUT_DIR FuseGTest(sys.argv[1], sys.argv[2]) else: print __doc__ sys.exit(1) if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 8937, 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, 199, 199, 624, 70, 1180, 63, 8385, 63, 1725, 14, 647, 373, 16, 14, 18, 14, 16, 199, 38, 5589, 4475, 1379, 1350, 1233, 1901, 282, 1275, 72, 570, 436, 282, 1275, 2055, 570, 14, 199, 199, 31802, 21665, 1311, 2126, 289, 1180, 63, 8385, 63, 1725, 14, 647, 359, 16151, 63, 5441, 63, 3022, 61, 18746, 63, 3022, 10817, 13916, 796, 18652, 63, 5441, 63, 3022, 367, 4475, 1379, 1350, 1233, 12, 436, 12821, 2126, 2877, 1584, 26, 18746, 63, 3022, 15, 8385, 15, 8385, 14, 72, 436, 18746, 63, 3022, 15, 8385, 15, 8385, 13, 452, 14, 2055, 14, 2126, 9442, 1265, 883, 1900, 2195, 2295, 701, 7791, 18746, 63, 3022, 370, 314, 2387, 2126, 2754, 931, 436, 25833, 543, 18746, 63, 3022, 15, 8385, 15, 8385, 13, 452, 14, 2055, 14, 221, 5723, 2126, 2877, 1584, 1395, 8137, 1265, 1929, 370, 675, 4475, 1379, 14, 221, 869, 4894, 2126, 1265, 883, 298, 3174, 2, 4475, 1379, 701, 16743, 3062, 370, 2382, 422, 1265, 2934, 14, 10817, 18652, 63, 5441, 63, 3022, 883, 506, 11684, 436, 4243, 370, 314, 1676, 2126, 2082, 402, 314, 2082, 17573, 642, 2884, 14, 199, 199, 8918, 2126, 16605, 70, 1180, 63, 8385, 63, 1725, 14, 647, 28580, 63, 8385, 2126, 16605, 70, 1180, 63, 8385, 63, 1725, 14, 647, 931, 15, 475, 15, 24497, 15, 8385, 28580, 63, 8385, 199, 199, 2765, 4744, 365, 22820, 14, 221, 1010, 6770, 12, 652, 15194, 626, 2337, 365, 949, 199, 14353, 20396, 402, 4475, 1379, 2323, 14, 221, 7754, 3622, 1263, 199, 22959, 370, 31141, 4857, 32, 3098, 2634, 14, 957, 14, 221, 2047, 883, 1586, 199, 1014, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 3098, 396, 15, 6797, 15, 13266, 774, 23613, 4324, 271, 367, 199, 6878, 2556, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 295, 199, 646, 5951, 199, 646, 984, 199, 199, 3, 2136, 5534, 626, 642, 570, 365, 315, 314, 10554, 15, 2082, 315, 314, 4475, 199, 3, 1379, 1738, 2082, 14, 199, 3472, 63, 16151, 63, 5441, 63, 3022, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 11541, 358, 199, 199, 3, 12939, 367, 4877, 3943, 2613, 298, 8385, 15, 11500, 1370, 199, 18171, 63, 16151, 63, 3817, 63, 10710, 275, 295, 14, 2014, 8, 82, 15542, 83, 10, 20262, 83, 10, 2613, 60, 83, 12469, 8, 8385, 15, 6977, 2924, 358, 199, 199, 3, 12939, 367, 4877, 3943, 2613, 298, 2164, 15, 11500, 1370, 199, 18171, 63, 12447, 63, 3817, 63, 10710, 275, 295, 14, 2014, 8, 82, 15542, 83, 10, 20262, 83, 10, 2613, 60, 83, 12469, 8, 2164, 15, 6977, 2924, 358, 199, 199, 3, 17685, 370, 2342, 314, 1350, 6347, 1584, 14, 199, 16151, 63, 40, 63, 25508, 275, 283, 2613, 15, 8385, 15, 8385, 14, 72, 7, 199, 16151, 63, 20495, 63, 40, 63, 25508, 275, 283, 2613, 15, 8385, 15, 8385, 13, 8721, 14, 72, 7, 199, 16151, 63, 1761, 63, 2571, 63, 25508, 275, 283, 2164, 15, 8385, 13, 452, 14, 2055, 7, 199, 199, 3, 17685, 370, 5324, 314, 4046, 1584, 14, 199, 16151, 63, 40, 63, 8414, 275, 283, 8385, 15, 8385, 14, 72, 7, 199, 16151, 63, 1761, 63, 2571, 63, 8414, 275, 283, 8385, 15, 8385, 13, 452, 14, 2055, 7, 421, 199, 318, 7635, 1173, 7965, 8, 3619, 12, 3847, 63, 515, 304, 523, 408, 21168, 626, 314, 1627, 570, 3495, 27, 12004, 83, 641, 5988, 14, 819, 3847, 63, 515, 365, 314, 570, 931, 3847, 370, 314, 1627, 2082, 14, 523, 408, 819, 340, 440, 747, 14, 515, 14, 6292, 8, 736, 14, 515, 14, 904, 8, 3619, 12, 3847, 63, 515, 2298, 272, 870, 283, 3170, 26, 18435, 2342, 450, 83, 315, 2082, 450, 83, 3530, 450, 334, 6188, 63, 515, 12, 10028, 2082, 9, 272, 870, 661, 8254, 1902, 4165, 282, 1686, 2199, 1738, 2082, 283, 1779, 283, 269, 19413, 652, 641, 314, 1414, 1004, 2659, 272, 984, 14, 2224, 8, 17, 9, 421, 199, 318, 12134, 39, 774 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 8937, 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, 199, 199, 624, 70, 1180, 63, 8385, 63, 1725, 14, 647, 373, 16, 14, 18, 14, 16, 199, 38, 5589, 4475, 1379, 1350, 1233, 1901, 282, 1275, 72, 570, 436, 282, 1275, 2055, 570, 14, 199, 199, 31802, 21665, 1311, 2126, 289, 1180, 63, 8385, 63, 1725, 14, 647, 359, 16151, 63, 5441, 63, 3022, 61, 18746, 63, 3022, 10817, 13916, 796, 18652, 63, 5441, 63, 3022, 367, 4475, 1379, 1350, 1233, 12, 436, 12821, 2126, 2877, 1584, 26, 18746, 63, 3022, 15, 8385, 15, 8385, 14, 72, 436, 18746, 63, 3022, 15, 8385, 15, 8385, 13, 452, 14, 2055, 14, 2126, 9442, 1265, 883, 1900, 2195, 2295, 701, 7791, 18746, 63, 3022, 370, 314, 2387, 2126, 2754, 931, 436, 25833, 543, 18746, 63, 3022, 15, 8385, 15, 8385, 13, 452, 14, 2055, 14, 221, 5723, 2126, 2877, 1584, 1395, 8137, 1265, 1929, 370, 675, 4475, 1379, 14, 221, 869, 4894, 2126, 1265, 883, 298, 3174, 2, 4475, 1379, 701, 16743, 3062, 370, 2382, 422, 1265, 2934, 14, 10817, 18652, 63, 5441, 63, 3022, 883, 506, 11684, 436, 4243, 370, 314, 1676, 2126, 2082, 402, 314, 2082, 17573, 642, 2884, 14, 199, 199, 8918, 2126, 16605, 70, 1180, 63, 8385, 63, 1725, 14, 647, 28580, 63, 8385, 2126, 16605, 70, 1180, 63, 8385, 63, 1725, 14, 647, 931, 15, 475, 15, 24497, 15, 8385, 28580, 63, 8385, 199, 199, 2765, 4744, 365, 22820, 14, 221, 1010, 6770, 12, 652, 15194, 626, 2337, 365, 949, 199, 14353, 20396, 402, 4475, 1379, 2323, 14, 221, 7754, 3622, 1263, 199, 22959, 370, 31141, 4857, 32, 3098, 2634, 14, 957, 14, 221, 2047, 883, 1586, 199, 1014, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 3098, 396, 15, 6797, 15, 13266, 774, 23613, 4324, 271, 367, 199, 6878, 2556, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 295, 199, 646, 5951, 199, 646, 984, 199, 199, 3, 2136, 5534, 626, 642, 570, 365, 315, 314, 10554, 15, 2082, 315, 314, 4475, 199, 3, 1379, 1738, 2082, 14, 199, 3472, 63, 16151, 63, 5441, 63, 3022, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 11541, 358, 199, 199, 3, 12939, 367, 4877, 3943, 2613, 298, 8385, 15, 11500, 1370, 199, 18171, 63, 16151, 63, 3817, 63, 10710, 275, 295, 14, 2014, 8, 82, 15542, 83, 10, 20262, 83, 10, 2613, 60, 83, 12469, 8, 8385, 15, 6977, 2924, 358, 199, 199, 3, 12939, 367, 4877, 3943, 2613, 298, 2164, 15, 11500, 1370, 199, 18171, 63, 12447, 63, 3817, 63, 10710, 275, 295, 14, 2014, 8, 82, 15542, 83, 10, 20262, 83, 10, 2613, 60, 83, 12469, 8, 2164, 15, 6977, 2924, 358, 199, 199, 3, 17685, 370, 2342, 314, 1350, 6347, 1584, 14, 199, 16151, 63, 40, 63, 25508, 275, 283, 2613, 15, 8385, 15, 8385, 14, 72, 7, 199, 16151, 63, 20495, 63, 40, 63, 25508, 275, 283, 2613, 15, 8385, 15, 8385, 13, 8721, 14, 72, 7, 199, 16151, 63, 1761, 63, 2571, 63, 25508, 275, 283, 2164, 15, 8385, 13, 452, 14, 2055, 7, 199, 199, 3, 17685, 370, 5324, 314, 4046, 1584, 14, 199, 16151, 63, 40, 63, 8414, 275, 283, 8385, 15, 8385, 14, 72, 7, 199, 16151, 63, 1761, 63, 2571, 63, 8414, 275, 283, 8385, 15, 8385, 13, 452, 14, 2055, 7, 421, 199, 318, 7635, 1173, 7965, 8, 3619, 12, 3847, 63, 515, 304, 523, 408, 21168, 626, 314, 1627, 570, 3495, 27, 12004, 83, 641, 5988, 14, 819, 3847, 63, 515, 365, 314, 570, 931, 3847, 370, 314, 1627, 2082, 14, 523, 408, 819, 340, 440, 747, 14, 515, 14, 6292, 8, 736, 14, 515, 14, 904, 8, 3619, 12, 3847, 63, 515, 2298, 272, 870, 283, 3170, 26, 18435, 2342, 450, 83, 315, 2082, 450, 83, 3530, 450, 334, 6188, 63, 515, 12, 10028, 2082, 9, 272, 870, 661, 8254, 1902, 4165, 282, 1686, 2199, 1738, 2082, 283, 1779, 283, 269, 19413, 652, 641, 314, 1414, 1004, 2659, 272, 984, 14, 2224, 8, 17, 9, 421, 199, 318, 12134, 39, 774, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
p0psicles/SickGear
sickbeard/traktChecker.py
3
9633
# Author: Frank Fenton # URL: http://code.google.com/p/sickbeard/ # # This file is part of SickGear. # # SickGear 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. # # SickGear 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 SickGear. If not, see <http://www.gnu.org/licenses/>. import os import traceback import datetime import sickbeard from sickbeard import encodingKludge as ek from sickbeard import logger from sickbeard import helpers from sickbeard import search_queue from sickbeard.common import SKIPPED, WANTED from lib.trakt import * class TraktChecker(): def __init__(self): self.todoWanted = [] def run(self, force=False): try: # add shows from trakt.tv watchlist if sickbeard.TRAKT_USE_WATCHLIST: self.todoWanted = [] # its about to all get re-added if len(sickbeard.ROOT_DIRS.split('|')) < 2: logger.log(u"No default root directory", logger.ERROR) return self.updateShows() self.updateEpisodes() # sync trakt.tv library with SickGear library if sickbeard.TRAKT_SYNC: self.syncLibrary() except Exception: logger.log(traceback.format_exc(), logger.DEBUG) def findShow(self, indexer, indexerid): library = TraktCall("user/library/shows/all.json/%API%/" + sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD) if library == 'NULL': logger.log(u"No shows found in your library, aborting library update", logger.DEBUG) return if not library: logger.log(u"Could not connect to trakt service, aborting library check", logger.ERROR) return return filter(lambda x: int(indexerid) in [int(x['tvdb_id']) or 0, int(x['tvrage_id'])] or 0, library) def syncLibrary(self): logger.log(u"Syncing Trakt.tv show library", logger.DEBUG) for myShow in sickbeard.showList: self.addShowToTraktLibrary(myShow) def removeShowFromTraktLibrary(self, show_obj): data = {} if self.findShow(show_obj.indexer, show_obj.indexerid): # URL parameters data['tvdb_id'] = helpers.mapIndexersToShow(show_obj)[1] data['title'] = show_obj.name data['year'] = show_obj.startyear if len(data): logger.log(u"Removing " + show_obj.name + " from trakt.tv library", logger.DEBUG) TraktCall("show/unlibrary/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, data) def addShowToTraktLibrary(self, show_obj): """ Sends a request to trakt indicating that the given show and all its episodes is part of our library. show_obj: The TVShow object to add to trakt """ data = {} if not self.findShow(show_obj.indexer, show_obj.indexerid): # URL parameters data['tvdb_id'] = helpers.mapIndexersToShow(show_obj)[1] data['title'] = show_obj.name data['year'] = show_obj.startyear if len(data): logger.log(u"Adding " + show_obj.name + " to trakt.tv library", logger.DEBUG) TraktCall("show/library/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, data) def updateShows(self): logger.log(u"Starting trakt show watchlist check", logger.DEBUG) watchlist = TraktCall("user/watchlist/shows.json/%API%/" + sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD) if watchlist == 'NULL': logger.log(u"No shows found in your watchlist, aborting watchlist update", logger.DEBUG) return if not watchlist: logger.log(u"Could not connect to trakt service, aborting watchlist update", logger.ERROR) return for show in watchlist: indexer = int(sickbeard.TRAKT_DEFAULT_INDEXER) if indexer == 2: indexer_id = int(show["tvrage_id"]) else: indexer_id = int(show["tvdb_id"]) if int(sickbeard.TRAKT_METHOD_ADD) != 2: self.addDefaultShow(indexer, indexer_id, show["title"], SKIPPED) else: self.addDefaultShow(indexer, indexer_id, show["title"], WANTED) if int(sickbeard.TRAKT_METHOD_ADD) == 1: newShow = helpers.findCertainShow(sickbeard.showList, indexer_id) if newShow is not None: self.setEpisodeToWanted(newShow, 1, 1) else: self.todoWanted.append((indexer_id, 1, 1)) def updateEpisodes(self): """ Sets episodes to wanted that are in trakt watchlist """ logger.log(u"Starting trakt episode watchlist check", logger.DEBUG) watchlist = TraktCall("user/watchlist/episodes.json/%API%/" + sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD) if watchlist == 'NULL': logger.log(u"No episodes found in your watchlist, aborting watchlist update", logger.DEBUG) return if not watchlist: logger.log(u"Could not connect to trakt service, aborting watchlist update", logger.ERROR) return for show in watchlist: indexer = int(sickbeard.TRAKT_DEFAULT_INDEXER) if indexer == 2: indexer_id = int(show["tvrage_id"]) else: indexer_id = int(show["tvdb_id"]) self.addDefaultShow(indexer, indexer_id, show["title"], SKIPPED) newShow = helpers.findCertainShow(sickbeard.showList, indexer_id) try: if newShow and newShow.indexer == indexer: for episode in show["episodes"]: if newShow is not None: self.setEpisodeToWanted(newShow, episode["season"], episode["number"]) else: self.todoWanted.append((indexer_id, episode["season"], episode["number"])) except TypeError: logger.log(u"Could not parse the output from trakt for " + show["title"], logger.DEBUG) def addDefaultShow(self, indexer, indexer_id, name, status): """ Adds a new show with the default settings """ if not helpers.findCertainShow(sickbeard.showList, int(indexer_id)): logger.log(u"Adding show " + str(indexer_id)) root_dirs = sickbeard.ROOT_DIRS.split('|') try: location = root_dirs[int(root_dirs[0]) + 1] except: location = None if location: showPath = ek.ek(os.path.join, location, helpers.sanitizeFileName(name)) dir_exists = helpers.makeDir(showPath) if not dir_exists: logger.log(u"Unable to create the folder " + showPath + ", can't add the show", logger.ERROR) return else: helpers.chmodAsParent(showPath) sickbeard.showQueueScheduler.action.addShow(int(indexer), int(indexer_id), showPath, status, int(sickbeard.QUALITY_DEFAULT), int(sickbeard.FLATTEN_FOLDERS_DEFAULT), paused=sickbeard.TRAKT_START_PAUSED) else: logger.log(u"There was an error creating the show, no root directory setting found", logger.ERROR) return def setEpisodeToWanted(self, show, s, e): """ Sets an episode to wanted, only is it is currently skipped """ epObj = show.getEpisode(int(s), int(e)) if epObj: with epObj.lock: if epObj.status != SKIPPED or epObj.airdate == datetime.date.fromordinal(1): return logger.log(u"Setting episode s" + str(s) + "e" + str(e) + " of show " + show.name + " to wanted") # figure out what segment the episode is in and remember it so we can backlog it epObj.status = WANTED epObj.saveToDB() cur_backlog_queue_item = search_queue.BacklogQueueItem(show, [epObj]) sickbeard.searchQueueScheduler.action.add_item(cur_backlog_queue_item) logger.log(u"Starting backlog for " + show.name + " season " + str( s) + " episode " + str(e) + " because some eps were set to wanted") def manageNewShow(self, show): logger.log(u"Checking if trakt watch list wants to search for episodes from new show " + show.name, logger.DEBUG) episodes = [i for i in self.todoWanted if i[0] == show.indexerid] for episode in episodes: self.todoWanted.remove(episode) self.setEpisodeToWanted(show, episode[1], episode[2])
gpl-3.0
[ 3, 6529, 26, 11007, 481, 484, 265, 199, 3, 2851, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 32370, 15283, 15, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28964, 39, 2210, 14, 199, 3, 199, 3, 28964, 39, 2210, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 28964, 39, 2210, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 28964, 39, 2210, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 747, 199, 646, 5190, 199, 646, 2197, 199, 199, 646, 17898, 199, 504, 17898, 492, 2644, 43, 76, 16603, 465, 325, 75, 199, 504, 17898, 492, 2512, 199, 504, 17898, 492, 10897, 199, 504, 17898, 492, 2754, 63, 1825, 199, 504, 17898, 14, 2330, 492, 27885, 19359, 12, 644, 1441, 1149, 199, 504, 1973, 14, 28257, 492, 627, 421, 199, 533, 12643, 5973, 3048, 837, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 11396, 55, 10221, 275, 942, 339, 347, 1255, 8, 277, 12, 3542, 29, 797, 304, 267, 862, 26, 288, 327, 1050, 13703, 687, 30501, 14, 6993, 9626, 513, 288, 340, 17898, 14, 1766, 7872, 52, 63, 4701, 63, 55, 8078, 4924, 26, 355, 291, 14, 11396, 55, 10221, 275, 942, 221, 327, 2399, 3595, 370, 1006, 664, 295, 13, 3270, 355, 340, 822, 8, 32370, 15283, 14, 5441, 63, 14455, 14, 1294, 20137, 1333, 665, 499, 26, 490, 2512, 14, 793, 8, 85, 2, 1944, 849, 1738, 2082, 401, 2512, 14, 3170, 9, 490, 372, 355, 291, 14, 873, 6824, 83, 342, 355, 291, 14, 873, 22887, 83, 342, 953, 327, 7604, 30501, 14, 6993, 3555, 543, 28964, 39, 2210, 3555, 288, 340, 17898, 14, 1766, 7872, 52, 63, 22012, 26, 355, 291, 14, 5186, 7424, 342, 267, 871, 2186, 26, 288, 2512, 14, 793, 8, 6894, 14, 908, 63, 2804, 1062, 2512, 14, 5287, 9, 339, 347, 2342, 6824, 8, 277, 12, 23093, 12, 23093, 344, 304, 267, 3555, 275, 12643, 5973, 2176, 480, 751, 15, 4342, 15, 23866, 15, 452, 14, 1001, 3149, 3735, 5, 6687, 435, 17898, 14, 1766, 7872, 52, 63, 11958, 12, 17898, 14, 1766, 7872, 52, 63, 3735, 12, 17898, 14, 1766, 7872, 52, 63, 11958, 12, 17898, 14, 1766, 7872, 52, 63, 9032, 9, 398, 340, 3555, 508, 283, 8084, 356, 288, 2512, 14, 793, 8, 85, 2, 1944, 13703, 1911, 315, 2195, 3555, 12, 12004, 316, 3555, 1678, 401, 2512, 14, 5287, 9, 288, 372, 398, 340, 440, 3555, 26, 288, 2512, 14, 793, 8, 85, 2, 6531, 440, 4907, 370, 30501, 2435, 12, 12004, 316, 3555, 1104, 401, 2512, 14, 3170, 9, 288, 372, 398, 372, 2457, 8, 2734, 671, 26, 1109, 8, 15615, 344, 9, 315, 359, 442, 8, 88, 459, 23625, 63, 344, 1105, 503, 378, 12, 1109, 8, 88, 459, 6993, 28812, 63, 344, 24437, 503, 378, 12, 3555, 9, 339, 347, 7604, 7424, 8, 277, 304, 267, 2512, 14, 793, 8, 85, 2, 10878, 316, 12643, 5973, 14, 6993, 2498, 3555, 401, 2512, 14, 5287, 9, 398, 367, 3002, 6824, 315, 17898, 14, 2384, 1296, 26, 288, 291, 14, 525, 6824, 1378, 2437, 5973, 7424, 8, 1662, 6824, 9, 339, 347, 2813, 6824, 2532, 2437, 5973, 7424, 8, 277, 12, 2498, 63, 1113, 304, 267, 666, 275, 1052, 267, 340, 291, 14, 1623, 6824, 8, 2384, 63, 1113, 14, 15615, 12, 2498, 63, 1113, 14, 15615, 344, 304, 288, 327, 2851, 2633, 288, 666, 459, 23625, 63, 344, 418, 275, 10897, 14, 1130, 2681, 1192, 1378, 6824, 8, 2384, 63, 1113, 2788, 17, 61, 288, 666, 459, 1213, 418, 275, 2498, 63, 1113, 14, 354, 288, 666, 459, 3403, 418, 275, 2498, 63, 1113, 14, 7848, 369, 2210, 398, 340, 822, 8, 576, 304, 288, 2512, 14, 793, 8, 85, 2, 23420, 298, 435, 2498, 63, 1113, 14, 354, 435, 298, 687, 30501, 14, 6993, 3555, 401, 2512, 14, 5287, 9, 288, 12643, 5973, 2176, 480, 2384, 15, 324, 4342, 3149, 3735, 31181, 17898, 14, 1766, 7872, 52, 63, 3735, 12, 17898, 14, 1766, 7872, 52, 63, 11958, 12, 17898, 14, 1766, 7872, 52, 63, 9032, 12, 1993, 666, 9, 339, 347, 1050, 6824, 1378, 2437, 5973, 7424, 8, 277, 12, 2498, 63, 1113, 304, 267, 408, 267, 428, 3198, 282, 1056, 370, 30501, 9297, 626, 314, 1627, 2498, 436, 1006, 2399, 30060, 365, 1777, 402, 4154, 3555, 14, 398, 2498, 63, 1113, 26, 710, 26990, 6824, 909, 370, 1050, 370, 30501, 267, 408, 398, 666, 275, 1052, 398, 340, 440, 291, 14, 1623, 6824, 8, 2384, 63, 1113, 14, 15615, 12, 2498, 63, 1113, 14, 15615, 344, 304, 288, 327, 2851, 2633, 288, 666, 459, 23625, 63, 344, 418, 275, 10897, 14, 1130, 2681, 1192, 1378, 6824, 8, 2384, 63, 1113, 2788, 17, 61, 288, 666, 459, 1213, 418, 275, 2498, 63, 1113, 14, 354, 288, 666, 459, 3403, 418, 275, 2498, 63, 1113, 14, 7848, 369, 2210, 398, 340, 822, 8, 576, 304, 288, 2512, 14, 793, 8, 85, 2, 20897, 298, 435, 2498, 63, 1113, 14, 354, 435, 298, 370, 30501, 14, 6993, 3555, 401, 2512, 14, 5287, 9, 288, 12643, 5973, 2176, 480, 2384, 15, 4342, 3149, 3735, 31181, 17898, 14, 1766, 7872, 52, 63, 3735, 12, 17898, 14, 1766, 7872, 52, 63, 11958, 12, 17898, 14, 1766, 7872, 52, 63, 9032, 12, 1993, 666, 9, 339, 347, 1678, 6824, 83, 8, 277, 304, 267, 2512, 14, 793, 8, 85, 2, 14139, 30501, 2498, 9626, 513, 1104, 401 ]
[ 6529, 26, 11007, 481, 484, 265, 199, 3, 2851, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 32370, 15283, 15, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28964, 39, 2210, 14, 199, 3, 199, 3, 28964, 39, 2210, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 28964, 39, 2210, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 28964, 39, 2210, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 747, 199, 646, 5190, 199, 646, 2197, 199, 199, 646, 17898, 199, 504, 17898, 492, 2644, 43, 76, 16603, 465, 325, 75, 199, 504, 17898, 492, 2512, 199, 504, 17898, 492, 10897, 199, 504, 17898, 492, 2754, 63, 1825, 199, 504, 17898, 14, 2330, 492, 27885, 19359, 12, 644, 1441, 1149, 199, 504, 1973, 14, 28257, 492, 627, 421, 199, 533, 12643, 5973, 3048, 837, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 11396, 55, 10221, 275, 942, 339, 347, 1255, 8, 277, 12, 3542, 29, 797, 304, 267, 862, 26, 288, 327, 1050, 13703, 687, 30501, 14, 6993, 9626, 513, 288, 340, 17898, 14, 1766, 7872, 52, 63, 4701, 63, 55, 8078, 4924, 26, 355, 291, 14, 11396, 55, 10221, 275, 942, 221, 327, 2399, 3595, 370, 1006, 664, 295, 13, 3270, 355, 340, 822, 8, 32370, 15283, 14, 5441, 63, 14455, 14, 1294, 20137, 1333, 665, 499, 26, 490, 2512, 14, 793, 8, 85, 2, 1944, 849, 1738, 2082, 401, 2512, 14, 3170, 9, 490, 372, 355, 291, 14, 873, 6824, 83, 342, 355, 291, 14, 873, 22887, 83, 342, 953, 327, 7604, 30501, 14, 6993, 3555, 543, 28964, 39, 2210, 3555, 288, 340, 17898, 14, 1766, 7872, 52, 63, 22012, 26, 355, 291, 14, 5186, 7424, 342, 267, 871, 2186, 26, 288, 2512, 14, 793, 8, 6894, 14, 908, 63, 2804, 1062, 2512, 14, 5287, 9, 339, 347, 2342, 6824, 8, 277, 12, 23093, 12, 23093, 344, 304, 267, 3555, 275, 12643, 5973, 2176, 480, 751, 15, 4342, 15, 23866, 15, 452, 14, 1001, 3149, 3735, 5, 6687, 435, 17898, 14, 1766, 7872, 52, 63, 11958, 12, 17898, 14, 1766, 7872, 52, 63, 3735, 12, 17898, 14, 1766, 7872, 52, 63, 11958, 12, 17898, 14, 1766, 7872, 52, 63, 9032, 9, 398, 340, 3555, 508, 283, 8084, 356, 288, 2512, 14, 793, 8, 85, 2, 1944, 13703, 1911, 315, 2195, 3555, 12, 12004, 316, 3555, 1678, 401, 2512, 14, 5287, 9, 288, 372, 398, 340, 440, 3555, 26, 288, 2512, 14, 793, 8, 85, 2, 6531, 440, 4907, 370, 30501, 2435, 12, 12004, 316, 3555, 1104, 401, 2512, 14, 3170, 9, 288, 372, 398, 372, 2457, 8, 2734, 671, 26, 1109, 8, 15615, 344, 9, 315, 359, 442, 8, 88, 459, 23625, 63, 344, 1105, 503, 378, 12, 1109, 8, 88, 459, 6993, 28812, 63, 344, 24437, 503, 378, 12, 3555, 9, 339, 347, 7604, 7424, 8, 277, 304, 267, 2512, 14, 793, 8, 85, 2, 10878, 316, 12643, 5973, 14, 6993, 2498, 3555, 401, 2512, 14, 5287, 9, 398, 367, 3002, 6824, 315, 17898, 14, 2384, 1296, 26, 288, 291, 14, 525, 6824, 1378, 2437, 5973, 7424, 8, 1662, 6824, 9, 339, 347, 2813, 6824, 2532, 2437, 5973, 7424, 8, 277, 12, 2498, 63, 1113, 304, 267, 666, 275, 1052, 267, 340, 291, 14, 1623, 6824, 8, 2384, 63, 1113, 14, 15615, 12, 2498, 63, 1113, 14, 15615, 344, 304, 288, 327, 2851, 2633, 288, 666, 459, 23625, 63, 344, 418, 275, 10897, 14, 1130, 2681, 1192, 1378, 6824, 8, 2384, 63, 1113, 2788, 17, 61, 288, 666, 459, 1213, 418, 275, 2498, 63, 1113, 14, 354, 288, 666, 459, 3403, 418, 275, 2498, 63, 1113, 14, 7848, 369, 2210, 398, 340, 822, 8, 576, 304, 288, 2512, 14, 793, 8, 85, 2, 23420, 298, 435, 2498, 63, 1113, 14, 354, 435, 298, 687, 30501, 14, 6993, 3555, 401, 2512, 14, 5287, 9, 288, 12643, 5973, 2176, 480, 2384, 15, 324, 4342, 3149, 3735, 31181, 17898, 14, 1766, 7872, 52, 63, 3735, 12, 17898, 14, 1766, 7872, 52, 63, 11958, 12, 17898, 14, 1766, 7872, 52, 63, 9032, 12, 1993, 666, 9, 339, 347, 1050, 6824, 1378, 2437, 5973, 7424, 8, 277, 12, 2498, 63, 1113, 304, 267, 408, 267, 428, 3198, 282, 1056, 370, 30501, 9297, 626, 314, 1627, 2498, 436, 1006, 2399, 30060, 365, 1777, 402, 4154, 3555, 14, 398, 2498, 63, 1113, 26, 710, 26990, 6824, 909, 370, 1050, 370, 30501, 267, 408, 398, 666, 275, 1052, 398, 340, 440, 291, 14, 1623, 6824, 8, 2384, 63, 1113, 14, 15615, 12, 2498, 63, 1113, 14, 15615, 344, 304, 288, 327, 2851, 2633, 288, 666, 459, 23625, 63, 344, 418, 275, 10897, 14, 1130, 2681, 1192, 1378, 6824, 8, 2384, 63, 1113, 2788, 17, 61, 288, 666, 459, 1213, 418, 275, 2498, 63, 1113, 14, 354, 288, 666, 459, 3403, 418, 275, 2498, 63, 1113, 14, 7848, 369, 2210, 398, 340, 822, 8, 576, 304, 288, 2512, 14, 793, 8, 85, 2, 20897, 298, 435, 2498, 63, 1113, 14, 354, 435, 298, 370, 30501, 14, 6993, 3555, 401, 2512, 14, 5287, 9, 288, 12643, 5973, 2176, 480, 2384, 15, 4342, 3149, 3735, 31181, 17898, 14, 1766, 7872, 52, 63, 3735, 12, 17898, 14, 1766, 7872, 52, 63, 11958, 12, 17898, 14, 1766, 7872, 52, 63, 9032, 12, 1993, 666, 9, 339, 347, 1678, 6824, 83, 8, 277, 304, 267, 2512, 14, 793, 8, 85, 2, 14139, 30501, 2498, 9626, 513, 1104, 401, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hastexo/edx-platform
cms/djangoapps/contentstore/views/tests/test_gating.py
11
5318
""" Unit tests for the gating feature in Studio """ import json from mock import patch from contentstore.tests.utils import CourseTestCase from contentstore.utils import reverse_usage_url from contentstore.views.item import VisibilityState from openedx.core.lib.gating.api import GATING_NAMESPACE_QUALIFIER from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE from xmodule.modulestore.tests.factories import ItemFactory class TestSubsectionGating(CourseTestCase): """ Tests for the subsection gating feature """ MODULESTORE = TEST_DATA_SPLIT_MODULESTORE ENABLED_SIGNALS = ['item_deleted'] def setUp(self): """ Initial data setup """ super(TestSubsectionGating, self).setUp() # Enable subsection gating for the test course self.course.enable_subsection_gating = True self.save_course() # create a chapter self.chapter = ItemFactory.create( parent_location=self.course.location, category='chapter', display_name='untitled chapter' ) # create 2 sequentials self.seq1 = ItemFactory.create( parent_location=self.chapter.location, category='sequential', display_name='untitled sequential 1' ) self.seq1_url = reverse_usage_url('xblock_handler', self.seq1.location) self.seq2 = ItemFactory.create( parent_location=self.chapter.location, category='sequential', display_name='untitled sequential 2' ) self.seq2_url = reverse_usage_url('xblock_handler', self.seq2.location) @patch('contentstore.views.item.gating_api.add_prerequisite') def test_add_prerequisite(self, mock_add_prereq): """ Test adding a subsection as a prerequisite """ self.client.ajax_post( self.seq1_url, data={'isPrereq': True} ) mock_add_prereq.assert_called_with(self.course.id, self.seq1.location) @patch('contentstore.views.item.gating_api.remove_prerequisite') def test_remove_prerequisite(self, mock_remove_prereq): """ Test removing a subsection as a prerequisite """ self.client.ajax_post( self.seq1_url, data={'isPrereq': False} ) mock_remove_prereq.assert_called_with(self.seq1.location) @patch('contentstore.views.item.gating_api.set_required_content') def test_add_gate(self, mock_set_required_content): """ Test adding a gated subsection """ self.client.ajax_post( self.seq2_url, data={'prereqUsageKey': unicode(self.seq1.location), 'prereqMinScore': '100'} ) mock_set_required_content.assert_called_with( self.course.id, self.seq2.location, unicode(self.seq1.location), '100' ) @patch('contentstore.views.item.gating_api.set_required_content') def test_remove_gate(self, mock_set_required_content): """ Test removing a gated subsection """ self.client.ajax_post( self.seq2_url, data={'prereqUsageKey': '', 'prereqMinScore': ''} ) mock_set_required_content.assert_called_with( self.course.id, self.seq2.location, '', '' ) @patch('contentstore.views.item.gating_api.get_prerequisites') @patch('contentstore.views.item.gating_api.get_required_content') @patch('contentstore.views.item.gating_api.is_prerequisite') def test_get_prerequisite(self, mock_is_prereq, mock_get_required_content, mock_get_prereqs): mock_is_prereq.return_value = True mock_get_required_content.return_value = unicode(self.seq1.location), 100 mock_get_prereqs.return_value = [ {'namespace': '{}{}'.format(unicode(self.seq1.location), GATING_NAMESPACE_QUALIFIER)}, {'namespace': '{}{}'.format(unicode(self.seq2.location), GATING_NAMESPACE_QUALIFIER)} ] resp = json.loads(self.client.get_json(self.seq2_url).content) mock_is_prereq.assert_called_with(self.course.id, self.seq2.location) mock_get_required_content.assert_called_with(self.course.id, self.seq2.location) mock_get_prereqs.assert_called_with(self.course.id) self.assertTrue(resp['is_prereq']) self.assertEqual(resp['prereq'], unicode(self.seq1.location)) self.assertEqual(resp['prereq_min_score'], 100) self.assertEqual(resp['visibility_state'], VisibilityState.gated) @patch('contentstore.signals.handlers.gating_api.set_required_content') @patch('contentstore.signals.handlers.gating_api.remove_prerequisite') def test_delete_item_signal_handler_called(self, mock_remove_prereq, mock_set_required): seq3 = ItemFactory.create( parent_location=self.chapter.location, category='sequential', display_name='untitled sequential 3' ) self.client.delete(reverse_usage_url('xblock_handler', seq3.location)) mock_remove_prereq.assert_called_with(seq3.location) mock_set_required.assert_called_with(seq3.location.course_key, seq3.location, None, None)
agpl-3.0
[ 624, 199, 5072, 2295, 367, 314, 486, 1958, 3878, 315, 13225, 199, 624, 199, 646, 2022, 199, 199, 504, 1683, 492, 3371, 199, 199, 504, 23061, 14, 2219, 14, 1208, 492, 5531, 1746, 199, 504, 23061, 14, 1208, 492, 3837, 63, 3807, 63, 633, 199, 504, 23061, 14, 4196, 14, 1053, 492, 6561, 4783, 2223, 199, 504, 22709, 14, 1018, 14, 773, 14, 71, 1958, 14, 1246, 492, 598, 27186, 63, 13001, 63, 9283, 16910, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1176, 63, 1208, 492, 7393, 63, 3998, 63, 30538, 63, 27011, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 19319, 421, 199, 533, 1379, 31839, 39, 1958, 8, 6979, 1746, 304, 272, 408, 272, 6496, 367, 314, 19876, 486, 1958, 3878, 272, 408, 272, 30920, 1293, 23278, 275, 7393, 63, 3998, 63, 30538, 63, 27011, 272, 27926, 36, 63, 16496, 51, 275, 788, 1053, 63, 6062, 418, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 6026, 666, 3272, 267, 408, 267, 1613, 8, 774, 31839, 39, 1958, 12, 291, 680, 5996, 342, 398, 327, 12030, 19876, 486, 1958, 367, 314, 511, 2518, 267, 291, 14, 1972, 14, 4296, 63, 18920, 63, 71, 1958, 275, 715, 267, 291, 14, 2117, 63, 1972, 342, 398, 327, 1218, 282, 17044, 267, 291, 14, 11316, 275, 19319, 14, 981, 8, 288, 1676, 63, 1985, 29, 277, 14, 1972, 14, 1985, 12, 288, 4637, 534, 11316, 297, 288, 2929, 63, 354, 534, 324, 1213, 68, 17044, 7, 267, 776, 398, 327, 1218, 499, 23381, 83, 267, 291, 14, 3610, 17, 275, 19319, 14, 981, 8, 288, 1676, 63, 1985, 29, 277, 14, 11316, 14, 1985, 12, 288, 4637, 534, 16211, 297, 288, 2929, 63, 354, 534, 324, 1213, 68, 23381, 413, 7, 267, 776, 267, 291, 14, 3610, 17, 63, 633, 275, 3837, 63, 3807, 63, 633, 360, 11283, 63, 2232, 297, 291, 14, 3610, 17, 14, 1985, 9, 398, 291, 14, 3610, 18, 275, 19319, 14, 981, 8, 288, 1676, 63, 1985, 29, 277, 14, 11316, 14, 1985, 12, 288, 4637, 534, 16211, 297, 288, 2929, 63, 354, 534, 324, 1213, 68, 23381, 499, 7, 267, 776, 267, 291, 14, 3610, 18, 63, 633, 275, 3837, 63, 3807, 63, 633, 360, 11283, 63, 2232, 297, 291, 14, 3610, 18, 14, 1985, 9, 339, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 525, 63, 657, 21763, 358, 272, 347, 511, 63, 525, 63, 657, 21763, 8, 277, 12, 1683, 63, 525, 63, 657, 2103, 304, 267, 408, 267, 1379, 7791, 282, 19876, 465, 282, 876, 21763, 267, 408, 398, 291, 14, 1258, 14, 12774, 63, 1932, 8, 288, 291, 14, 3610, 17, 63, 633, 12, 288, 666, 3713, 374, 2398, 2103, 356, 715, 93, 267, 776, 267, 1683, 63, 525, 63, 657, 2103, 14, 479, 63, 3527, 63, 1045, 8, 277, 14, 1972, 14, 344, 12, 291, 14, 3610, 17, 14, 1985, 9, 339, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 2168, 63, 657, 21763, 358, 272, 347, 511, 63, 2168, 63, 657, 21763, 8, 277, 12, 1683, 63, 2168, 63, 657, 2103, 304, 267, 408, 267, 1379, 12881, 282, 19876, 465, 282, 876, 21763, 267, 408, 398, 291, 14, 1258, 14, 12774, 63, 1932, 8, 288, 291, 14, 3610, 17, 63, 633, 12, 288, 666, 3713, 374, 2398, 2103, 356, 756, 93, 267, 776, 267, 1683, 63, 2168, 63, 657, 2103, 14, 479, 63, 3527, 63, 1045, 8, 277, 14, 3610, 17, 14, 1985, 9, 339, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 409, 63, 2427, 63, 1317, 358, 272, 347, 511, 63, 525, 63, 3237, 8, 277, 12, 1683, 63, 409, 63, 2427, 63, 1317, 304, 267, 408, 267, 1379, 7791, 282, 486, 972, 19876, 267, 408, 398, 291, 14, 1258, 14, 12774, 63, 1932, 8, 288, 291, 14, 3610, 18, 63, 633, 12, 288, 666, 3713, 657, 2103, 7692, 1197, 356, 2649, 8, 277, 14, 3610, 17, 14, 1985, 395, 283, 657, 2103, 4649, 12642, 356, 283, 1960, 936, 267, 776, 267, 1683, 63, 409, 63, 2427, 63, 1317, 14, 479, 63, 3527, 63, 1045, 8, 288, 291, 14, 1972, 14, 344, 12, 288, 291, 14, 3610, 18, 14, 1985, 12, 288, 2649, 8, 277, 14, 3610, 17, 14, 1985, 395, 288, 283, 1960, 7, 267, 776, 339, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 409, 63, 2427, 63, 1317, 358, 272, 347, 511, 63, 2168, 63, 3237, 8, 277, 12, 1683, 63, 409, 63, 2427, 63, 1317, 304, 267, 408, 267, 1379, 12881, 282, 486, 972, 19876, 267, 408, 398, 291, 14, 1258, 14, 12774, 63, 1932, 8, 288, 291, 14, 3610, 18, 63, 633, 12, 288, 666, 3713, 657, 2103, 7692, 1197, 356, 3260, 283, 657, 2103, 4649, 12642, 356, 28174, 267, 776, 267, 1683, 63, 409, 63, 2427, 63, 1317, 14, 479, 63, 3527, 63, 1045, 8, 288, 291, 14, 1972, 14, 344, 12, 288, 291, 14, 3610, 18, 14, 1985, 12, 288, 3260, 288, 2125, 267, 776, 339, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 362, 63, 657, 30140, 358, 272, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 362, 63, 2427, 63, 1317, 358, 272, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 374, 63, 657, 21763, 358, 272, 347, 511, 63, 362, 63, 657, 21763, 8, 277, 12, 1683, 63, 374, 63, 657, 2103, 12, 1683, 63, 362, 63, 2427, 63, 1317, 12, 1683, 63, 362, 63, 657, 12720, 304, 267, 1683, 63, 374, 63, 657, 2103, 14, 1107, 63, 585, 275, 715, 267, 1683, 63, 362, 63, 2427, 63, 1317, 14, 1107, 63, 585, 275, 2649, 8, 277, 14, 3610, 17, 14, 1985, 395, 2948, 267, 1683, 63, 362, 63, 657, 12720, 14, 1107, 63, 585, 275, 359, 288, 791, 3251, 356, 9005, 11123, 908, 8, 2975, 8, 277, 14, 3610, 17, 14, 1985, 395, 598, 27186, 63, 13001, 63, 9283, 16910, 16658, 288, 791, 3251, 356 ]
[ 199, 5072, 2295, 367, 314, 486, 1958, 3878, 315, 13225, 199, 624, 199, 646, 2022, 199, 199, 504, 1683, 492, 3371, 199, 199, 504, 23061, 14, 2219, 14, 1208, 492, 5531, 1746, 199, 504, 23061, 14, 1208, 492, 3837, 63, 3807, 63, 633, 199, 504, 23061, 14, 4196, 14, 1053, 492, 6561, 4783, 2223, 199, 504, 22709, 14, 1018, 14, 773, 14, 71, 1958, 14, 1246, 492, 598, 27186, 63, 13001, 63, 9283, 16910, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1176, 63, 1208, 492, 7393, 63, 3998, 63, 30538, 63, 27011, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 19319, 421, 199, 533, 1379, 31839, 39, 1958, 8, 6979, 1746, 304, 272, 408, 272, 6496, 367, 314, 19876, 486, 1958, 3878, 272, 408, 272, 30920, 1293, 23278, 275, 7393, 63, 3998, 63, 30538, 63, 27011, 272, 27926, 36, 63, 16496, 51, 275, 788, 1053, 63, 6062, 418, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 6026, 666, 3272, 267, 408, 267, 1613, 8, 774, 31839, 39, 1958, 12, 291, 680, 5996, 342, 398, 327, 12030, 19876, 486, 1958, 367, 314, 511, 2518, 267, 291, 14, 1972, 14, 4296, 63, 18920, 63, 71, 1958, 275, 715, 267, 291, 14, 2117, 63, 1972, 342, 398, 327, 1218, 282, 17044, 267, 291, 14, 11316, 275, 19319, 14, 981, 8, 288, 1676, 63, 1985, 29, 277, 14, 1972, 14, 1985, 12, 288, 4637, 534, 11316, 297, 288, 2929, 63, 354, 534, 324, 1213, 68, 17044, 7, 267, 776, 398, 327, 1218, 499, 23381, 83, 267, 291, 14, 3610, 17, 275, 19319, 14, 981, 8, 288, 1676, 63, 1985, 29, 277, 14, 11316, 14, 1985, 12, 288, 4637, 534, 16211, 297, 288, 2929, 63, 354, 534, 324, 1213, 68, 23381, 413, 7, 267, 776, 267, 291, 14, 3610, 17, 63, 633, 275, 3837, 63, 3807, 63, 633, 360, 11283, 63, 2232, 297, 291, 14, 3610, 17, 14, 1985, 9, 398, 291, 14, 3610, 18, 275, 19319, 14, 981, 8, 288, 1676, 63, 1985, 29, 277, 14, 11316, 14, 1985, 12, 288, 4637, 534, 16211, 297, 288, 2929, 63, 354, 534, 324, 1213, 68, 23381, 499, 7, 267, 776, 267, 291, 14, 3610, 18, 63, 633, 275, 3837, 63, 3807, 63, 633, 360, 11283, 63, 2232, 297, 291, 14, 3610, 18, 14, 1985, 9, 339, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 525, 63, 657, 21763, 358, 272, 347, 511, 63, 525, 63, 657, 21763, 8, 277, 12, 1683, 63, 525, 63, 657, 2103, 304, 267, 408, 267, 1379, 7791, 282, 19876, 465, 282, 876, 21763, 267, 408, 398, 291, 14, 1258, 14, 12774, 63, 1932, 8, 288, 291, 14, 3610, 17, 63, 633, 12, 288, 666, 3713, 374, 2398, 2103, 356, 715, 93, 267, 776, 267, 1683, 63, 525, 63, 657, 2103, 14, 479, 63, 3527, 63, 1045, 8, 277, 14, 1972, 14, 344, 12, 291, 14, 3610, 17, 14, 1985, 9, 339, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 2168, 63, 657, 21763, 358, 272, 347, 511, 63, 2168, 63, 657, 21763, 8, 277, 12, 1683, 63, 2168, 63, 657, 2103, 304, 267, 408, 267, 1379, 12881, 282, 19876, 465, 282, 876, 21763, 267, 408, 398, 291, 14, 1258, 14, 12774, 63, 1932, 8, 288, 291, 14, 3610, 17, 63, 633, 12, 288, 666, 3713, 374, 2398, 2103, 356, 756, 93, 267, 776, 267, 1683, 63, 2168, 63, 657, 2103, 14, 479, 63, 3527, 63, 1045, 8, 277, 14, 3610, 17, 14, 1985, 9, 339, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 409, 63, 2427, 63, 1317, 358, 272, 347, 511, 63, 525, 63, 3237, 8, 277, 12, 1683, 63, 409, 63, 2427, 63, 1317, 304, 267, 408, 267, 1379, 7791, 282, 486, 972, 19876, 267, 408, 398, 291, 14, 1258, 14, 12774, 63, 1932, 8, 288, 291, 14, 3610, 18, 63, 633, 12, 288, 666, 3713, 657, 2103, 7692, 1197, 356, 2649, 8, 277, 14, 3610, 17, 14, 1985, 395, 283, 657, 2103, 4649, 12642, 356, 283, 1960, 936, 267, 776, 267, 1683, 63, 409, 63, 2427, 63, 1317, 14, 479, 63, 3527, 63, 1045, 8, 288, 291, 14, 1972, 14, 344, 12, 288, 291, 14, 3610, 18, 14, 1985, 12, 288, 2649, 8, 277, 14, 3610, 17, 14, 1985, 395, 288, 283, 1960, 7, 267, 776, 339, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 409, 63, 2427, 63, 1317, 358, 272, 347, 511, 63, 2168, 63, 3237, 8, 277, 12, 1683, 63, 409, 63, 2427, 63, 1317, 304, 267, 408, 267, 1379, 12881, 282, 486, 972, 19876, 267, 408, 398, 291, 14, 1258, 14, 12774, 63, 1932, 8, 288, 291, 14, 3610, 18, 63, 633, 12, 288, 666, 3713, 657, 2103, 7692, 1197, 356, 3260, 283, 657, 2103, 4649, 12642, 356, 28174, 267, 776, 267, 1683, 63, 409, 63, 2427, 63, 1317, 14, 479, 63, 3527, 63, 1045, 8, 288, 291, 14, 1972, 14, 344, 12, 288, 291, 14, 3610, 18, 14, 1985, 12, 288, 3260, 288, 2125, 267, 776, 339, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 362, 63, 657, 30140, 358, 272, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 362, 63, 2427, 63, 1317, 358, 272, 768, 2068, 360, 28160, 14, 4196, 14, 1053, 14, 71, 1958, 63, 1246, 14, 374, 63, 657, 21763, 358, 272, 347, 511, 63, 362, 63, 657, 21763, 8, 277, 12, 1683, 63, 374, 63, 657, 2103, 12, 1683, 63, 362, 63, 2427, 63, 1317, 12, 1683, 63, 362, 63, 657, 12720, 304, 267, 1683, 63, 374, 63, 657, 2103, 14, 1107, 63, 585, 275, 715, 267, 1683, 63, 362, 63, 2427, 63, 1317, 14, 1107, 63, 585, 275, 2649, 8, 277, 14, 3610, 17, 14, 1985, 395, 2948, 267, 1683, 63, 362, 63, 657, 12720, 14, 1107, 63, 585, 275, 359, 288, 791, 3251, 356, 9005, 11123, 908, 8, 2975, 8, 277, 14, 3610, 17, 14, 1985, 395, 598, 27186, 63, 13001, 63, 9283, 16910, 16658, 288, 791, 3251, 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, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ashutrix03/inteygrate_flaskapp-master
yowsup/common/optionalmodules.py
13
1739
import importlib import logging logger = logging.getLogger(__name__) from contextlib import contextmanager class OptionalModule(object): def __init__(self, modulename, failMessage = None, require = False): self.modulename = modulename self.require = require self.failMessage = failMessage def __enter__(self): return self.importFn def importFn(self, what = None): imp = self.modulename if not what else ("%s.%s" % (self.modulename, what)) return importlib.import_module(imp) def __exit__(self, exc_type, exc_val, exc_tb): if isinstance(exc_val, ImportError): failMessage = self.failMessage if self.failMessage is not None else ("%s import failed" % self.modulename) if failMessage: logger.error(failMessage) if self.require: raise return True class PILOptionalModule(OptionalModule): def __init__(self, failMessage = None, require = False): super(PILOptionalModule, self).__init__("PIL", failMessage= failMessage, require = require) class FFVideoOptionalModule(OptionalModule): def __init__(self, failMessage = None, require = False): super(FFVideoOptionalModule, self).__init__("ffvideo", failMessage=failMessage, require=require) class AxolotlOptionalModule(OptionalModule): def __init__(self, failMessage = None, require = False): super(AxolotlOptionalModule, self).__init__("axolotl", failMessage=failMessage, require=require) if __name__ == "__main__": with PILOptionalModule() as imp: imp() print("OK") print("DONE")
gpl-3.0
[ 646, 14802, 199, 646, 2050, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 504, 15502, 492, 27608, 199, 199, 533, 4879, 2377, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 30045, 12, 2449, 2209, 275, 488, 12, 4409, 275, 756, 304, 267, 291, 14, 22582, 275, 30045, 267, 291, 14, 4365, 275, 4409, 267, 291, 14, 1633, 2209, 275, 2449, 2209, 339, 347, 636, 4200, 721, 277, 304, 267, 372, 291, 14, 646, 9656, 339, 347, 492, 9656, 8, 277, 12, 4052, 275, 488, 304, 267, 1742, 275, 291, 14, 22582, 340, 440, 4052, 587, 19426, 83, 4111, 83, 2, 450, 334, 277, 14, 22582, 12, 4052, 430, 267, 372, 14802, 14, 646, 63, 578, 8, 3236, 9, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 637, 12, 3178, 63, 5842, 304, 267, 340, 1228, 8, 2804, 63, 637, 12, 3545, 304, 288, 2449, 2209, 275, 291, 14, 1633, 2209, 340, 291, 14, 1633, 2209, 365, 440, 488, 587, 19426, 83, 492, 3405, 2, 450, 291, 14, 22582, 9, 288, 340, 2449, 2209, 26, 355, 2512, 14, 705, 8, 1633, 2209, 9, 288, 340, 291, 14, 4365, 26, 355, 746, 288, 372, 715, 199, 199, 533, 14937, 7012, 2377, 8, 7012, 2377, 304, 272, 347, 636, 826, 721, 277, 12, 2449, 2209, 275, 488, 12, 4409, 275, 756, 304, 267, 1613, 8, 48, 1193, 7012, 2377, 12, 291, 2843, 826, 29093, 48, 1193, 401, 355, 2449, 2209, 29, 2449, 2209, 12, 355, 4409, 275, 4409, 9, 199, 199, 533, 25046, 9166, 7012, 2377, 8, 7012, 2377, 304, 272, 347, 636, 826, 721, 277, 12, 2449, 2209, 275, 488, 12, 4409, 275, 756, 304, 267, 1613, 8, 1665, 9166, 7012, 2377, 12, 291, 2843, 826, 29093, 556, 3722, 401, 355, 2449, 2209, 29, 1633, 2209, 12, 355, 4409, 29, 4365, 9, 199, 199, 533, 437, 15987, 1653, 76, 7012, 2377, 8, 7012, 2377, 304, 272, 347, 636, 826, 721, 277, 12, 2449, 2209, 275, 488, 12, 4409, 275, 756, 304, 267, 1613, 8, 33, 15987, 1653, 76, 7012, 2377, 12, 291, 2843, 826, 29093, 1219, 79, 1653, 76, 401, 355, 2449, 2209, 29, 1633, 2209, 12, 355, 4409, 29, 4365, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 543, 14937, 7012, 2377, 342, 465, 1742, 26, 267, 1742, 342, 267, 870, 480, 3593, 531, 272, 870, 480, 22162, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 14802, 199, 646, 2050, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 504, 15502, 492, 27608, 199, 199, 533, 4879, 2377, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 30045, 12, 2449, 2209, 275, 488, 12, 4409, 275, 756, 304, 267, 291, 14, 22582, 275, 30045, 267, 291, 14, 4365, 275, 4409, 267, 291, 14, 1633, 2209, 275, 2449, 2209, 339, 347, 636, 4200, 721, 277, 304, 267, 372, 291, 14, 646, 9656, 339, 347, 492, 9656, 8, 277, 12, 4052, 275, 488, 304, 267, 1742, 275, 291, 14, 22582, 340, 440, 4052, 587, 19426, 83, 4111, 83, 2, 450, 334, 277, 14, 22582, 12, 4052, 430, 267, 372, 14802, 14, 646, 63, 578, 8, 3236, 9, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 637, 12, 3178, 63, 5842, 304, 267, 340, 1228, 8, 2804, 63, 637, 12, 3545, 304, 288, 2449, 2209, 275, 291, 14, 1633, 2209, 340, 291, 14, 1633, 2209, 365, 440, 488, 587, 19426, 83, 492, 3405, 2, 450, 291, 14, 22582, 9, 288, 340, 2449, 2209, 26, 355, 2512, 14, 705, 8, 1633, 2209, 9, 288, 340, 291, 14, 4365, 26, 355, 746, 288, 372, 715, 199, 199, 533, 14937, 7012, 2377, 8, 7012, 2377, 304, 272, 347, 636, 826, 721, 277, 12, 2449, 2209, 275, 488, 12, 4409, 275, 756, 304, 267, 1613, 8, 48, 1193, 7012, 2377, 12, 291, 2843, 826, 29093, 48, 1193, 401, 355, 2449, 2209, 29, 2449, 2209, 12, 355, 4409, 275, 4409, 9, 199, 199, 533, 25046, 9166, 7012, 2377, 8, 7012, 2377, 304, 272, 347, 636, 826, 721, 277, 12, 2449, 2209, 275, 488, 12, 4409, 275, 756, 304, 267, 1613, 8, 1665, 9166, 7012, 2377, 12, 291, 2843, 826, 29093, 556, 3722, 401, 355, 2449, 2209, 29, 1633, 2209, 12, 355, 4409, 29, 4365, 9, 199, 199, 533, 437, 15987, 1653, 76, 7012, 2377, 8, 7012, 2377, 304, 272, 347, 636, 826, 721, 277, 12, 2449, 2209, 275, 488, 12, 4409, 275, 756, 304, 267, 1613, 8, 33, 15987, 1653, 76, 7012, 2377, 12, 291, 2843, 826, 29093, 1219, 79, 1653, 76, 401, 355, 2449, 2209, 29, 1633, 2209, 12, 355, 4409, 29, 4365, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 543, 14937, 7012, 2377, 342, 465, 1742, 26, 267, 1742, 342, 267, 870, 480, 3593, 531, 272, 870, 480, 22162, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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329
from rest_framework.fields import CharField, ListField, SerializerMethodField from rest_framework.serializers import ModelSerializer from mkt.api.fields import ReverseChoiceField, TranslationSerializerField from mkt.constants.base import (STATUS_CHOICES_API_v2, STATUS_FILE_CHOICES_API_v2, STATUS_PUBLIC) from mkt.extensions.models import Extension, ExtensionVersion from mkt.search.serializers import BaseESSerializer, es_to_datetime class ExtensionVersionSerializer(ModelSerializer): download_url = CharField(read_only=True) unsigned_download_url = CharField(read_only=True) reviewer_mini_manifest_url = CharField(read_only=True) status = ReverseChoiceField( choices_dict=STATUS_FILE_CHOICES_API_v2, read_only=True) class Meta: model = ExtensionVersion fields = ['id', 'created', 'download_url', 'reviewer_mini_manifest_url', 'unsigned_download_url', 'size', 'status', 'version'] class ExtensionSerializer(ModelSerializer): description = TranslationSerializerField(read_only=True) device_types = ListField(CharField(), source='device_names') icons = SerializerMethodField() latest_public_version = ExtensionVersionSerializer(read_only=True) latest_version = ExtensionVersionSerializer(read_only=True) mini_manifest_url = CharField(read_only=True) name = TranslationSerializerField(read_only=True) status = ReverseChoiceField( choices_dict=STATUS_CHOICES_API_v2, read_only=True) # FIXME: latest_version potentially expose private data. # Nothing extremely major, but maybe we care. Not a fan of moving it to # another endpoint since that'd mean developers and reviewers would need # to use that other endpoint instead of the regular one, but maybe that's # the way to go ? That endpoint could include all versions info, too. def get_icons(self, obj): return {size: obj.get_icon_url(size) for size in (64, 128)} class Meta: model = Extension fields = ['id', 'author', 'description', 'device_types', 'disabled', 'icons', 'last_updated', 'latest_version', 'latest_public_version', 'mini_manifest_url', 'name', 'slug', 'status', 'uuid', ] class ESExtensionSerializer(BaseESSerializer, ExtensionSerializer): class Meta(ExtensionSerializer.Meta): # Exclude non-public version data that we don't currently store in ES. fields = ['id', 'author', 'description', 'device_types', 'disabled', 'icons', 'last_updated', 'latest_public_version', 'mini_manifest_url', 'name', 'slug', 'status', 'uuid'] def fake_object(self, data): """Create a fake instance of Extension from ES data.""" obj = Extension(id=data['id']) data['created'] = es_to_datetime(data['created']) data['last_updated'] = es_to_datetime(data['last_updated']) data['modified'] = es_to_datetime(data['modified']) # Create a fake ExtensionVersion for latest_public_version. if data['latest_public_version']: obj.latest_public_version = ExtensionVersion( extension=obj, id=data['latest_public_version']['id'], created=es_to_datetime( data['latest_public_version']['created']), size=data['latest_public_version'].get('size', 0), status=STATUS_PUBLIC, version=data['latest_public_version']['version'],) # Set basic attributes we'll need on the fake instance using the data # from ES. self._attach_fields( obj, data, ('author', 'created', 'default_language', 'icon_hash', 'last_updated', 'modified', 'slug', 'status', 'version')) obj.deleted = data['is_deleted'] obj.disabled = data['is_disabled'] obj.uuid = data['guid'] # Attach translations for all translated attributes. # obj.default_language should be set first for this to work. self._attach_translations( obj, data, ('name', 'description', )) # Some methods might need the raw data from ES, put it on obj. obj.es_data = data return obj
bsd-3-clause
[ 504, 4618, 63, 4857, 14, 955, 492, 12064, 12, 3820, 792, 12, 25555, 3767, 792, 199, 504, 4618, 63, 4857, 14, 12844, 492, 5822, 7299, 199, 199, 504, 21825, 14, 1246, 14, 955, 492, 22734, 15792, 12, 25224, 7299, 792, 199, 504, 21825, 14, 5559, 14, 1095, 492, 334, 6305, 63, 16236, 63, 3735, 63, 86, 18, 12, 1816, 18460, 63, 3817, 63, 16236, 63, 3735, 63, 86, 18, 12, 18460, 63, 19476, 9, 199, 504, 21825, 14, 5359, 14, 992, 492, 13282, 12, 13282, 3353, 199, 504, 21825, 14, 1733, 14, 12844, 492, 3523, 654, 7299, 12, 9455, 63, 475, 63, 2083, 421, 199, 533, 13282, 3353, 7299, 8, 1685, 7299, 304, 272, 5235, 63, 633, 275, 12064, 8, 739, 63, 2118, 29, 549, 9, 272, 7381, 63, 4249, 63, 633, 275, 12064, 8, 739, 63, 2118, 29, 549, 9, 272, 11248, 281, 63, 18000, 63, 6418, 63, 633, 275, 12064, 8, 739, 63, 2118, 29, 549, 9, 272, 2004, 275, 22734, 15792, 8, 267, 3415, 63, 807, 29, 6305, 63, 3817, 63, 16236, 63, 3735, 63, 86, 18, 12, 1586, 63, 2118, 29, 549, 9, 339, 1021, 6288, 26, 267, 1402, 275, 13282, 3353, 267, 1504, 275, 788, 344, 297, 283, 3966, 297, 283, 4249, 63, 633, 297, 2116, 283, 23492, 63, 18000, 63, 6418, 63, 633, 297, 283, 2244, 63, 4249, 63, 633, 297, 2116, 283, 890, 297, 283, 1205, 297, 283, 1023, 418, 421, 199, 533, 13282, 7299, 8, 1685, 7299, 304, 272, 1369, 275, 25224, 7299, 792, 8, 739, 63, 2118, 29, 549, 9, 272, 2243, 63, 1313, 275, 3820, 792, 8, 2183, 1062, 1350, 534, 1782, 63, 1247, 358, 272, 7016, 83, 275, 25555, 3767, 792, 342, 272, 8839, 63, 3455, 63, 1023, 275, 13282, 3353, 7299, 8, 739, 63, 2118, 29, 549, 9, 272, 8839, 63, 1023, 275, 13282, 3353, 7299, 8, 739, 63, 2118, 29, 549, 9, 272, 20536, 63, 6418, 63, 633, 275, 12064, 8, 739, 63, 2118, 29, 549, 9, 272, 536, 275, 25224, 7299, 792, 8, 739, 63, 2118, 29, 549, 9, 272, 2004, 275, 22734, 15792, 8, 267, 3415, 63, 807, 29, 6305, 63, 16236, 63, 3735, 63, 86, 18, 12, 1586, 63, 2118, 29, 549, 9, 339, 327, 7600, 26, 8839, 63, 1023, 18994, 23705, 5726, 666, 14, 272, 327, 20550, 30503, 590, 12160, 12, 1325, 11703, 781, 10296, 14, 2832, 282, 13758, 402, 12876, 652, 370, 272, 327, 4573, 6037, 3967, 626, 5121, 4615, 19782, 436, 11248, 1192, 3955, 1929, 272, 327, 370, 675, 626, 1163, 6037, 3140, 402, 314, 5578, 1373, 12, 1325, 11703, 626, 1159, 272, 327, 314, 4340, 370, 2621, 5805, 10314, 6037, 4293, 2387, 1006, 5459, 2256, 12, 4634, 14, 339, 347, 664, 63, 16471, 8, 277, 12, 1559, 304, 267, 372, 469, 890, 26, 1559, 14, 362, 63, 4677, 63, 633, 8, 890, 9, 367, 1568, 315, 334, 772, 12, 7960, 6769, 339, 1021, 6288, 26, 267, 1402, 275, 13282, 267, 1504, 275, 788, 344, 297, 283, 2502, 297, 283, 1802, 297, 283, 1782, 63, 1313, 297, 283, 7011, 297, 2116, 283, 16471, 297, 283, 2019, 63, 5334, 297, 283, 7410, 63, 1023, 297, 2116, 283, 7410, 63, 3455, 63, 1023, 297, 283, 18000, 63, 6418, 63, 633, 297, 283, 354, 297, 283, 5464, 297, 2116, 283, 1205, 297, 283, 2580, 297, 1622, 421, 199, 533, 10427, 6382, 7299, 8, 1563, 654, 7299, 12, 13282, 7299, 304, 272, 1021, 6288, 8, 6382, 7299, 14, 3396, 304, 267, 327, 28554, 2222, 13, 3455, 1015, 666, 626, 781, 2793, 1133, 5544, 3877, 315, 10427, 14, 267, 1504, 275, 788, 344, 297, 283, 2502, 297, 283, 1802, 297, 283, 1782, 63, 1313, 297, 283, 7011, 297, 2116, 283, 16471, 297, 283, 2019, 63, 5334, 297, 283, 7410, 63, 3455, 63, 1023, 297, 2116, 283, 18000, 63, 6418, 63, 633, 297, 283, 354, 297, 283, 5464, 297, 283, 1205, 297, 283, 2580, 418, 339, 347, 4026, 63, 785, 8, 277, 12, 666, 304, 267, 408, 2499, 282, 4026, 1256, 402, 13282, 687, 10427, 666, 1041, 267, 1559, 275, 13282, 8, 344, 29, 576, 459, 344, 1105, 267, 666, 459, 3966, 418, 275, 9455, 63, 475, 63, 2083, 8, 576, 459, 3966, 1105, 267, 666, 459, 2019, 63, 5334, 418, 275, 9455, 63, 475, 63, 2083, 8, 576, 459, 2019, 63, 5334, 1105, 267, 666, 459, 5540, 418, 275, 9455, 63, 475, 63, 2083, 8, 576, 459, 5540, 1105, 398, 327, 2790, 282, 4026, 13282, 3353, 367, 8839, 63, 3455, 63, 1023, 14, 267, 340, 666, 459, 7410, 63, 3455, 63, 1023, 2565, 288, 1559, 14, 7410, 63, 3455, 63, 1023, 275, 13282, 3353, 8, 355, 3329, 29, 1113, 12, 355, 1305, 29, 576, 459, 7410, 63, 3455, 63, 1023, 2545, 344, 995, 355, 2737, 29, 397, 63, 475, 63, 2083, 8, 490, 666, 459, 7410, 63, 3455, 63, 1023, 2545, 3966, 3815, 355, 1568, 29, 576, 459, 7410, 63, 3455, 63, 1023, 2278, 362, 360, 890, 297, 378, 395, 355, 2004, 29, 6305, 63, 19476, 12, 355, 1015, 29, 576, 459, 7410, 63, 3455, 63, 1023, 2545, 1023, 995, 9, 398, 327, 2494, 5678, 3004, 781, 7171, 1929, 641, 314, 4026, 1256, 1808, 314, 666, 267, 327, 687, 10427, 14, 267, 291, 423, 5040, 63, 955, 8, 288, 1559, 12, 666, 12, 661, 2502, 297, 283, 3966, 297, 283, 885, 63, 3671, 297, 283, 4677, 63, 2227, 297, 717, 283, 2019, 63, 5334, 297, 283, 5540, 297, 283, 5464, 297, 283, 1205, 297, 717, 283, 1023, 1333, 398, 1559, 14, 6062, 275, 666, 459, 374, 63, 6062, 418, 267, 1559, 14, 7011, 275, 666, 459, 374, 63, 7011, 418, 267, 1559, 14, 2580, 275, 666, 459, 9473, 418, 398, 327, 21328, 15547, 367, 1006, 14598, 3004, 14, 267, 327, 1559, 14, 885, 63, 3671, 1077, 506, 663, 1642, 367, 642, 370, 1736, 14, 267, 291, 423, 5040, 63, 13982, 8, 288, 1559, 12, 666, 12, 661, 354, 297, 283, 1802, 297, 5082, 398, 327, 6601, 3102, 5594, 1929, 314, 3066, 666, 687, 10427, 12, 5324, 652, 641, 1559, 14, 267, 1559, 14, 397, 63, 576, 275, 666, 398, 372, 1559, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4618, 63, 4857, 14, 955, 492, 12064, 12, 3820, 792, 12, 25555, 3767, 792, 199, 504, 4618, 63, 4857, 14, 12844, 492, 5822, 7299, 199, 199, 504, 21825, 14, 1246, 14, 955, 492, 22734, 15792, 12, 25224, 7299, 792, 199, 504, 21825, 14, 5559, 14, 1095, 492, 334, 6305, 63, 16236, 63, 3735, 63, 86, 18, 12, 1816, 18460, 63, 3817, 63, 16236, 63, 3735, 63, 86, 18, 12, 18460, 63, 19476, 9, 199, 504, 21825, 14, 5359, 14, 992, 492, 13282, 12, 13282, 3353, 199, 504, 21825, 14, 1733, 14, 12844, 492, 3523, 654, 7299, 12, 9455, 63, 475, 63, 2083, 421, 199, 533, 13282, 3353, 7299, 8, 1685, 7299, 304, 272, 5235, 63, 633, 275, 12064, 8, 739, 63, 2118, 29, 549, 9, 272, 7381, 63, 4249, 63, 633, 275, 12064, 8, 739, 63, 2118, 29, 549, 9, 272, 11248, 281, 63, 18000, 63, 6418, 63, 633, 275, 12064, 8, 739, 63, 2118, 29, 549, 9, 272, 2004, 275, 22734, 15792, 8, 267, 3415, 63, 807, 29, 6305, 63, 3817, 63, 16236, 63, 3735, 63, 86, 18, 12, 1586, 63, 2118, 29, 549, 9, 339, 1021, 6288, 26, 267, 1402, 275, 13282, 3353, 267, 1504, 275, 788, 344, 297, 283, 3966, 297, 283, 4249, 63, 633, 297, 2116, 283, 23492, 63, 18000, 63, 6418, 63, 633, 297, 283, 2244, 63, 4249, 63, 633, 297, 2116, 283, 890, 297, 283, 1205, 297, 283, 1023, 418, 421, 199, 533, 13282, 7299, 8, 1685, 7299, 304, 272, 1369, 275, 25224, 7299, 792, 8, 739, 63, 2118, 29, 549, 9, 272, 2243, 63, 1313, 275, 3820, 792, 8, 2183, 1062, 1350, 534, 1782, 63, 1247, 358, 272, 7016, 83, 275, 25555, 3767, 792, 342, 272, 8839, 63, 3455, 63, 1023, 275, 13282, 3353, 7299, 8, 739, 63, 2118, 29, 549, 9, 272, 8839, 63, 1023, 275, 13282, 3353, 7299, 8, 739, 63, 2118, 29, 549, 9, 272, 20536, 63, 6418, 63, 633, 275, 12064, 8, 739, 63, 2118, 29, 549, 9, 272, 536, 275, 25224, 7299, 792, 8, 739, 63, 2118, 29, 549, 9, 272, 2004, 275, 22734, 15792, 8, 267, 3415, 63, 807, 29, 6305, 63, 16236, 63, 3735, 63, 86, 18, 12, 1586, 63, 2118, 29, 549, 9, 339, 327, 7600, 26, 8839, 63, 1023, 18994, 23705, 5726, 666, 14, 272, 327, 20550, 30503, 590, 12160, 12, 1325, 11703, 781, 10296, 14, 2832, 282, 13758, 402, 12876, 652, 370, 272, 327, 4573, 6037, 3967, 626, 5121, 4615, 19782, 436, 11248, 1192, 3955, 1929, 272, 327, 370, 675, 626, 1163, 6037, 3140, 402, 314, 5578, 1373, 12, 1325, 11703, 626, 1159, 272, 327, 314, 4340, 370, 2621, 5805, 10314, 6037, 4293, 2387, 1006, 5459, 2256, 12, 4634, 14, 339, 347, 664, 63, 16471, 8, 277, 12, 1559, 304, 267, 372, 469, 890, 26, 1559, 14, 362, 63, 4677, 63, 633, 8, 890, 9, 367, 1568, 315, 334, 772, 12, 7960, 6769, 339, 1021, 6288, 26, 267, 1402, 275, 13282, 267, 1504, 275, 788, 344, 297, 283, 2502, 297, 283, 1802, 297, 283, 1782, 63, 1313, 297, 283, 7011, 297, 2116, 283, 16471, 297, 283, 2019, 63, 5334, 297, 283, 7410, 63, 1023, 297, 2116, 283, 7410, 63, 3455, 63, 1023, 297, 283, 18000, 63, 6418, 63, 633, 297, 283, 354, 297, 283, 5464, 297, 2116, 283, 1205, 297, 283, 2580, 297, 1622, 421, 199, 533, 10427, 6382, 7299, 8, 1563, 654, 7299, 12, 13282, 7299, 304, 272, 1021, 6288, 8, 6382, 7299, 14, 3396, 304, 267, 327, 28554, 2222, 13, 3455, 1015, 666, 626, 781, 2793, 1133, 5544, 3877, 315, 10427, 14, 267, 1504, 275, 788, 344, 297, 283, 2502, 297, 283, 1802, 297, 283, 1782, 63, 1313, 297, 283, 7011, 297, 2116, 283, 16471, 297, 283, 2019, 63, 5334, 297, 283, 7410, 63, 3455, 63, 1023, 297, 2116, 283, 18000, 63, 6418, 63, 633, 297, 283, 354, 297, 283, 5464, 297, 283, 1205, 297, 283, 2580, 418, 339, 347, 4026, 63, 785, 8, 277, 12, 666, 304, 267, 408, 2499, 282, 4026, 1256, 402, 13282, 687, 10427, 666, 1041, 267, 1559, 275, 13282, 8, 344, 29, 576, 459, 344, 1105, 267, 666, 459, 3966, 418, 275, 9455, 63, 475, 63, 2083, 8, 576, 459, 3966, 1105, 267, 666, 459, 2019, 63, 5334, 418, 275, 9455, 63, 475, 63, 2083, 8, 576, 459, 2019, 63, 5334, 1105, 267, 666, 459, 5540, 418, 275, 9455, 63, 475, 63, 2083, 8, 576, 459, 5540, 1105, 398, 327, 2790, 282, 4026, 13282, 3353, 367, 8839, 63, 3455, 63, 1023, 14, 267, 340, 666, 459, 7410, 63, 3455, 63, 1023, 2565, 288, 1559, 14, 7410, 63, 3455, 63, 1023, 275, 13282, 3353, 8, 355, 3329, 29, 1113, 12, 355, 1305, 29, 576, 459, 7410, 63, 3455, 63, 1023, 2545, 344, 995, 355, 2737, 29, 397, 63, 475, 63, 2083, 8, 490, 666, 459, 7410, 63, 3455, 63, 1023, 2545, 3966, 3815, 355, 1568, 29, 576, 459, 7410, 63, 3455, 63, 1023, 2278, 362, 360, 890, 297, 378, 395, 355, 2004, 29, 6305, 63, 19476, 12, 355, 1015, 29, 576, 459, 7410, 63, 3455, 63, 1023, 2545, 1023, 995, 9, 398, 327, 2494, 5678, 3004, 781, 7171, 1929, 641, 314, 4026, 1256, 1808, 314, 666, 267, 327, 687, 10427, 14, 267, 291, 423, 5040, 63, 955, 8, 288, 1559, 12, 666, 12, 661, 2502, 297, 283, 3966, 297, 283, 885, 63, 3671, 297, 283, 4677, 63, 2227, 297, 717, 283, 2019, 63, 5334, 297, 283, 5540, 297, 283, 5464, 297, 283, 1205, 297, 717, 283, 1023, 1333, 398, 1559, 14, 6062, 275, 666, 459, 374, 63, 6062, 418, 267, 1559, 14, 7011, 275, 666, 459, 374, 63, 7011, 418, 267, 1559, 14, 2580, 275, 666, 459, 9473, 418, 398, 327, 21328, 15547, 367, 1006, 14598, 3004, 14, 267, 327, 1559, 14, 885, 63, 3671, 1077, 506, 663, 1642, 367, 642, 370, 1736, 14, 267, 291, 423, 5040, 63, 13982, 8, 288, 1559, 12, 666, 12, 661, 354, 297, 283, 1802, 297, 5082, 398, 327, 6601, 3102, 5594, 1929, 314, 3066, 666, 687, 10427, 12, 5324, 652, 641, 1559, 14, 267, 1559, 14, 397, 63, 576, 275, 666, 398, 372, 1559, 199, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0 ]
davidjb/sqlalchemy
lib/sqlalchemy/testing/plugin/noseplugin.py
58
2847
# plugin/noseplugin.py # Copyright (C) 2005-2015 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 """Enhance nose with extra options and behaviors for running SQLAlchemy tests. Must be run via ./sqla_nose.py so that it is imported in the expected way (e.g. as a package-less import). """ try: # installed by bootstrap.py import sqla_plugin_base as plugin_base except ImportError: # assume we're a package, use traditional import from . import plugin_base import os import sys from nose.plugins import Plugin import nose fixtures = None py3k = sys.version_info >= (3, 0) class NoseSQLAlchemy(Plugin): enabled = True name = 'sqla_testing' score = 100 def options(self, parser, env=os.environ): Plugin.options(self, parser, env) opt = parser.add_option def make_option(name, **kw): callback_ = kw.pop("callback", None) if callback_: def wrap_(option, opt_str, value, parser): callback_(opt_str, value, parser) kw["callback"] = wrap_ opt(name, **kw) plugin_base.setup_options(make_option) plugin_base.read_config() def configure(self, options, conf): super(NoseSQLAlchemy, self).configure(options, conf) plugin_base.pre_begin(options) plugin_base.set_coverage_flag(options.enable_plugin_coverage) plugin_base.set_skip_test(nose.SkipTest) def begin(self): global fixtures from sqlalchemy.testing import fixtures # noqa plugin_base.post_begin() def describeTest(self, test): return "" def wantFunction(self, fn): return False def wantMethod(self, fn): if py3k: if not hasattr(fn.__self__, 'cls'): return False cls = fn.__self__.cls else: cls = fn.im_class return plugin_base.want_method(cls, fn) def wantClass(self, cls): return plugin_base.want_class(cls) def beforeTest(self, test): if not hasattr(test.test, 'cls'): return plugin_base.before_test( test, test.test.cls.__module__, test.test.cls, test.test.method.__name__) def afterTest(self, test): plugin_base.after_test(test) def startContext(self, ctx): if not isinstance(ctx, type) \ or not issubclass(ctx, fixtures.TestBase): return plugin_base.start_test_class(ctx) def stopContext(self, ctx): if not isinstance(ctx, type) \ or not issubclass(ctx, fixtures.TestBase): return plugin_base.stop_test_class(ctx)
mit
[ 3, 3589, 15, 21085, 2718, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7806, 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, 1327, 14666, 11354, 543, 2402, 1511, 436, 5112, 1384, 367, 3879, 14303, 2295, 14, 199, 199, 13757, 506, 1255, 4799, 16605, 3526, 416, 63, 21085, 14, 647, 880, 626, 652, 365, 8439, 315, 314, 1420, 199, 3316, 334, 69, 14, 71, 14, 465, 282, 2559, 13, 2003, 492, 680, 199, 199, 624, 199, 199, 893, 26, 272, 327, 4903, 701, 15865, 14, 647, 272, 492, 5295, 416, 63, 2718, 63, 1095, 465, 3589, 63, 1095, 199, 2590, 3545, 26, 272, 327, 5534, 781, 3984, 282, 2559, 12, 675, 1468, 2603, 492, 272, 687, 1275, 492, 3589, 63, 1095, 421, 199, 646, 747, 199, 646, 984, 199, 199, 504, 11354, 14, 5265, 492, 11349, 199, 646, 11354, 199, 8769, 275, 488, 199, 199, 647, 19, 75, 275, 984, 14, 1023, 63, 815, 2356, 334, 19, 12, 378, 9, 421, 199, 533, 3091, 261, 4657, 12800, 8, 5061, 304, 272, 5223, 275, 715, 339, 536, 275, 283, 3526, 416, 63, 4776, 7, 272, 5396, 275, 2948, 339, 347, 1511, 8, 277, 12, 1798, 12, 2589, 29, 736, 14, 2314, 304, 267, 11349, 14, 1419, 8, 277, 12, 1798, 12, 2589, 9, 267, 2450, 275, 1798, 14, 525, 63, 1422, 398, 347, 1852, 63, 1422, 8, 354, 12, 1011, 829, 304, 288, 3233, 63, 275, 4775, 14, 1935, 480, 3058, 401, 488, 9, 288, 340, 3233, 10388, 355, 347, 4816, 2531, 1422, 12, 2450, 63, 495, 12, 574, 12, 1798, 304, 490, 3233, 2531, 2992, 63, 495, 12, 574, 12, 1798, 9, 355, 4775, 905, 3058, 937, 275, 4816, 63, 288, 2450, 8, 354, 12, 1011, 829, 9, 398, 3589, 63, 1095, 14, 2758, 63, 1419, 8, 1875, 63, 1422, 9, 267, 3589, 63, 1095, 14, 739, 63, 888, 342, 339, 347, 7908, 8, 277, 12, 1511, 12, 3743, 304, 267, 1613, 8, 1944, 261, 4657, 12800, 12, 291, 680, 6472, 8, 1419, 12, 3743, 9, 267, 3589, 63, 1095, 14, 657, 63, 5037, 8, 1419, 9, 398, 3589, 63, 1095, 14, 409, 63, 10828, 63, 4173, 8, 1419, 14, 4296, 63, 2718, 63, 10828, 9, 398, 3589, 63, 1095, 14, 409, 63, 2759, 63, 396, 8, 21085, 14, 25755, 9, 339, 347, 5386, 8, 277, 304, 267, 2288, 15188, 267, 687, 8335, 14, 4776, 492, 15188, 221, 327, 8151, 398, 3589, 63, 1095, 14, 1932, 63, 5037, 342, 339, 347, 13743, 774, 8, 277, 12, 511, 304, 267, 372, 3087, 339, 347, 2934, 3481, 8, 277, 12, 4325, 304, 267, 372, 756, 339, 347, 2934, 3767, 8, 277, 12, 4325, 304, 267, 340, 1134, 19, 75, 26, 288, 340, 440, 2688, 8, 2324, 855, 277, 3108, 283, 1886, 735, 355, 372, 756, 288, 843, 275, 4325, 855, 277, 4343, 1886, 267, 587, 26, 288, 843, 275, 4325, 14, 1017, 63, 533, 267, 372, 3589, 63, 1095, 14, 7051, 63, 765, 8, 1886, 12, 4325, 9, 339, 347, 2934, 2543, 8, 277, 12, 843, 304, 267, 372, 3589, 63, 1095, 14, 7051, 63, 533, 8, 1886, 9, 339, 347, 2544, 774, 8, 277, 12, 511, 304, 267, 340, 440, 2688, 8, 396, 14, 396, 12, 283, 1886, 735, 288, 372, 267, 3589, 63, 1095, 14, 5182, 63, 396, 8, 288, 511, 12, 288, 511, 14, 396, 14, 1886, 855, 578, 3108, 288, 511, 14, 396, 14, 1886, 12, 511, 14, 396, 14, 765, 855, 354, 3368, 339, 347, 2410, 774, 8, 277, 12, 511, 304, 267, 3589, 63, 1095, 14, 4399, 63, 396, 8, 396, 9, 339, 347, 1343, 2998, 8, 277, 12, 4027, 304, 267, 340, 440, 1228, 8, 3799, 12, 730, 9, 971, 355, 503, 440, 11602, 8, 3799, 12, 15188, 14, 14440, 304, 288, 372, 267, 3589, 63, 1095, 14, 928, 63, 396, 63, 533, 8, 3799, 9, 339, 347, 3631, 2998, 8, 277, 12, 4027, 304, 267, 340, 440, 1228, 8, 3799, 12, 730, 9, 971, 355, 503, 440, 11602, 8, 3799, 12, 15188, 14, 14440, 304, 288, 372, 267, 3589, 63, 1095, 14, 2379, 63, 396, 63, 533, 8, 3799, 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 ]
[ 3589, 15, 21085, 2718, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7806, 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, 1327, 14666, 11354, 543, 2402, 1511, 436, 5112, 1384, 367, 3879, 14303, 2295, 14, 199, 199, 13757, 506, 1255, 4799, 16605, 3526, 416, 63, 21085, 14, 647, 880, 626, 652, 365, 8439, 315, 314, 1420, 199, 3316, 334, 69, 14, 71, 14, 465, 282, 2559, 13, 2003, 492, 680, 199, 199, 624, 199, 199, 893, 26, 272, 327, 4903, 701, 15865, 14, 647, 272, 492, 5295, 416, 63, 2718, 63, 1095, 465, 3589, 63, 1095, 199, 2590, 3545, 26, 272, 327, 5534, 781, 3984, 282, 2559, 12, 675, 1468, 2603, 492, 272, 687, 1275, 492, 3589, 63, 1095, 421, 199, 646, 747, 199, 646, 984, 199, 199, 504, 11354, 14, 5265, 492, 11349, 199, 646, 11354, 199, 8769, 275, 488, 199, 199, 647, 19, 75, 275, 984, 14, 1023, 63, 815, 2356, 334, 19, 12, 378, 9, 421, 199, 533, 3091, 261, 4657, 12800, 8, 5061, 304, 272, 5223, 275, 715, 339, 536, 275, 283, 3526, 416, 63, 4776, 7, 272, 5396, 275, 2948, 339, 347, 1511, 8, 277, 12, 1798, 12, 2589, 29, 736, 14, 2314, 304, 267, 11349, 14, 1419, 8, 277, 12, 1798, 12, 2589, 9, 267, 2450, 275, 1798, 14, 525, 63, 1422, 398, 347, 1852, 63, 1422, 8, 354, 12, 1011, 829, 304, 288, 3233, 63, 275, 4775, 14, 1935, 480, 3058, 401, 488, 9, 288, 340, 3233, 10388, 355, 347, 4816, 2531, 1422, 12, 2450, 63, 495, 12, 574, 12, 1798, 304, 490, 3233, 2531, 2992, 63, 495, 12, 574, 12, 1798, 9, 355, 4775, 905, 3058, 937, 275, 4816, 63, 288, 2450, 8, 354, 12, 1011, 829, 9, 398, 3589, 63, 1095, 14, 2758, 63, 1419, 8, 1875, 63, 1422, 9, 267, 3589, 63, 1095, 14, 739, 63, 888, 342, 339, 347, 7908, 8, 277, 12, 1511, 12, 3743, 304, 267, 1613, 8, 1944, 261, 4657, 12800, 12, 291, 680, 6472, 8, 1419, 12, 3743, 9, 267, 3589, 63, 1095, 14, 657, 63, 5037, 8, 1419, 9, 398, 3589, 63, 1095, 14, 409, 63, 10828, 63, 4173, 8, 1419, 14, 4296, 63, 2718, 63, 10828, 9, 398, 3589, 63, 1095, 14, 409, 63, 2759, 63, 396, 8, 21085, 14, 25755, 9, 339, 347, 5386, 8, 277, 304, 267, 2288, 15188, 267, 687, 8335, 14, 4776, 492, 15188, 221, 327, 8151, 398, 3589, 63, 1095, 14, 1932, 63, 5037, 342, 339, 347, 13743, 774, 8, 277, 12, 511, 304, 267, 372, 3087, 339, 347, 2934, 3481, 8, 277, 12, 4325, 304, 267, 372, 756, 339, 347, 2934, 3767, 8, 277, 12, 4325, 304, 267, 340, 1134, 19, 75, 26, 288, 340, 440, 2688, 8, 2324, 855, 277, 3108, 283, 1886, 735, 355, 372, 756, 288, 843, 275, 4325, 855, 277, 4343, 1886, 267, 587, 26, 288, 843, 275, 4325, 14, 1017, 63, 533, 267, 372, 3589, 63, 1095, 14, 7051, 63, 765, 8, 1886, 12, 4325, 9, 339, 347, 2934, 2543, 8, 277, 12, 843, 304, 267, 372, 3589, 63, 1095, 14, 7051, 63, 533, 8, 1886, 9, 339, 347, 2544, 774, 8, 277, 12, 511, 304, 267, 340, 440, 2688, 8, 396, 14, 396, 12, 283, 1886, 735, 288, 372, 267, 3589, 63, 1095, 14, 5182, 63, 396, 8, 288, 511, 12, 288, 511, 14, 396, 14, 1886, 855, 578, 3108, 288, 511, 14, 396, 14, 1886, 12, 511, 14, 396, 14, 765, 855, 354, 3368, 339, 347, 2410, 774, 8, 277, 12, 511, 304, 267, 3589, 63, 1095, 14, 4399, 63, 396, 8, 396, 9, 339, 347, 1343, 2998, 8, 277, 12, 4027, 304, 267, 340, 440, 1228, 8, 3799, 12, 730, 9, 971, 355, 503, 440, 11602, 8, 3799, 12, 15188, 14, 14440, 304, 288, 372, 267, 3589, 63, 1095, 14, 928, 63, 396, 63, 533, 8, 3799, 9, 339, 347, 3631, 2998, 8, 277, 12, 4027, 304, 267, 340, 440, 1228, 8, 3799, 12, 730, 9, 971, 355, 503, 440, 11602, 8, 3799, 12, 15188, 14, 14440, 304, 288, 372, 267, 3589, 63, 1095, 14, 2379, 63, 396, 63, 533, 8, 3799, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
anna-ka/nlptools-ru
nlptools2/pickling.py
4
5306
#!/usr/bin/python # -*- coding: utf-8 -*- from collections import defaultdict import pickle # Функции-обертки для загрузки/выгрузки многоуровневых словарей с помощью модуля cPickle (Python 2.7) def inner_lambda_float(): """ Обертка для lambda (одноуровневая, float) """ return defaultdict(float) def inner_lambda_int(): """ Обертка для lambda (одноуровневая, int) """ return defaultdict(int) def inner_lambda_str(): """ Обертка для lambda (одноуровневая, str) """ return defaultdict(str) def inner_lambda_set(): """ Обертка для lambda (одноуровневая, set) """ return defaultdict(set) def inner_lambda_tuple(): """ Обертка для lambda (одноуровневая, tuple) """ return defaultdict(tuple) def inner_func_float(): """ Обертка для lambda (двухуровневая, float) """ return defaultdict(inner_lambda_float) def inner_func_tuple(): """ Обертка для lambda (двухуровневая, tuple) """ return defaultdict(inner_lambda_tuple) def inner_func_float2(): """ Обертка для lambda (треххуровневая, float) """ return defaultdict(inner_func_float) def inner_func_int(): """ Обертка для lambda (двухуровневая, int) """ return defaultdict(inner_lambda_int) def inner_func_str(): """ Обертка для lambda (двухуровневая, str) """ return defaultdict(inner_lambda_str) def inner_func_set(): """ Обертка для lambda (двухуровневая, set) """ return defaultdict(inner_lambda_set) def unpkl_1layered_f(picklefreqs): """ Подгружает одноуровневый словарь типа float """ freqs = defaultdict(float) with open(picklefreqs, "rb") as fin: freqs = pickle.load(fin) return freqs def unpkl_1layered_i(picklefreqs): """ Подгружает одноуровневый словарь типа int """ freqs = defaultdict(int) with open(picklefreqs, "rb") as fin: freqs = pickle.load(fin) return freqs def unpkl_1layered_s(picklefreqs): """ Подгружает одноуровневый словарь типа str """ freqs = defaultdict(str) with open(picklefreqs, "rb") as fin: freqs = pickle.load(fin) return freqs def unpkl_1layered_sets(picklefreqs): """ Подгружает одноуровневый словарь типа set """ sets = defaultdict(set) with open(picklefreqs, "rb") as fin: sets = pickle.load(fin) return sets def unpkl_2layered_f(picklefile): """ Подгружает двухуровневый словарь типа float """ freqs = defaultdict(inner_lambda_float) with open(picklefile, "rb") as fin: freqs = pickle.load(fin) return freqs def unpkl_2layered_i(picklefile): """ Подгружает двухуровневый словарь типа int """ freqs = defaultdict(inner_lambda_int) with open(picklefile, "rb") as fin: freqs = pickle.load(fin) return freqs def unpkl_2layered_s(picklefile): """ Подгружает двухуровневый словарь типа str """ words = defaultdict(inner_lambda_str) with open(picklefile, "rb") as fin: words = pickle.load(fin) return words def unpkl_2layered_set(picklefile): """ Подгружает двухуровневый словарь типа set """ words = defaultdict(inner_lambda_set) with open(picklefile, "rb") as fin: words = pickle.load(fin) return words def unpkl_2layered_tuple(picklefile): """ Подгружает двухуровневый словарь типа tuple """ words = defaultdict(inner_lambda_tuple) with open(picklefile, "rb") as fin: words = pickle.load(fin) return words def unpkl_3layered_i(picklefile): """ Подгружает трехуровневый словарь типа int """ freqs = defaultdict(inner_func_int) with open(picklefile, "rb") as fin: freqs = pickle.load(fin) return freqs def unpkl_3layered_f(picklefile): """ Подгружает трехуровневый словарь типа float """ freqs = defaultdict(inner_func_float) with open(picklefile, "rb") as fin: freqs = pickle.load(fin) return freqs def unpkl_set(picklefile): """ Подгружает множество """ wordset = set() with open(picklefile, "rb") as fin: wordset = pickle.load(fin) return wordset def dump_data(filename, data): """ Сериализация """ with open(filename, "wb") as fout: pickle.dump(data, fout, pickle.HIGHEST_PROTOCOL) return True
mit
[ 3381, 2647, 15, 1393, 15, 1548, 202, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 2999, 199, 504, 5055, 492, 10018, 202, 199, 646, 5927, 2999, 199, 3, 7038, 98, 12195, 7592, 11487, 25827, 6500, 6500, 13, 8381, 110, 21273, 7413, 11487, 6500, 29562, 10356, 14978, 7038, 116, 13111, 112, 7753, 12195, 31027, 11487, 6500, 15, 19630, 17445, 141, 112, 7753, 12195, 31027, 11487, 6500, 7038, 121, 7592, 8381, 112, 5806, 12195, 7753, 21267, 7592, 15578, 111, 17445, 25969, 24071, 10356, 21267, 27559, 15578, 118, 24071, 19820, 32334, 5806, 142, 232, 16961, 31235, 7038, 121, 28711, 12195, 10356, 14978, 17572, 334, 4718, 499, 14, 23, 9, 2999, 199, 318, 6506, 63, 2734, 63, 1609, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 2069, 9, 1128, 408, 1128, 372, 10018, 8, 1609, 9, 2999, 199, 318, 6506, 63, 2734, 63, 442, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 1109, 9, 1128, 408, 1128, 372, 10018, 8, 442, 9, 2999, 199, 318, 6506, 63, 2734, 63, 495, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 620, 9, 1128, 408, 1128, 372, 10018, 8, 495, 9, 2999, 199, 318, 6506, 63, 2734, 63, 409, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 663, 9, 1128, 408, 1128, 372, 10018, 8, 409, 9, 2999, 199, 318, 6506, 63, 2734, 63, 2960, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 2008, 9, 1128, 408, 1128, 372, 10018, 8, 2960, 9, 2999, 199, 318, 6506, 63, 1532, 63, 1609, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 20497, 19630, 12195, 25969, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 2069, 9, 1128, 408, 1128, 372, 10018, 8, 5216, 63, 2734, 63, 1609, 9, 2999, 199, 318, 6506, 63, 1532, 63, 2960, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 20497, 19630, 12195, 25969, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 2008, 9, 1128, 408, 1128, 372, 10018, 8, 5216, 63, 2734, 63, 2960, 9, 2999, 199, 318, 6506, 63, 1532, 63, 1609, 18, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 7413, 7753, 6286, 25969, 25969, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 2069, 9, 1128, 408, 1128, 372, 10018, 8, 5216, 63, 1532, 63, 1609, 9, 2999, 199, 318, 6506, 63, 1532, 63, 442, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 20497, 19630, 12195, 25969, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 1109, 9, 1128, 408, 1128, 372, 10018, 8, 5216, 63, 2734, 63, 442, 9, 2999, 199, 318, 6506, 63, 1532, 63, 495, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 20497, 19630, 12195, 25969, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 620, 9, 1128, 408, 1128, 372, 10018, 8, 5216, 63, 2734, 63, 495, 9, 2999, 199, 318, 6506, 63, 1532, 63, 409, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 20497, 19630, 12195, 25969, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 663, 9, 1128, 408, 1128, 372, 10018, 8, 5216, 63, 2734, 63, 409, 9, 2999, 199, 318, 625, 23947, 63, 17, 817, 16179, 63, 70, 8, 8092, 28557, 304, 1128, 408, 1128, 7038, 254, 28711, 141, 112, 7753, 12195, 141, 115, 5657, 30160, 221, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 17445, 141, 118, 24071, 10356, 21267, 27559, 16961, 221, 7413, 16863, 124, 5657, 2069, 1128, 408, 1128, 9220, 83, 275, 10018, 8, 1609, 9, 1128, 543, 1551, 8, 8092, 28557, 12, 298, 4848, 531, 465, 2583, 26, 1039, 9220, 83, 275, 5927, 14, 912, 8, 2408, 9, 1128, 372, 9220, 83, 10292, 202, 199, 318, 625, 23947, 63, 17, 817, 16179, 63, 73, 8, 8092, 28557, 304, 1128, 408, 1128, 7038, 254, 28711, 141, 112, 7753, 12195, 141, 115, 5657, 30160, 221, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 17445, 141, 118, 24071, 10356, 21267, 27559, 16961, 221, 7413, 16863, 124, 5657, 1109, 1128, 408, 1128, 9220, 83, 275, 10018, 8, 442, 9, 1128, 543, 1551, 8, 8092, 28557, 12, 298, 4848, 531, 465, 2583, 26, 1039, 9220, 83, 275, 5927, 14, 912, 8, 2408, 9, 1128, 372, 9220, 83, 2999, 199, 318, 625, 23947, 63, 17, 817, 16179, 63, 83, 8, 8092, 28557, 304, 1128, 408, 1128, 7038, 254, 28711, 141, 112, 7753, 12195, 141, 115, 5657, 30160, 221, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 17445, 141, 118, 24071, 10356, 21267, 27559, 16961, 221, 7413, 16863, 124, 5657, 620, 1128, 408, 1128, 9220, 83, 275, 10018, 8, 495, 9, 1128, 543, 1551, 8, 8092, 28557, 12, 298, 4848, 531, 465, 2583, 26, 1039, 9220, 83, 275, 5927, 14, 912, 8, 2408, 9, 1128, 372, 9220, 83, 2999, 199, 318, 625, 23947, 63, 17, 817, 16179, 63, 2193, 8, 8092, 28557, 304, 1128, 408, 1128, 7038, 254, 28711, 141, 112, 7753, 12195, 141, 115, 5657, 30160, 221, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 17445, 141, 118, 24071, 10356, 21267, 27559, 16961, 221, 7413, 16863, 124, 5657, 663, 1128, 408, 1128, 5951, 275, 10018, 8, 409, 9, 1128, 543, 1551, 8, 8092, 28557, 12, 298, 4848, 531, 465, 2583, 26, 1039, 5951, 275, 5927, 14, 912, 8, 2408, 9, 1128, 372, 5951, 2999, 199, 318, 625, 23947, 63, 18, 817, 16179, 63, 70, 8, 8092, 493, 304, 1128, 408, 1128, 7038, 254, 28711 ]
[ 2647, 15, 1393, 15, 1548, 202, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 2999, 199, 504, 5055, 492, 10018, 202, 199, 646, 5927, 2999, 199, 3, 7038, 98, 12195, 7592, 11487, 25827, 6500, 6500, 13, 8381, 110, 21273, 7413, 11487, 6500, 29562, 10356, 14978, 7038, 116, 13111, 112, 7753, 12195, 31027, 11487, 6500, 15, 19630, 17445, 141, 112, 7753, 12195, 31027, 11487, 6500, 7038, 121, 7592, 8381, 112, 5806, 12195, 7753, 21267, 7592, 15578, 111, 17445, 25969, 24071, 10356, 21267, 27559, 15578, 118, 24071, 19820, 32334, 5806, 142, 232, 16961, 31235, 7038, 121, 28711, 12195, 10356, 14978, 17572, 334, 4718, 499, 14, 23, 9, 2999, 199, 318, 6506, 63, 2734, 63, 1609, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 2069, 9, 1128, 408, 1128, 372, 10018, 8, 1609, 9, 2999, 199, 318, 6506, 63, 2734, 63, 442, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 1109, 9, 1128, 408, 1128, 372, 10018, 8, 442, 9, 2999, 199, 318, 6506, 63, 2734, 63, 495, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 620, 9, 1128, 408, 1128, 372, 10018, 8, 495, 9, 2999, 199, 318, 6506, 63, 2734, 63, 409, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 663, 9, 1128, 408, 1128, 372, 10018, 8, 409, 9, 2999, 199, 318, 6506, 63, 2734, 63, 2960, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 2008, 9, 1128, 408, 1128, 372, 10018, 8, 2960, 9, 2999, 199, 318, 6506, 63, 1532, 63, 1609, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 20497, 19630, 12195, 25969, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 2069, 9, 1128, 408, 1128, 372, 10018, 8, 5216, 63, 2734, 63, 1609, 9, 2999, 199, 318, 6506, 63, 1532, 63, 2960, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 20497, 19630, 12195, 25969, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 2008, 9, 1128, 408, 1128, 372, 10018, 8, 5216, 63, 2734, 63, 2960, 9, 2999, 199, 318, 6506, 63, 1532, 63, 1609, 18, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 7413, 7753, 6286, 25969, 25969, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 2069, 9, 1128, 408, 1128, 372, 10018, 8, 5216, 63, 1532, 63, 1609, 9, 2999, 199, 318, 6506, 63, 1532, 63, 442, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 20497, 19630, 12195, 25969, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 1109, 9, 1128, 408, 1128, 372, 10018, 8, 5216, 63, 2734, 63, 442, 9, 2999, 199, 318, 6506, 63, 1532, 63, 495, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 20497, 19630, 12195, 25969, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 620, 9, 1128, 408, 1128, 372, 10018, 8, 5216, 63, 2734, 63, 495, 9, 2999, 199, 318, 6506, 63, 1532, 63, 409, 837, 1128, 408, 1128, 7038, 253, 141, 110, 21273, 7413, 29352, 29562, 10356, 14978, 2400, 334, 20497, 19630, 12195, 25969, 12195, 7753, 21267, 7592, 15578, 111, 5657, 14978, 12, 663, 9, 1128, 408, 1128, 372, 10018, 8, 5216, 63, 2734, 63, 409, 9, 2999, 199, 318, 625, 23947, 63, 17, 817, 16179, 63, 70, 8, 8092, 28557, 304, 1128, 408, 1128, 7038, 254, 28711, 141, 112, 7753, 12195, 141, 115, 5657, 30160, 221, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 17445, 141, 118, 24071, 10356, 21267, 27559, 16961, 221, 7413, 16863, 124, 5657, 2069, 1128, 408, 1128, 9220, 83, 275, 10018, 8, 1609, 9, 1128, 543, 1551, 8, 8092, 28557, 12, 298, 4848, 531, 465, 2583, 26, 1039, 9220, 83, 275, 5927, 14, 912, 8, 2408, 9, 1128, 372, 9220, 83, 10292, 202, 199, 318, 625, 23947, 63, 17, 817, 16179, 63, 73, 8, 8092, 28557, 304, 1128, 408, 1128, 7038, 254, 28711, 141, 112, 7753, 12195, 141, 115, 5657, 30160, 221, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 17445, 141, 118, 24071, 10356, 21267, 27559, 16961, 221, 7413, 16863, 124, 5657, 1109, 1128, 408, 1128, 9220, 83, 275, 10018, 8, 442, 9, 1128, 543, 1551, 8, 8092, 28557, 12, 298, 4848, 531, 465, 2583, 26, 1039, 9220, 83, 275, 5927, 14, 912, 8, 2408, 9, 1128, 372, 9220, 83, 2999, 199, 318, 625, 23947, 63, 17, 817, 16179, 63, 83, 8, 8092, 28557, 304, 1128, 408, 1128, 7038, 254, 28711, 141, 112, 7753, 12195, 141, 115, 5657, 30160, 221, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 17445, 141, 118, 24071, 10356, 21267, 27559, 16961, 221, 7413, 16863, 124, 5657, 620, 1128, 408, 1128, 9220, 83, 275, 10018, 8, 495, 9, 1128, 543, 1551, 8, 8092, 28557, 12, 298, 4848, 531, 465, 2583, 26, 1039, 9220, 83, 275, 5927, 14, 912, 8, 2408, 9, 1128, 372, 9220, 83, 2999, 199, 318, 625, 23947, 63, 17, 817, 16179, 63, 2193, 8, 8092, 28557, 304, 1128, 408, 1128, 7038, 254, 28711, 141, 112, 7753, 12195, 141, 115, 5657, 30160, 221, 28711, 7592, 5806, 12195, 7753, 21267, 7592, 15578, 111, 17445, 141, 118, 24071, 10356, 21267, 27559, 16961, 221, 7413, 16863, 124, 5657, 663, 1128, 408, 1128, 5951, 275, 10018, 8, 409, 9, 1128, 543, 1551, 8, 8092, 28557, 12, 298, 4848, 531, 465, 2583, 26, 1039, 5951, 275, 5927, 14, 912, 8, 2408, 9, 1128, 372, 5951, 2999, 199, 318, 625, 23947, 63, 18, 817, 16179, 63, 70, 8, 8092, 493, 304, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ClovisIRex/Snake-django
env/lib/python3.6/site-packages/django/contrib/messages/storage/fallback.py
704
2172
from django.contrib.messages.storage.base import BaseStorage from django.contrib.messages.storage.cookie import CookieStorage from django.contrib.messages.storage.session import SessionStorage class FallbackStorage(BaseStorage): """ Tries to store all messages in the first backend, storing any unstored messages in each subsequent backend backend. """ storage_classes = (CookieStorage, SessionStorage) def __init__(self, *args, **kwargs): super(FallbackStorage, self).__init__(*args, **kwargs) self.storages = [storage_class(*args, **kwargs) for storage_class in self.storage_classes] self._used_storages = set() def _get(self, *args, **kwargs): """ Gets a single list of messages from all storage backends. """ all_messages = [] for storage in self.storages: messages, all_retrieved = storage._get() # If the backend hasn't been used, no more retrieval is necessary. if messages is None: break if messages: self._used_storages.add(storage) all_messages.extend(messages) # If this storage class contained all the messages, no further # retrieval is necessary if all_retrieved: break return all_messages, all_retrieved def _store(self, messages, response, *args, **kwargs): """ Stores the messages, returning any unstored messages after trying all backends. For each storage backend, any messages not stored are passed on to the next backend. """ for storage in self.storages: if messages: messages = storage._store(messages, response, remove_oldest=False) # Even if there are no more messages, continue iterating to ensure # storages which contained messages are flushed. elif storage in self._used_storages: storage._store([], response) self._used_storages.remove(storage) return messages
mit
[ 504, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 1095, 492, 3523, 6408, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 5306, 492, 14798, 6408, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 1730, 492, 8596, 6408, 421, 199, 533, 481, 5421, 6408, 8, 1563, 6408, 304, 272, 408, 272, 377, 1996, 370, 3877, 1006, 3788, 315, 314, 1642, 4865, 12, 16915, 1263, 625, 16431, 272, 3788, 315, 1924, 13372, 4865, 4865, 14, 272, 408, 272, 4887, 63, 2888, 275, 334, 7810, 6408, 12, 8596, 6408, 9, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 21860, 6408, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 3494, 83, 275, 359, 3494, 63, 533, 2031, 589, 12, 1011, 958, 9, 586, 367, 4887, 63, 533, 315, 291, 14, 3494, 63, 2888, 61, 267, 291, 423, 2972, 63, 3494, 83, 275, 663, 342, 339, 347, 485, 362, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 14509, 282, 2849, 769, 402, 3788, 687, 1006, 4887, 14745, 14, 267, 408, 267, 1006, 63, 3431, 275, 942, 267, 367, 4887, 315, 291, 14, 3494, 83, 26, 288, 3788, 12, 1006, 63, 11235, 27986, 275, 4887, 423, 362, 342, 288, 327, 982, 314, 4865, 18699, 1133, 2757, 1202, 12, 949, 1655, 27157, 365, 5784, 14, 288, 340, 3788, 365, 488, 26, 355, 2059, 288, 340, 3788, 26, 355, 291, 423, 2972, 63, 3494, 83, 14, 525, 8, 3494, 9, 288, 1006, 63, 3431, 14, 2880, 8, 3431, 9, 288, 327, 982, 642, 4887, 1021, 10470, 1006, 314, 3788, 12, 949, 9848, 288, 327, 27157, 365, 5784, 288, 340, 1006, 63, 11235, 27986, 26, 355, 2059, 267, 372, 1006, 63, 3431, 12, 1006, 63, 11235, 27986, 339, 347, 485, 1617, 8, 277, 12, 3788, 12, 1177, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 31299, 314, 3788, 12, 8152, 1263, 625, 16431, 3788, 2410, 9936, 1006, 267, 14745, 14, 398, 2104, 1924, 4887, 4865, 12, 1263, 3788, 440, 5489, 787, 3032, 641, 370, 314, 267, 2163, 4865, 14, 267, 408, 267, 367, 4887, 315, 291, 14, 3494, 83, 26, 288, 340, 3788, 26, 355, 3788, 275, 4887, 423, 1617, 8, 3431, 12, 1177, 12, 5101, 2813, 63, 393, 2614, 29, 797, 9, 288, 327, 22207, 340, 2337, 787, 949, 1655, 3788, 12, 1980, 25012, 370, 4868, 288, 327, 4887, 83, 1314, 10470, 3788, 787, 8976, 379, 14, 288, 916, 4887, 315, 291, 423, 2972, 63, 3494, 83, 26, 355, 4887, 423, 1617, 8798, 1177, 9, 355, 291, 423, 2972, 63, 3494, 83, 14, 2168, 8, 3494, 9, 267, 372, 3788, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 2828, 14, 3431, 14, 3494, 14, 1095, 492, 3523, 6408, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 5306, 492, 14798, 6408, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 1730, 492, 8596, 6408, 421, 199, 533, 481, 5421, 6408, 8, 1563, 6408, 304, 272, 408, 272, 377, 1996, 370, 3877, 1006, 3788, 315, 314, 1642, 4865, 12, 16915, 1263, 625, 16431, 272, 3788, 315, 1924, 13372, 4865, 4865, 14, 272, 408, 272, 4887, 63, 2888, 275, 334, 7810, 6408, 12, 8596, 6408, 9, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 21860, 6408, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 3494, 83, 275, 359, 3494, 63, 533, 2031, 589, 12, 1011, 958, 9, 586, 367, 4887, 63, 533, 315, 291, 14, 3494, 63, 2888, 61, 267, 291, 423, 2972, 63, 3494, 83, 275, 663, 342, 339, 347, 485, 362, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 14509, 282, 2849, 769, 402, 3788, 687, 1006, 4887, 14745, 14, 267, 408, 267, 1006, 63, 3431, 275, 942, 267, 367, 4887, 315, 291, 14, 3494, 83, 26, 288, 3788, 12, 1006, 63, 11235, 27986, 275, 4887, 423, 362, 342, 288, 327, 982, 314, 4865, 18699, 1133, 2757, 1202, 12, 949, 1655, 27157, 365, 5784, 14, 288, 340, 3788, 365, 488, 26, 355, 2059, 288, 340, 3788, 26, 355, 291, 423, 2972, 63, 3494, 83, 14, 525, 8, 3494, 9, 288, 1006, 63, 3431, 14, 2880, 8, 3431, 9, 288, 327, 982, 642, 4887, 1021, 10470, 1006, 314, 3788, 12, 949, 9848, 288, 327, 27157, 365, 5784, 288, 340, 1006, 63, 11235, 27986, 26, 355, 2059, 267, 372, 1006, 63, 3431, 12, 1006, 63, 11235, 27986, 339, 347, 485, 1617, 8, 277, 12, 3788, 12, 1177, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 31299, 314, 3788, 12, 8152, 1263, 625, 16431, 3788, 2410, 9936, 1006, 267, 14745, 14, 398, 2104, 1924, 4887, 4865, 12, 1263, 3788, 440, 5489, 787, 3032, 641, 370, 314, 267, 2163, 4865, 14, 267, 408, 267, 367, 4887, 315, 291, 14, 3494, 83, 26, 288, 340, 3788, 26, 355, 3788, 275, 4887, 423, 1617, 8, 3431, 12, 1177, 12, 5101, 2813, 63, 393, 2614, 29, 797, 9, 288, 327, 22207, 340, 2337, 787, 949, 1655, 3788, 12, 1980, 25012, 370, 4868, 288, 327, 4887, 83, 1314, 10470, 3788, 787, 8976, 379, 14, 288, 916, 4887, 315, 291, 423, 2972, 63, 3494, 83, 26, 355, 4887, 423, 1617, 8798, 1177, 9, 355, 291, 423, 2972, 63, 3494, 83, 14, 2168, 8, 3494, 9, 267, 372, 3788, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
sammerry/ansible
lib/ansible/parsing/vault/__init__.py
40
20086
# (c) 2014, James Tanner <tanner.jc@gmail.com> # # 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/>. # # ansible-pull is a script that runs ansible in local mode # after checking out a playbooks directory from source repo. There is an # example playbook to bootstrap this script in the examples/ dir which # installs ansible and sets it up to run on cron. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import sys import os import shlex import shutil import tempfile from io import BytesIO from subprocess import call from ansible.errors import AnsibleError from hashlib import sha256 from binascii import hexlify from binascii import unhexlify from six import binary_type, PY3, text_type # Note: Only used for loading obsolete VaultAES files. All files are written # using the newer VaultAES256 which does not require md5 from hashlib import md5 try: from six import byte2int except ImportError: # bytes2int added in six-1.4.0 if PY3: import operator byte2int = operator.itemgetter(0) else: def byte2int(bs): return ord(bs[0]) from ansible.utils.unicode import to_unicode, to_bytes try: from Crypto.Hash import SHA256, HMAC HAS_HASH = True except ImportError: HAS_HASH = False # Counter import fails for 2.0.1, requires >= 2.6.1 from pip try: from Crypto.Util import Counter HAS_COUNTER = True except ImportError: HAS_COUNTER = False # KDF import fails for 2.0.1, requires >= 2.6.1 from pip try: from Crypto.Protocol.KDF import PBKDF2 HAS_PBKDF2 = True except ImportError: HAS_PBKDF2 = False # AES IMPORTS try: from Crypto.Cipher import AES as AES HAS_AES = True except ImportError: HAS_AES = False CRYPTO_UPGRADE = "ansible-vault requires a newer version of pycrypto than the one installed on your platform. You may fix this with OS-specific commands such as: yum install python-devel; rpm -e --nodeps python-crypto; pip install pycrypto" HEADER=u'$ANSIBLE_VAULT' CIPHER_WHITELIST=['AES', 'AES256'] def check_prereqs(): if not HAS_AES or not HAS_COUNTER or not HAS_PBKDF2 or not HAS_HASH: raise AnsibleError(CRYPTO_UPGRADE) class VaultLib(object): def __init__(self, password): self.password = password self.cipher_name = None self.version = '1.1' def is_encrypted(self, data): data = to_unicode(data) if data.startswith(HEADER): return True else: return False def encrypt(self, data): data = to_unicode(data) if self.is_encrypted(data): raise AnsibleError("data is already encrypted") if not self.cipher_name: self.cipher_name = "AES256" # raise AnsibleError("the cipher must be set before encrypting data") if 'Vault' + self.cipher_name in globals() and self.cipher_name in CIPHER_WHITELIST: cipher = globals()['Vault' + self.cipher_name] this_cipher = cipher() else: raise AnsibleError("{0} cipher could not be found".format(self.cipher_name)) """ # combine sha + data this_sha = sha256(data).hexdigest() tmp_data = this_sha + "\n" + data """ # encrypt sha + data enc_data = this_cipher.encrypt(data, self.password) # add header tmp_data = self._add_header(enc_data) return tmp_data def decrypt(self, data): data = to_bytes(data) if self.password is None: raise AnsibleError("A vault password must be specified to decrypt data") if not self.is_encrypted(data): raise AnsibleError("data is not encrypted") # clean out header data = self._split_header(data) # create the cipher object ciphername = to_unicode(self.cipher_name) if 'Vault' + ciphername in globals() and ciphername in CIPHER_WHITELIST: cipher = globals()['Vault' + ciphername] this_cipher = cipher() else: raise AnsibleError("{0} cipher could not be found".format(ciphername)) # try to unencrypt data data = this_cipher.decrypt(data, self.password) if data is None: raise AnsibleError("Decryption failed") return data def _add_header(self, data): # combine header and encrypted data in 80 char columns #tmpdata = hexlify(data) tmpdata = [to_bytes(data[i:i+80]) for i in range(0, len(data), 80)] if not self.cipher_name: raise AnsibleError("the cipher must be set before adding a header") dirty_data = to_bytes(HEADER + ";" + self.version + ";" + self.cipher_name + "\n") for l in tmpdata: dirty_data += l + b'\n' return dirty_data def _split_header(self, data): # used by decrypt tmpdata = data.split(b'\n') tmpheader = tmpdata[0].strip().split(b';') self.version = to_unicode(tmpheader[1].strip()) self.cipher_name = to_unicode(tmpheader[2].strip()) clean_data = b'\n'.join(tmpdata[1:]) """ # strip out newline, join, unhex clean_data = [ x.strip() for x in clean_data ] clean_data = unhexlify(''.join(clean_data)) """ return clean_data def __enter__(self): return self def __exit__(self, *err): pass class VaultEditor(object): # uses helper methods for write_file(self, filename, data) # to write a file so that code isn't duplicated for simple # file I/O, ditto read_file(self, filename) and launch_editor(self, filename) # ... "Don't Repeat Yourself", etc. def __init__(self, cipher_name, password, filename): # instantiates a member variable for VaultLib self.cipher_name = cipher_name self.password = password self.filename = filename def _edit_file_helper(self, existing_data=None, cipher=None): # make sure the umask is set to a sane value old_umask = os.umask(0o077) # Create a tempfile _, tmp_path = tempfile.mkstemp() if existing_data: self.write_data(existing_data, tmp_path) # drop the user into an editor on the tmp file call(self._editor_shell_command(tmp_path)) tmpdata = self.read_data(tmp_path) # Do nothing if the content has not changed if existing_data == tmpdata: return # create new vault this_vault = VaultLib(self.password) if cipher: this_vault.cipher_name = cipher # encrypt new data and write out to tmp enc_data = this_vault.encrypt(tmpdata) self.write_data(enc_data, tmp_path) # shuffle tmp file into place self.shuffle_files(tmp_path, self.filename) # and restore umask os.umask(old_umask) def create_file(self): """ create a new encrypted file """ check_prereqs() if os.path.isfile(self.filename): raise AnsibleError("%s exists, please use 'edit' instead" % self.filename) # Let the user specify contents and save file self._edit_file_helper(cipher=self.cipher_name) def decrypt_file(self): check_prereqs() if not os.path.isfile(self.filename): raise AnsibleError("%s does not exist" % self.filename) tmpdata = self.read_data(self.filename) this_vault = VaultLib(self.password) if this_vault.is_encrypted(tmpdata): dec_data = this_vault.decrypt(tmpdata) if dec_data is None: raise AnsibleError("Decryption failed") else: self.write_data(dec_data, self.filename) else: raise AnsibleError("%s is not encrypted" % self.filename) def edit_file(self): check_prereqs() # decrypt to tmpfile tmpdata = self.read_data(self.filename) this_vault = VaultLib(self.password) dec_data = this_vault.decrypt(tmpdata) # let the user edit the data and save self._edit_file_helper(existing_data=dec_data) ###we want the cipher to default to AES256 (get rid of files # encrypted with the AES cipher) #self._edit_file_helper(existing_data=dec_data, cipher=this_vault.cipher_name) def view_file(self): check_prereqs() # decrypt to tmpfile tmpdata = self.read_data(self.filename) this_vault = VaultLib(self.password) dec_data = this_vault.decrypt(tmpdata) _, tmp_path = tempfile.mkstemp() self.write_data(dec_data, tmp_path) # drop the user into pager on the tmp file call(self._pager_shell_command(tmp_path)) os.remove(tmp_path) def encrypt_file(self): check_prereqs() if not os.path.isfile(self.filename): raise AnsibleError("%s does not exist" % self.filename) tmpdata = self.read_data(self.filename) this_vault = VaultLib(self.password) this_vault.cipher_name = self.cipher_name if not this_vault.is_encrypted(tmpdata): enc_data = this_vault.encrypt(tmpdata) self.write_data(enc_data, self.filename) else: raise AnsibleError("%s is already encrypted" % self.filename) def rekey_file(self, new_password): check_prereqs() # decrypt tmpdata = self.read_data(self.filename) this_vault = VaultLib(self.password) dec_data = this_vault.decrypt(tmpdata) # create new vault new_vault = VaultLib(new_password) # we want to force cipher to the default #new_vault.cipher_name = this_vault.cipher_name # re-encrypt data and re-write file enc_data = new_vault.encrypt(dec_data) self.write_data(enc_data, self.filename) def read_data(self, filename): f = open(filename, "rb") tmpdata = f.read() f.close() return tmpdata def write_data(self, data, filename): if os.path.isfile(filename): os.remove(filename) f = open(filename, "wb") f.write(to_bytes(data)) f.close() def shuffle_files(self, src, dest): # overwrite dest with src if os.path.isfile(dest): os.remove(dest) shutil.move(src, dest) def _editor_shell_command(self, filename): EDITOR = os.environ.get('EDITOR','vim') editor = shlex.split(EDITOR) editor.append(filename) return editor def _pager_shell_command(self, filename): PAGER = os.environ.get('PAGER','less') pager = shlex.split(PAGER) pager.append(filename) return pager class VaultFile(object): def __init__(self, password, filename): self.password = password self.filename = filename if not os.path.isfile(self.filename): raise AnsibleError("%s does not exist" % self.filename) try: self.filehandle = open(filename, "rb") except Exception as e: raise AnsibleError("Could not open %s: %s" % (self.filename, str(e))) _, self.tmpfile = tempfile.mkstemp() def __del__(self): self.filehandle.close() os.unlink(self.tmplfile) def is_encrypted(self): peak = self.filehandler.readline() if peak.startswith(HEADER): return True else: return False def get_decrypted(self): check_prereqs() if self.is_encrypted(): tmpdata = self.filehandle.read() this_vault = VaultLib(self.password) dec_data = this_vault.decrypt(tmpdata) if dec_data is None: raise AnsibleError("Decryption failed") else: self.tempfile.write(dec_data) return self.tmpfile else: return self.filename ######################################## # CIPHERS # ######################################## class VaultAES(object): # this version has been obsoleted by the VaultAES256 class # which uses encrypt-then-mac (fixing order) and also improving the KDF used # code remains for upgrade purposes only # http://stackoverflow.com/a/16761459 def __init__(self): if not HAS_AES: raise AnsibleError(CRYPTO_UPGRADE) def aes_derive_key_and_iv(self, password, salt, key_length, iv_length): """ Create a key and an initialization vector """ d = d_i = b'' while len(d) < key_length + iv_length: text = "{0}{1}{2}".format(d_i, password, salt) d_i = md5(to_bytes(text)).digest() d += d_i key = d[:key_length] iv = d[key_length:key_length+iv_length] return key, iv def encrypt(self, data, password, key_length=32): """ Read plaintext data from in_file and write encrypted to out_file """ # combine sha + data this_sha = sha256(to_bytes(data)).hexdigest() tmp_data = this_sha + "\n" + data in_file = BytesIO(to_bytes(tmp_data)) in_file.seek(0) out_file = BytesIO() bs = AES.block_size # Get a block of random data. EL does not have Crypto.Random.new() # so os.urandom is used for cross platform purposes salt = os.urandom(bs - len('Salted__')) key, iv = self.aes_derive_key_and_iv(password, salt, key_length, bs) cipher = AES.new(key, AES.MODE_CBC, iv) full = to_bytes(b'Salted__' + salt) out_file.write(full) finished = False while not finished: chunk = in_file.read(1024 * bs) if len(chunk) == 0 or len(chunk) % bs != 0: padding_length = (bs - len(chunk) % bs) or bs chunk += to_bytes(padding_length * chr(padding_length)) finished = True out_file.write(cipher.encrypt(chunk)) out_file.seek(0) enc_data = out_file.read() tmp_data = hexlify(enc_data) return tmp_data def decrypt(self, data, password, key_length=32): """ Read encrypted data from in_file and write decrypted to out_file """ # http://stackoverflow.com/a/14989032 data = b''.join(data.split(b'\n')) data = unhexlify(data) in_file = BytesIO(data) in_file.seek(0) out_file = BytesIO() bs = AES.block_size tmpsalt = in_file.read(bs) salt = tmpsalt[len('Salted__'):] key, iv = self.aes_derive_key_and_iv(password, salt, key_length, bs) cipher = AES.new(key, AES.MODE_CBC, iv) next_chunk = b'' finished = False while not finished: chunk, next_chunk = next_chunk, cipher.decrypt(in_file.read(1024 * bs)) if len(next_chunk) == 0: if PY3: padding_length = chunk[-1] else: padding_length = ord(chunk[-1]) chunk = chunk[:-padding_length] finished = True out_file.write(chunk) out_file.flush() # reset the stream pointer to the beginning out_file.seek(0) out_data = out_file.read() out_file.close() new_data = to_unicode(out_data) # split out sha and verify decryption split_data = new_data.split("\n") this_sha = split_data[0] this_data = '\n'.join(split_data[1:]) test_sha = sha256(to_bytes(this_data)).hexdigest() if this_sha != test_sha: raise AnsibleError("Decryption failed") return this_data class VaultAES256(object): """ Vault implementation using AES-CTR with an HMAC-SHA256 authentication code. Keys are derived using PBKDF2 """ # http://www.daemonology.net/blog/2009-06-11-cryptographic-right-answers.html def __init__(self): check_prereqs() def gen_key_initctr(self, password, salt): # 16 for AES 128, 32 for AES256 keylength = 32 # match the size used for counter.new to avoid extra work ivlength = 16 hash_function = SHA256 # make two keys and one iv pbkdf2_prf = lambda p, s: HMAC.new(p, s, hash_function).digest() derivedkey = PBKDF2(password, salt, dkLen=(2 * keylength) + ivlength, count=10000, prf=pbkdf2_prf) key1 = derivedkey[:keylength] key2 = derivedkey[keylength:(keylength * 2)] iv = derivedkey[(keylength * 2):(keylength * 2) + ivlength] return key1, key2, hexlify(iv) def encrypt(self, data, password): salt = os.urandom(32) key1, key2, iv = self.gen_key_initctr(password, salt) # PKCS#7 PAD DATA http://tools.ietf.org/html/rfc5652#section-6.3 bs = AES.block_size padding_length = (bs - len(data) % bs) or bs data += padding_length * chr(padding_length) # COUNTER.new PARAMETERS # 1) nbits (integer) - Length of the counter, in bits. # 2) initial_value (integer) - initial value of the counter. "iv" from gen_key_initctr ctr = Counter.new(128, initial_value=int(iv, 16)) # AES.new PARAMETERS # 1) AES key, must be either 16, 24, or 32 bytes long -- "key" from gen_key_initctr # 2) MODE_CTR, is the recommended mode # 3) counter=<CounterObject> cipher = AES.new(key1, AES.MODE_CTR, counter=ctr) # ENCRYPT PADDED DATA cryptedData = cipher.encrypt(data) # COMBINE SALT, DIGEST AND DATA hmac = HMAC.new(key2, cryptedData, SHA256) message = b''.join([hexlify(salt), b"\n", to_bytes(hmac.hexdigest()), b"\n", hexlify(cryptedData)]) message = hexlify(message) return message def decrypt(self, data, password): # SPLIT SALT, DIGEST, AND DATA data = b''.join(data.split(b"\n")) data = unhexlify(data) salt, cryptedHmac, cryptedData = data.split(b"\n", 2) salt = unhexlify(salt) cryptedData = unhexlify(cryptedData) key1, key2, iv = self.gen_key_initctr(password, salt) # EXIT EARLY IF DIGEST DOESN'T MATCH hmacDecrypt = HMAC.new(key2, cryptedData, SHA256) if not self.is_equal(cryptedHmac, to_bytes(hmacDecrypt.hexdigest())): return None # SET THE COUNTER AND THE CIPHER ctr = Counter.new(128, initial_value=int(iv, 16)) cipher = AES.new(key1, AES.MODE_CTR, counter=ctr) # DECRYPT PADDED DATA decryptedData = cipher.decrypt(cryptedData) # UNPAD DATA try: padding_length = ord(decryptedData[-1]) except TypeError: padding_length = decryptedData[-1] decryptedData = decryptedData[:-padding_length] return to_unicode(decryptedData) def is_equal(self, a, b): """ Comparing 2 byte arrrays in constant time to avoid timing attacks. It would be nice if there was a library for this but hey. """ # http://codahale.com/a-lesson-in-timing-attacks/ if len(a) != len(b): return False result = 0 for x, y in zip(a, b): if PY3: result |= x ^ y else: result |= ord(x) ^ ord(y) return result == 0
gpl-3.0
[ 3, 334, 67, 9, 6927, 12, 1603, 14015, 377, 5161, 665, 84, 5161, 14, 22760, 32, 6799, 14, 957, 30, 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, 3, 3242, 13, 9302, 365, 282, 2884, 626, 7858, 3242, 315, 2257, 818, 199, 3, 2410, 7907, 734, 282, 5232, 8858, 2082, 687, 1350, 3831, 14, 221, 6006, 365, 376, 199, 3, 2893, 15695, 370, 15865, 642, 2884, 315, 314, 7251, 15, 2935, 1314, 199, 3, 25801, 3242, 436, 5951, 652, 1536, 370, 1255, 641, 19818, 14, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 984, 199, 646, 747, 199, 646, 16701, 199, 646, 5145, 199, 646, 5549, 199, 504, 5890, 492, 11808, 199, 504, 3873, 492, 1240, 199, 504, 3242, 14, 2550, 492, 13358, 199, 504, 8337, 492, 7793, 3912, 199, 504, 14755, 492, 6318, 8209, 199, 504, 14755, 492, 625, 20677, 199, 504, 3816, 492, 3366, 63, 466, 12, 7843, 19, 12, 1318, 63, 466, 199, 199, 3, 3390, 26, 5972, 1202, 367, 8697, 24985, 812, 558, 14494, 1584, 14, 221, 2900, 1584, 787, 5313, 199, 3, 1808, 314, 15666, 812, 558, 14494, 3912, 1314, 1630, 440, 4409, 6128, 21, 199, 504, 8337, 492, 6128, 21, 421, 199, 893, 26, 272, 687, 3816, 492, 3696, 18, 442, 199, 2590, 3545, 26, 272, 327, 2783, 18, 442, 3483, 315, 3816, 13, 17, 14, 20, 14, 16, 272, 340, 7843, 19, 26, 267, 492, 4182, 267, 3696, 18, 442, 275, 4182, 14, 20832, 8, 16, 9, 272, 587, 26, 267, 347, 3696, 18, 442, 8, 1533, 304, 288, 372, 6206, 8, 1533, 59, 16, 566, 199, 199, 504, 3242, 14, 1208, 14, 2975, 492, 370, 63, 2975, 12, 370, 63, 2394, 421, 199, 893, 26, 272, 687, 18855, 14, 3476, 492, 12002, 3912, 12, 29817, 272, 7509, 63, 14395, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 14395, 275, 756, 199, 199, 3, 14427, 492, 6918, 367, 499, 14, 16, 14, 17, 12, 5074, 2356, 499, 14, 22, 14, 17, 687, 7305, 199, 893, 26, 272, 687, 18855, 14, 9562, 492, 14427, 272, 7509, 63, 23049, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 23049, 275, 756, 199, 199, 3, 1804, 3888, 492, 6918, 367, 499, 14, 16, 14, 17, 12, 5074, 2356, 499, 14, 22, 14, 17, 687, 7305, 199, 893, 26, 272, 687, 18855, 14, 3658, 14, 43, 3888, 492, 510, 17672, 3888, 18, 272, 7509, 63, 13167, 43, 3888, 18, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 13167, 43, 3888, 18, 275, 756, 199, 199, 3, 19093, 5025, 2596, 51, 199, 893, 26, 272, 687, 18855, 14, 21967, 492, 19093, 465, 19093, 272, 7509, 63, 14494, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 14494, 275, 756, 199, 199, 2944, 7431, 2566, 63, 2160, 28594, 275, 298, 4853, 13, 10077, 5074, 282, 15666, 1015, 402, 1134, 10316, 2419, 314, 1373, 4903, 641, 2195, 4298, 14, 2047, 1443, 5325, 642, 543, 4403, 13, 6100, 3718, 4066, 465, 26, 24717, 3907, 2366, 13, 27870, 27, 21980, 446, 69, 1553, 932, 1190, 2366, 13, 10316, 27, 7305, 3907, 1134, 10316, 2, 199, 199, 7311, 29, 85, 7, 4, 8490, 63, 15162, 2233, 7, 199, 35, 1772, 3452, 63, 18817, 4924, 2968, 14494, 297, 283, 14494, 3912, 418, 421, 199, 318, 1104, 63, 657, 12720, 837, 339, 340, 440, 7509, 63, 14494, 503, 440, 7509, 63, 23049, 503, 440, 7509, 63, 13167, 43, 3888, 18, 503, 440, 7509, 63, 14395, 26, 267, 746, 13358, 8, 2944, 7431, 2566, 63, 2160, 28594, 9, 199, 199, 533, 812, 558, 4728, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2505, 304, 267, 291, 14, 2060, 275, 2505, 267, 291, 14, 9231, 63, 354, 275, 488, 267, 291, 14, 1023, 275, 283, 17, 14, 17, 7, 339, 347, 365, 63, 15078, 8, 277, 12, 666, 304, 267, 666, 275, 370, 63, 2975, 8, 576, 9, 267, 340, 666, 14, 2460, 8, 7311, 304, 288, 372, 715, 267, 587, 26, 288, 372, 756, 339, 347, 14645, 8, 277, 12, 666, 304, 267, 666, 275, 370, 63, 2975, 8, 576, 9, 398, 340, 291, 14, 374, 63, 15078, 8, 576, 304, 288, 746, 13358, 480, 576, 365, 2575, 14862, 531, 398, 340, 440, 291, 14, 9231, 63, 354, 26, 288, 291, 14, 9231, 63, 354, 275, 298, 14494, 3912, 2, 288, 327, 746, 13358, 480, 1589, 10830, 1471, 506, 663, 2544, 14645, 316, 666, 531, 398, 340, 283, 20229, 7, 435, 291, 14, 9231, 63, 354, 315, 7992, 342, 436, 291, 14, 9231, 63, 354, 315, 445, 1772, 3452, 63, 18817, 4924, 26, 288, 10830, 275, 7992, 12047, 20229, 7, 435, 291, 14, 9231, 63, 354, 61, 288, 642, 63, 9231, 275, 10830, 342, 267, 587, 26, 288, 746, 13358, 13076, 16, 93, 10830, 4293, 440, 506, 1911, 1674, 908, 8, 277, 14, 9231, 63, 354, 430, 398, 408, 267, 327, 13323, 7793, 435, 666, 267, 642, 63, 4835, 275, 7793, 3912, 8, 576, 680, 11453, 342, 267, 3529, 63, 576, 275, 642, 63, 4835, 435, 1867, 78, 2, 435, 666, 267, 408, 398, 327, 14645, 7793, 435, 666, 267, 12011, 63, 576, 275, 642 ]
[ 334, 67, 9, 6927, 12, 1603, 14015, 377, 5161, 665, 84, 5161, 14, 22760, 32, 6799, 14, 957, 30, 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, 3, 3242, 13, 9302, 365, 282, 2884, 626, 7858, 3242, 315, 2257, 818, 199, 3, 2410, 7907, 734, 282, 5232, 8858, 2082, 687, 1350, 3831, 14, 221, 6006, 365, 376, 199, 3, 2893, 15695, 370, 15865, 642, 2884, 315, 314, 7251, 15, 2935, 1314, 199, 3, 25801, 3242, 436, 5951, 652, 1536, 370, 1255, 641, 19818, 14, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 984, 199, 646, 747, 199, 646, 16701, 199, 646, 5145, 199, 646, 5549, 199, 504, 5890, 492, 11808, 199, 504, 3873, 492, 1240, 199, 504, 3242, 14, 2550, 492, 13358, 199, 504, 8337, 492, 7793, 3912, 199, 504, 14755, 492, 6318, 8209, 199, 504, 14755, 492, 625, 20677, 199, 504, 3816, 492, 3366, 63, 466, 12, 7843, 19, 12, 1318, 63, 466, 199, 199, 3, 3390, 26, 5972, 1202, 367, 8697, 24985, 812, 558, 14494, 1584, 14, 221, 2900, 1584, 787, 5313, 199, 3, 1808, 314, 15666, 812, 558, 14494, 3912, 1314, 1630, 440, 4409, 6128, 21, 199, 504, 8337, 492, 6128, 21, 421, 199, 893, 26, 272, 687, 3816, 492, 3696, 18, 442, 199, 2590, 3545, 26, 272, 327, 2783, 18, 442, 3483, 315, 3816, 13, 17, 14, 20, 14, 16, 272, 340, 7843, 19, 26, 267, 492, 4182, 267, 3696, 18, 442, 275, 4182, 14, 20832, 8, 16, 9, 272, 587, 26, 267, 347, 3696, 18, 442, 8, 1533, 304, 288, 372, 6206, 8, 1533, 59, 16, 566, 199, 199, 504, 3242, 14, 1208, 14, 2975, 492, 370, 63, 2975, 12, 370, 63, 2394, 421, 199, 893, 26, 272, 687, 18855, 14, 3476, 492, 12002, 3912, 12, 29817, 272, 7509, 63, 14395, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 14395, 275, 756, 199, 199, 3, 14427, 492, 6918, 367, 499, 14, 16, 14, 17, 12, 5074, 2356, 499, 14, 22, 14, 17, 687, 7305, 199, 893, 26, 272, 687, 18855, 14, 9562, 492, 14427, 272, 7509, 63, 23049, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 23049, 275, 756, 199, 199, 3, 1804, 3888, 492, 6918, 367, 499, 14, 16, 14, 17, 12, 5074, 2356, 499, 14, 22, 14, 17, 687, 7305, 199, 893, 26, 272, 687, 18855, 14, 3658, 14, 43, 3888, 492, 510, 17672, 3888, 18, 272, 7509, 63, 13167, 43, 3888, 18, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 13167, 43, 3888, 18, 275, 756, 199, 199, 3, 19093, 5025, 2596, 51, 199, 893, 26, 272, 687, 18855, 14, 21967, 492, 19093, 465, 19093, 272, 7509, 63, 14494, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 14494, 275, 756, 199, 199, 2944, 7431, 2566, 63, 2160, 28594, 275, 298, 4853, 13, 10077, 5074, 282, 15666, 1015, 402, 1134, 10316, 2419, 314, 1373, 4903, 641, 2195, 4298, 14, 2047, 1443, 5325, 642, 543, 4403, 13, 6100, 3718, 4066, 465, 26, 24717, 3907, 2366, 13, 27870, 27, 21980, 446, 69, 1553, 932, 1190, 2366, 13, 10316, 27, 7305, 3907, 1134, 10316, 2, 199, 199, 7311, 29, 85, 7, 4, 8490, 63, 15162, 2233, 7, 199, 35, 1772, 3452, 63, 18817, 4924, 2968, 14494, 297, 283, 14494, 3912, 418, 421, 199, 318, 1104, 63, 657, 12720, 837, 339, 340, 440, 7509, 63, 14494, 503, 440, 7509, 63, 23049, 503, 440, 7509, 63, 13167, 43, 3888, 18, 503, 440, 7509, 63, 14395, 26, 267, 746, 13358, 8, 2944, 7431, 2566, 63, 2160, 28594, 9, 199, 199, 533, 812, 558, 4728, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2505, 304, 267, 291, 14, 2060, 275, 2505, 267, 291, 14, 9231, 63, 354, 275, 488, 267, 291, 14, 1023, 275, 283, 17, 14, 17, 7, 339, 347, 365, 63, 15078, 8, 277, 12, 666, 304, 267, 666, 275, 370, 63, 2975, 8, 576, 9, 267, 340, 666, 14, 2460, 8, 7311, 304, 288, 372, 715, 267, 587, 26, 288, 372, 756, 339, 347, 14645, 8, 277, 12, 666, 304, 267, 666, 275, 370, 63, 2975, 8, 576, 9, 398, 340, 291, 14, 374, 63, 15078, 8, 576, 304, 288, 746, 13358, 480, 576, 365, 2575, 14862, 531, 398, 340, 440, 291, 14, 9231, 63, 354, 26, 288, 291, 14, 9231, 63, 354, 275, 298, 14494, 3912, 2, 288, 327, 746, 13358, 480, 1589, 10830, 1471, 506, 663, 2544, 14645, 316, 666, 531, 398, 340, 283, 20229, 7, 435, 291, 14, 9231, 63, 354, 315, 7992, 342, 436, 291, 14, 9231, 63, 354, 315, 445, 1772, 3452, 63, 18817, 4924, 26, 288, 10830, 275, 7992, 12047, 20229, 7, 435, 291, 14, 9231, 63, 354, 61, 288, 642, 63, 9231, 275, 10830, 342, 267, 587, 26, 288, 746, 13358, 13076, 16, 93, 10830, 4293, 440, 506, 1911, 1674, 908, 8, 277, 14, 9231, 63, 354, 430, 398, 408, 267, 327, 13323, 7793, 435, 666, 267, 642, 63, 4835, 275, 7793, 3912, 8, 576, 680, 11453, 342, 267, 3529, 63, 576, 275, 642, 63, 4835, 435, 1867, 78, 2, 435, 666, 267, 408, 398, 327, 14645, 7793, 435, 666, 267, 12011, 63, 576, 275, 642, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ferranti/watchdog
vendor/pyExcelerator-0.6.3a/pyExcelerator/BIFFRecords.py
11
88369
#!/usr/bin/env python # -*- coding: windows-1251 -*- # Copyright (C) 2005 Roman V. Kiseliov # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # 3. All advertising materials mentioning features or use of this # software must display the following acknowledgment: # "This product includes software developed by # Roman V. Kiseliov <roman@kiseliov.ru>." # # 4. Redistributions of any form whatsoever must retain the following # acknowledgment: # "This product includes software developed by # Roman V. Kiseliov <roman@kiseliov.ru>." # # THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY # EXPRESSED 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 Roman V. Kiseliov OR # ITS 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. __rev_id__ = """$Id: BIFFRecords.py,v 1.7 2005/10/26 07:44:24 rvk Exp $""" from struct import pack from UnicodeUtils import * import sys class SharedStringTable(object): _SST_ID = 0x00FC _CONTINUE_ID = 0x003C def __init__(self): self._sst_record = '' self._continues = [] self._current_piece = pack('<II', 0, 0) self._pos = len(self._current_piece) self._str_indexes = {} self._add_calls = 0 def add_str(self, s): self._add_calls += 1 if s not in self._str_indexes: self._str_indexes[s] = len(self._str_indexes) self._add_to_sst(s) return self._str_indexes[s] def str_index(self, s): return self._str_indexes[s] def get_biff_record(self): self._new_piece() result = pack('<2HII', self._SST_ID, len(self._sst_record), self._add_calls, len(self._str_indexes)) result += self._sst_record[8:] result += ''.join(self._continues) return result def _add_to_sst(self, s): u_str = upack2(s) if len(u_str) > 0xFFFF: raise Exception('error: very long string.') is_unicode_str = u_str[2] == '\x01' if is_unicode_str: atom_len = 5 # 2 byte -- len, # 1 byte -- options, # 2 byte -- 1st sym else: atom_len = 4 # 2 byte -- len, # 1 byte -- options, # 1 byte -- 1st sym self._save_atom(u_str[0:atom_len]) self._save_splitted(u_str[atom_len:], is_unicode_str) def _new_piece(self): if self._sst_record == '': self._sst_record = self._current_piece else: curr_piece_len = len(self._current_piece) self._continues.append(pack('<2H%ds'%curr_piece_len, self._CONTINUE_ID, curr_piece_len, self._current_piece)) self._current_piece = '' self._pos = len(self._current_piece) def _save_atom(self, s): atom_len = len(s) free_space = 0x2020 - len(self._current_piece) if free_space < atom_len: self._new_piece() self._current_piece += s def _save_splitted(self, s, is_unicode_str): i = 0 str_len = len(s) while i < str_len: piece_len = len(self._current_piece) free_space = 0x2020 - piece_len tail_len = str_len - i need_more_space = free_space < tail_len if not need_more_space: atom_len = tail_len else: if is_unicode_str: atom_len = free_space & 0xFFFE else: atom_len = free_space self._current_piece += s[i:i+atom_len] if need_more_space: self._new_piece() if is_unicode_str: self._current_piece += '\x01' else: self._current_piece += '\x00' i += atom_len class BiffRecord(object): def __init__(self): self._rec_data = '' def get_rec_id(self): return _REC_ID def get_rec_header(self): return pack('<2H', self._REC_ID, len(self._rec_data)) def get_rec_data(self): return self._rec_data def get(self): data = self.get_rec_data() if len(data) > 0x2020: # limit for BIFF7/8 chunks = [] pos = 0 while pos < len(data): chunk_pos = pos + 0x2020 chunk = data[pos:chunk_pos] chunks.append(chunk) pos = chunk_pos continues = pack('<2H', self._REC_ID, len(chunks[0])) + chunks[0] for chunk in chunks[1:]: continues += pack('<2H%ds'%len(chunk), 0x003C, len(chunk), chunk) # 0x003C -- CONTINUE record id return continues else: return self.get_rec_header() + data class Biff8BOFRecord(BiffRecord): """ Offset Size Contents 0 2 Version, contains 0600H for BIFF8 and BIFF8X 2 2 Type of the following data: 0005H = Workbook globals 0006H = Visual Basic module 0010H = Worksheet 0020H = Chart 0040H = Macro sheet 0100H = Workspace file 4 2 Build identifier 6 2 Build year 8 4 File history flags 12 4 Lowest Excel version that can read all records in this file """ _REC_ID = 0x0809 # stream types BOOK_GLOBAL = 0x0005 VB_MODULE = 0x0006 WORKSHEET = 0x0010 CHART = 0x0020 MACROSHEET = 0x0040 WORKSPACE = 0x0100 def __init__(self, rec_type): BiffRecord.__init__(self) version = 0x0600 build = 0x0DBB year = 0x07CC file_hist_flags = 0x00L ver_can_read = 0x06L self._rec_data = pack('<4H2I', version, rec_type, build, year, file_hist_flags, ver_can_read) class InteraceHdrRecord(BiffRecord): _REC_ID = 0x00E1 def __init__(self): BiffRecord.__init__(self) self._rec_data = pack('BB', 0xB0, 0x04) class InteraceEndRecord(BiffRecord): _REC_ID = 0x00E2 def __init__(self): BiffRecord.__init__(self) self._rec_data = '' class MMSRecord(BiffRecord): _REC_ID = 0x00C1 def __init__(self): BiffRecord.__init__(self) self._rec_data = pack('<H', 0x00) class WriteAccessRecord(BiffRecord): """ This record is part of the file protection. It contains the name of the user that has saved the file. The user name is always stored as an equal-sized string. All unused characters after the name are filled with space characters. It is not required to write the mentioned string length. Every other length will be accepted too. """ _REC_ID = 0x005C def __init__(self, owner): BiffRecord.__init__(self) uowner = owner[0:0x30] uowner_len = len(uowner) self._rec_data = pack('%ds%ds' % (uowner_len, 0x70 - uowner_len), uowner, ' '*(0x70 - uowner_len)) class DSFRecord(BiffRecord): """ This record specifies if the file contains an additional BIFF5/BIFF7 workbook stream. Record DSF, BIFF8: Offset Size Contents 0 2 0 = Only the BIFF8 Workbook stream is present 1 = Additional BIFF5/BIFF7 Book stream is in the file A double stream file can be read by Excel 5.0 and Excel 95, and still contains all new features added to BIFF8 (which are left out in the BIFF5/BIFF7 Book stream). """ _REC_ID = 0x0161 def __init__(self): BiffRecord.__init__(self) self._rec_data = pack('<H', 0x00) class TabIDRecord(BiffRecord): _REC_ID = 0x013D def __init__(self, sheetcount): BiffRecord.__init__(self) for i in range(sheetcount): self._rec_data += pack('<H', i+1) class FnGroupCountRecord(BiffRecord): _REC_ID = 0x009C def __init__(self): BiffRecord.__init__(self) self._rec_data = pack('BB', 0x0E, 0x00) class WindowProtectRecord(BiffRecord): """ This record is part of the worksheet/workbook protection. It determines whether the window configuration of this document is protected. Window protection is not active, if this record is omitted. """ _REC_ID = 0x0019 def __init__(self, wndprotect): BiffRecord.__init__(self) self._rec_data = pack('<H', wndprotect) class ObjectProtectRecord(BiffRecord): """ This record is part of the worksheet/workbook protection. It determines whether the objects of the current sheet are protected. Object protection is not active, if this record is omitted. """ _REC_ID = 0x0063 def __init__(self, objprotect): BiffRecord.__init__(self) self._rec_data = pack('<H', objprotect) class ScenProtectRecord(BiffRecord): """ This record is part of the worksheet/workbook protection. It determines whether the scenarios of the current sheet are protected. Scenario protection is not active, if this record is omitted. """ _REC_ID = 0x00DD def __init__(self, scenprotect): BiffRecord.__init__(self) self._rec_data = pack('<H', scenprotect) class ProtectRecord(BiffRecord): """ This record is part of the worksheet/workbook protection. It specifies whether a worksheet or a workbook is protected against modification. Protection is not active, if this record is omitted. """ _REC_ID = 0x0012 def __init__(self, protect): BiffRecord.__init__(self) self._rec_data = pack('<H', protect) class PasswordRecord(BiffRecord): """ This record is part of the worksheet/workbook protection. It stores a 16-bit hash value, calculated from the worksheet or workbook protection password. """ _REC_ID = 0x0013 def passwd_hash(self, plaintext): """ Based on the algorithm provided by Daniel Rentz of OpenOffice. """ if plaintext == "": return 0 passwd_hash = 0x0000 for i, char in enumerate(plaintext): c = ord(char) << (i + 1) low_15 = c & 0x7fff high_15 = c & 0x7fff << 15 high_15 = high_15 >> 15 c = low_15 | high_15 passwd_hash ^= c passwd_hash ^= len(plaintext) passwd_hash ^= 0xCE4B return passwd_hash def __init__(self, passwd = ""): BiffRecord.__init__(self) self._rec_data = pack('<H', self.passwd_hash(passwd)) class Prot4RevRecord(BiffRecord): _REC_ID = 0x01AF def __init__(self): BiffRecord.__init__(self) self._rec_data = pack('<H', 0x00) class Prot4RevPassRecord(BiffRecord): _REC_ID = 0x01BC def __init__(self): BiffRecord.__init__(self) self._rec_data = pack('<H', 0x00) class BackupRecord(BiffRecord): """ This record contains a Boolean value determining whether Excel makes a backup of the file while saving. """ _REC_ID = 0x0040 def __init__(self, backup): BiffRecord.__init__(self) self._rec_data = pack('<H', backup) class HideObjRecord(BiffRecord): """ This record specifies whether and how to show objects in the workbook. Record HIDEOBJ, BIFF3-BIFF8: Offset Size Contents 0 2 Viewing mode for objects: 0 = Show all objects 1 = Show placeholders 2 = Do not show objects """ _REC_ID = 0x008D def __init__(self): BiffRecord.__init__(self) self._rec_data = pack('<H', 0x00) class RefreshAllRecord(BiffRecord): """ """ _REC_ID = 0x01B7 def __init__(self): BiffRecord.__init__(self) self._rec_data = pack('<H', 0x00) class BookBoolRecord(BiffRecord): """ This record contains a Boolean value determining whether to save values linked from external workbooks (CRN records and XCT records). In BIFF3 and BIFF4 this option is stored in the WSBOOL record. Record BOOKBOOL, BIFF5-BIFF8: Offset Size Contents 0 2 0 = Save external linked values; 1 = Do not save external linked values """ _REC_ID = 0x00DA def __init__(self): BiffRecord.__init__(self) self._rec_data = pack('<H', 0x00) class CountryRecord(BiffRecord): """ This record stores two Windows country identifiers. The first represents the user interface language of the Excel version that has saved the file, and the second represents the system regional settings at the time the file was saved. Record COUNTRY, BIFF3-BIFF8: Offset Size Contents 0 2 Windows country identifier of the user interface language of Excel 2 2 Windows country identifier of the system regional settings The following table shows most of the used country identifiers. Most of these identifiers are equal to the international country calling codes. 1 USA 2 Canada 7 Russia """ _REC_ID = 0x00DA def __init__(self, ui_id, sys_settings_id): BiffRecord.__init__(self) self._rec_data = pack('<2H', ui_id, sys_settings_id) class UseSelfsRecord(BiffRecord): """ This record specifies if the formulas in the workbook can use natural language formulas”. This type of formula can refer to cells by its content or the content of the column or row header cell. Record USESELFS, BIFF8: Offset Size Contents 0 2 0 = Do not use natural language formulas 1 = Use natural language formulas """ _REC_ID = 0x0160 def __init__(self): BiffRecord.__init__(self) self._rec_data = pack('<H', 0x01) class EOFRecord(BiffRecord): _REC_ID = 0x000A def __init__(self): BiffRecord.__init__(self) self._rec_data = '' class DateModeRecord(BiffRecord): """ This record specifies the base date for displaying date values. All dates are stored as count of days past this base date. In BIFF2-BIFF4 this record is part of the Calculation Settings Block. In BIFF5-BIFF8 it is stored in the Workbook Globals Substream. Record DATEMODE, BIFF2-BIFF8: Offset Size Contents 0 2 0 = Base is 1899-Dec-31 (the cell = 1 represents 1900-Jan-01) 1 = Base is 1904-Jan-01 (the cell = 1 represents 1904-Jan-02) """ _REC_ID = 0x0022 def __init__(self, from1904): BiffRecord.__init__(self) if from1904: self._rec_data = pack('<H', 1) else: self._rec_data = pack('<H', 0) class PrecisionRecord(BiffRecord): """ This record stores if formulas use the real cell values for calculation or the values displayed on the screen. In BIFF2- BIFF4 this record is part of the Calculation Settings Block. In BIFF5-BIFF8 it is stored in the Workbook Globals Substream. Record PRECISION, BIFF2-BIFF8: Offset Size Contents 0 2 0 = Use displayed values; 1 = Use real cell values """ _REC_ID = 0x000E def __init__(self, use_real_values): BiffRecord.__init__(self) if use_real_values: self._rec_data = pack('<H', 1) else: self._rec_data = pack('<H', 0) class CodepageBiff8Record(BiffRecord): """ This record stores the text encoding used to write byte strings, stored as MS Windows code page identifier. The CODEPAGE record in BIFF8 always contains the code page 1200 (UTF-16). Therefore it is not possible to obtain the encoding used for a protection password (it is not UTF-16). Record CODEPAGE, BIFF2-BIFF8: Offset Size Contents 0 2 Code page identifier used for byte string text encoding: 016FH = 367 = ASCII 01B5H = 437 = IBM PC CP-437 (US) 02D0H = 720 = IBM PC CP-720 (OEM Arabic) 02E1H = 737 = IBM PC CP-737 (Greek) 0307H = 775 = IBM PC CP-775 (Baltic) 0352H = 850 = IBM PC CP-850 (Latin I) 0354H = 852 = IBM PC CP-852 (Latin II (Central European)) 0357H = 855 = IBM PC CP-855 (Cyrillic) 0359H = 857 = IBM PC CP-857 (Turkish) 035AH = 858 = IBM PC CP-858 (Multilingual Latin I with Euro) 035CH = 860 = IBM PC CP-860 (Portuguese) 035DH = 861 = IBM PC CP-861 (Icelandic) 035EH = 862 = IBM PC CP-862 (Hebrew) 035FH = 863 = IBM PC CP-863 (Canadian (French)) 0360H = 864 = IBM PC CP-864 (Arabic) 0361H = 865 = IBM PC CP-865 (Nordic) 0362H = 866 = IBM PC CP-866 (Cyrillic (Russian)) 0365H = 869 = IBM PC CP-869 (Greek (Modern)) 036AH = 874 = Windows CP-874 (Thai) 03A4H = 932 = Windows CP-932 (Japanese Shift-JIS) 03A8H = 936 = Windows CP-936 (Chinese Simplified GBK) 03B5H = 949 = Windows CP-949 (Korean (Wansung)) 03B6H = 950 = Windows CP-950 (Chinese Traditional BIG5) 04B0H = 1200 = UTF-16 (BIFF8) 04E2H = 1250 = Windows CP-1250 (Latin II) (Central European) 04E3H = 1251 = Windows CP-1251 (Cyrillic) 04E4H = 1252 = Windows CP-1252 (Latin I) (BIFF4-BIFF7) 04E5H = 1253 = Windows CP-1253 (Greek) 04E6H = 1254 = Windows CP-1254 (Turkish) 04E7H = 1255 = Windows CP-1255 (Hebrew) 04E8H = 1256 = Windows CP-1256 (Arabic) 04E9H = 1257 = Windows CP-1257 (Baltic) 04EAH = 1258 = Windows CP-1258 (Vietnamese) 0551H = 1361 = Windows CP-1361 (Korean (Johab)) 2710H = 10000 = Apple Roman 8000H = 32768 = Apple Roman 8001H = 32769 = Windows CP-1252 (Latin I) (BIFF2-BIFF3) """ _REC_ID = 0x0042 UTF_16 = 0x04B0 def __init__(self): BiffRecord.__init__(self) self._rec_data = pack('<H', self.UTF_16) class Window1Record(BiffRecord): """ Offset Size Contents 0 2 Horizontal position of the document window (in twips = 1/20 of a point) 2 2 Vertical position of the document window (in twips = 1/20 of a point) 4 2 Width of the document window (in twips = 1/20 of a point) 6 2 Height of the document window (in twips = 1/20 of a point) 8 2 Option flags: Bits Mask Contents 0 0001H 0 = Window is visible 1 = Window is hidden 1 0002H 0 = Window is open 1 = Window is minimised 3 0008H 0 = Horizontal scroll bar hidden 1 = Horizontal scroll bar visible 4 0010H 0 = Vertical scroll bar hidden 1 = Vertical scroll bar visible 5 0020H 0 = Worksheet tab bar hidden 1 = Worksheet tab bar visible 10 2 Index to active (displayed) worksheet 12 2 Index of first visible tab in the worksheet tab bar 14 2 Number of selected worksheets (highlighted in the worksheet tab bar) 16 2 Width of worksheet tab bar (in 1/1000 of window width). The remaining space is used by the horizontal scrollbar. """ _REC_ID = 0x003D # flags def __init__(self, hpos_twips, vpos_twips, width_twips, height_twips, flags, active_sheet, first_tab_index, selected_tabs, tab_width): BiffRecord.__init__(self) self._rec_data = pack('<9H', hpos_twips, vpos_twips, width_twips, height_twips, flags, active_sheet, first_tab_index, selected_tabs, tab_width) class FontRecord(BiffRecord): """ WARNING The font with index 4 is omitted in all BIFF versions. This means the first four fonts have zero-based indexes, and the fifth font and all following fonts are referenced with one-based indexes. Offset Size Contents 0 2 Height of the font (in twips = 1/20 of a point) 2 2 Option flags: Bit Mask Contents 0 0001H 1 = Characters are bold (redundant, see below) 1 0002H 1 = Characters are italic 2 0004H 1 = Characters are underlined (redundant, see below) 3 0008H 1 = Characters are struck out 0010H 1 = Outline 0020H 1 = Shadow 4 2 Colour index 6 2 Font weight (100-1000). Standard values are 0190H (400) for normal text and 02BCH (700) for bold text. 8 2 Escapement type: 0000H = None 0001H = Superscript 0002H = Subscript 10 1 Underline type: 00H = None 01H = Single 21H = Single accounting 02H = Double 22H = Double accounting 11 1 Font family: 00H = None (unknown or don't care) 01H = Roman (variable width, serifed) 02H = Swiss (variable width, sans-serifed) 03H = Modern (fixed width, serifed or sans-serifed) 04H = Script (cursive) 05H = Decorative (specialised, i.e. Old English, Fraktur) 12 1 Character set: 00H = 0 = ANSI Latin 01H = 1 = System default 02H = 2 = Symbol 4DH = 77 = Apple Roman 80H = 128 = ANSI Japanese Shift-JIS 81H = 129 = ANSI Korean (Hangul) 82H = 130 = ANSI Korean (Johab) 86H = 134 = ANSI Chinese Simplified GBK 88H = 136 = ANSI Chinese Traditional BIG5 A1H = 161 = ANSI Greek A2H = 162 = ANSI Turkish A3H = 163 = ANSI Vietnamese B1H = 177 = ANSI Hebrew B2H = 178 = ANSI Arabic BAH = 186 = ANSI Baltic CCH = 204 = ANSI Cyrillic DEH = 222 = ANSI Thai EEH = 238 = ANSI Latin II (Central European) FFH = 255 = OEM Latin I 13 1 Not used 14 var. Font name: BIFF5/BIFF7: Byte string, 8-bit string length BIFF8: Unicode string, 8-bit string length The boldness and underline flags are still set in the options field, but not used on reading the font. Font weight and underline type are specified in separate fields instead. """ _REC_ID = 0x0031 def __init__(self, height, options, colour_index, weight, escapement, underline, family, charset, name): BiffRecord.__init__(self) uname = upack1(name) uname_len = len(uname) self._rec_data = pack('<5H4B%ds' % uname_len, height, options, colour_index, weight, escapement, underline, family, charset, 0x00, uname) class NumberFormatRecord(BiffRecord): """ Record FORMAT, BIFF8: Offset Size Contents 0 2 Format index used in other records 2 var. Number format string (Unicode string, 16-bit string length) From BIFF5 on, the built-in number formats will be omitted. The built-in formats are dependent on the current regional settings of the operating system. The following table shows which number formats are used by default in a US-English environment. All indexes from 0 to 163 are reserved for built-in formats. The first user-defined format starts at 164. The built-in number formats, BIFF5-BIFF8 Index Type Format string 0 General General 1 Decimal 0 2 Decimal 0.00 3 Decimal #,##0 4 Decimal #,##0.00 5 Currency "$"#,##0_);("$"#,## 6 Currency "$"#,##0_);[Red]("$"#,## 7 Currency "$"#,##0.00_);("$"#,## 8 Currency "$"#,##0.00_);[Red]("$"#,## 9 Percent 0% 10 Percent 0.00% 11 Scientific 0.00E+00 12 Fraction # ?/? 13 Fraction # ??/?? 14 Date M/D/YY 15 Date D-MMM-YY 16 Date D-MMM 17 Date MMM-YY 18 Time h:mm AM/PM 19 Time h:mm:ss AM/PM 20 Time h:mm 21 Time h:mm:ss 22 Date/Time M/D/YY h:mm 37 Account _(#,##0_);(#,##0) 38 Account _(#,##0_);[Red](#,##0) 39 Account _(#,##0.00_);(#,##0.00) 40 Account _(#,##0.00_);[Red](#,##0.00) 41 Currency _("$"* #,##0_);_("$"* (#,##0);_("$"* "-"_);_(@_) 42 Currency _(* #,##0_);_(* (#,##0);_(* "-"_);_(@_) 43 Currency _("$"* #,##0.00_);_("$"* (#,##0.00);_("$"* "-"??_);_(@_) 44 Currency _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_) 45 Time mm:ss 46 Time [h]:mm:ss 47 Time mm:ss.0 48 Scientific ##0.0E+0 49 Text @ """ _REC_ID = 0x041E def __init__(self, idx, fmtstr): BiffRecord.__init__(self) ufmtstr = upack2(fmtstr) ufmtstr_len = len(ufmtstr) self._rec_data = pack('<H%ds' % ufmtstr_len, idx, ufmtstr) class XFRecord(BiffRecord): """ XF Substructures ------------------------------------------------------------------------- XF_TYPE_PROT XF Type and Cell Protection (3 Bits), BIFF3-BIFF8 These 3 bits are part of a specific data byte. Bit Mask Contents 0 01H 1 = Cell is locked 1 02H 1 = Formula is hidden 2 04H 0 = Cell XF; 1 = Style XF XF_USED_ATTRIB Attributes Used from Parent Style XF (6 Bits), BIFF3-BIFF8 Each bit describes the validity of a specific group of attributes. In cell XFs a cleared bit means the attributes of the parent style XF are used (but only if the attributes are valid there), a set bit means the attributes of this XF are used. In style XFs a cleared bit means the attribute setting is valid, a set bit means the attribute should be ignored. Bit Mask Contents 0 01H Flag for number format 1 02H Flag for font 2 04H Flag for horizontal and vertical alignment, text wrap, indentation, orientation, rotation, and text direction 3 08H Flag for border lines 4 10H Flag for background area style 5 20H Flag for cell protection (cell locked and formula hidden) XF_HOR_ALIGN Horizontal Alignment (3 Bits), BIFF2-BIFF8 The horizontal alignment consists of 3 bits and is part of a specific data byte. Value Horizontal alignment 00H General 01H Left 02H Centred 03H Right 04H Filled 05H Justified (BIFF4-BIFF8X) 06H Centred across selection (BIFF4-BIFF8X) 07H Distributed (BIFF8X) XF_VERT_ALIGN Vertical Alignment (2 or 3 Bits), BIFF4-BIFF8 The vertical alignment consists of 2 bits (BIFF4) or 3 bits (BIFF5-BIFF8) and is part of a specific data byte. Vertical alignment is not available in BIFF2 and BIFF3. Value Vertical alignment 00H Top 01H Centred 02H Bottom 03H Justified (BIFF5-BIFF8X) 04H Distributed (BIFF8X) XF_ORIENTATION Text Orientation (2 Bits), BIFF4-BIFF7 In the BIFF versions BIFF4-BIFF7, text can be rotated in steps of 90 degrees or stacked. The orientation mode consists of 2 bits and is part of a specific data byte. In BIFF8 a rotation angle occurs instead of these flags. Value Text orientation 00H Not rotated 01H Letters are stacked top-to-bottom, but not rotated 02H Text is rotated 90 degrees counterclockwise 03H Text is rotated 90 degrees clockwise XF_ROTATION Text Rotation Angle (1 Byte), BIFF8 Value Text rotation 0 Not rotated 1-90 1 to 90 degrees counterclockwise 91-180 1 to 90 degrees clockwise 255 Letters are stacked top-to-bottom, but not rotated XF_BORDER_34 Cell Border Style (4 Bytes), BIFF3-BIFF4 Cell borders contain a line style and a line colour for each line of the border. Bit Mask Contents 2-0 00000007H Top line style 7-3 000000F8H Colour index for top line colour 10-8 00000700H Left line style 15-11 0000F800H Colour index for left line colour 18-16 00070000H Bottom line style 23-19 00F80000H Colour index for bottom line colour 26-24 07000000H Right line style 31-27 F8000000H Colour index for right line colour XF_AREA_34 Cell Background Area Style (2 Bytes), BIFF3-BIFF4 A cell background area style contains an area pattern and a foreground and background colour. Bit Mask Contents 5-0 003FH Fill pattern 10-6 07C0H Colour index for pattern colour 15-11 F800H Colour index for pattern background --------------------------------------------------------------------------------------------- Record XF, BIFF8: Offset Size Contents 0 2 Index to FONT record 2 2 Index to FORMAT record 4 2 Bit Mask Contents 2-0 0007H XF_TYPE_PROT . XF type, cell protection (see above) 15-4 FFF0H Index to parent style XF (always FFFH in style XFs) 6 1 Bit Mask Contents 2-0 07H XF_HOR_ALIGN . Horizontal alignment (see above) 3 08H 1 = Text is wrapped at right border 6-4 70H XF_VERT_ALIGN . Vertical alignment (see above) 7 1 XF_ROTATION: Text rotation angle (see above) 8 1 Bit Mask Contents 3-0 0FH Indent level 4 10H 1 = Shrink content to fit into cell 5 merge 7-6 C0H Text direction (BIFF8X only) 00b = According to context 01b = Left-to-right 10b = Right-to-left 9 1 Bit Mask Contents 7-2 FCH XF_USED_ATTRIB . Used attributes (see above) 10 4 Cell border lines and background area: Bit Mask Contents 3-0 0000000FH Left line style 7-4 000000F0H Right line style 11-8 00000F00H Top line style 15-12 0000F000H Bottom line style 22-16 007F0000H Colour index for left line colour 29-23 3F800000H Colour index for right line colour 30 40000000H 1 = Diagonal line from top left to right bottom 31 80000000H 1 = Diagonal line from bottom left to right top 14 4 Bit Mask Contents 6-0 0000007FH Colour index for top line colour 13-7 00003F80H Colour index for bottom line colour 20-14 001FC000H Colour index for diagonal line colour 24-21 01E00000H Diagonal line style 31-26 FC000000H Fill pattern 18 2 Bit Mask Contents 6-0 007FH Colour index for pattern colour 13-7 3F80H Colour index for pattern background """ _REC_ID = 0x00E0 def __init__(self, xf, xftype='cell'): BiffRecord.__init__(self) font_xf_idx, fmt_str_xf_idx, alignment, borders, pattern, protection = xf fnt = struct.pack('<H', font_xf_idx) fmt = struct.pack('<H', fmt_str_xf_idx) if xftype == 'cell': prt = struct.pack('<H', ((protection.cell_locked & 0x01) << 0) | ((protection.formula_hidden & 0x01) << 1) ) else: prt = struct.pack('<H', 0xFFF5) aln = struct.pack('B', ((alignment.horz & 0x07) << 0) | ((alignment.wrap & 0x01) << 3) | ((alignment.vert & 0x07) << 4) ) rot = struct.pack('B', alignment.rota) txt = struct.pack('B', ((alignment.inde & 0x0F) << 0) | ((alignment.shri & 0x01) << 4) | ((alignment.merg & 0x01) << 5) | ((alignment.dire & 0x03) << 6) ) if xftype == 'cell': used_attr = struct.pack('B', 0xF8) else: used_attr = struct.pack('B', 0xF4) if borders.left == borders.NO_LINE: borders.left_colour = 0x00 if borders.right == borders.NO_LINE: borders.right_colour = 0x00 if borders.top == borders.NO_LINE: borders.top_colour = 0x00 if borders.bottom == borders.NO_LINE: borders.bottom_colour = 0x00 if borders.diag == borders.NO_LINE: borders.diag_colour = 0x00 brd1 = struct.pack('<L', ((borders.left & 0x0F) << 0 ) | ((borders.right & 0x0F) << 4 ) | ((borders.top & 0x0F) << 8 ) | ((borders.bottom & 0x0F) << 12) | ((borders.left_colour & 0x7F) << 16) | ((borders.right_colour & 0x7F) << 23) | ((borders.need_diag1 & 0x01) << 30) | ((borders.need_diag2 & 0x01) << 31) ) brd2 = struct.pack('<L', ((borders.top_colour & 0x7F) << 0 ) | ((borders.bottom_colour & 0x7F) << 7 ) | ((borders.diag_colour & 0x7F) << 14) | ((borders.diag & 0x0F) << 21) | ((pattern.pattern & 0x0F) << 26) ) pat = struct.pack('<H', ((pattern.pattern_fore_colour & 0x7F) << 0 ) | ((pattern.pattern_back_colour & 0x7F) << 7 ) ) self._rec_data = fnt + fmt + prt + \ aln + rot + txt + used_attr + \ brd1 + brd2 + \ pat class StyleRecord(BiffRecord): """ STYLE record for user-defined cell styles, BIFF3-BIFF8: Offset Size Contents 0 2 Bit Mask Contents 11-0 0FFFH Index to style XF record 15 8000H Always 0 for user-defined styles 2 var. BIFF2-BIFF7: Non-empty byte string, 8-bit string length BIFF8: Non-empty Unicode string, 16-bit string length STYLE record for built-in cell styles, BIFF3-BIFF8: Offset Size Contents 0 2 Bit Mask Contents 11-0 0FFFH Index to style XF record 15 8000H Always 1 for built-in styles 2 1 Identifier of the built-in cell style: 00H = Normal 01H = RowLevel_lv (see next field) 02H = ColLevel_lv (see next field) 03H = Comma 04H = Currency 05H = Percent 06H = Comma [0] (BIFF4-BIFF8) 07H = Currency [0] (BIFF4-BIFF8) 08H = Hyperlink (BIFF8) 09H = Followed Hyperlink (BIFF8) 3 1 Level for RowLevel or ColLevel style (zero-based, lv), FFH otherwise The RowLevel and ColLevel styles specify the formatting of subtotal cells in a specific outline level. The level is specified by the last field in the STYLE record. Valid values are 0-6 for the outline levels 1-7. """ _REC_ID = 0x0293 def __init__(self): BiffRecord.__init__(self) self._rec_data = struct.pack('<HBB', 0x8000, 0x00, 0xFF) # TODO: implement user-defined styles??? class PaletteRecord(BiffRecord): """ This record contains the definition of all user-defined colours available for cell and object formatting. Record PALETTE, BIFF3-BIFF8: Offset Size Contents 0 2 Number of following colours (nm). Contains 16 in BIFF3-BIFF4 and 56 in BIFF5-BIFF8. 2 4*nm List of nm RGB colours The following table shows how colour indexes are used in other records: Colour index Resulting colour or internal list index 00H Built-in Black (R = 00H, G = 00H, B = 00H) 01H Built-in White (R = FFH, G = FFH, B = FFH) 02H Built-in Red (R = FFH, G = 00H, B = 00H) 03H Built-in Green (R = 00H, G = FFH, B = 00H) 04H Built-in Blue (R = 00H, G = 00H, B = FFH) 05H Built-in Yellow (R = FFH, G = FFH, B = 00H) 06H Built-in Magenta (R = FFH, G = 00H, B = FFH) 07H Built-in Cyan (R = 00H, G = FFH, B = FFH) 08H First user-defined colour from the PALETTE record (entry 0 from record colour list) ......................... 17H (BIFF3-BIFF4) Last user-defined colour from the PALETTE record (entry 15 or 55 from record colour list) 3FH (BIFF5-BIFF8) 18H (BIFF3-BIFF4) System window text colour for border lines (used in records XF, CF, and 40H (BIFF5-BIFF8) WINDOW2 (BIFF8 only)) 19H (BIFF3-BIFF4) System window background colour for pattern background (used in records XF, and CF) 41H (BIFF5-BIFF8) 43H System face colour (dialogue background colour) 4DH System window text colour for chart border lines 4EH System window background colour for chart areas 4FH Automatic colour for chart border lines (seems to be always Black) 50H System ToolTip background colour (used in note objects) 51H System ToolTip text colour (used in note objects) 7FFFH System window text colour for fonts (used in records FONT, EFONT, and CF) """ _REC_ID = 0x0092 class BoundSheetRecord(BiffRecord): """ This record is located in the workbook globals area and represents a sheet inside of the workbook. For each sheet a BOUNDSHEET record is written. It stores the sheet name and a stream offset to the BOF record within the workbook stream. The record is also known as BUNDLESHEET. Record BOUNDSHEET, BIFF5-BIFF8: Offset Size Contents 0 4 Absolute stream position of the BOF record of the sheet represented by this record. This field is never encrypted in protected files. 4 1 Visibility: 00H = Visible 01H = Hidden 02H = Strong hidden 5 1 Sheet type: 00H = Worksheet 02H = Chart 06H = Visual Basic module 6 var. Sheet name: BIFF5/BIFF7: Byte string, 8-bit string length BIFF8: Unicode string, 8-bit string length """ _REC_ID = 0x0085 def __init__(self, stream_pos, visibility, sheetname): BiffRecord.__init__(self) usheetname = upack1(sheetname) uusheetname_len = len(usheetname) self._rec_data = pack('<LBB%ds' % uusheetname_len, stream_pos, visibility, 0x00, usheetname) class ContinueRecord(BiffRecord): """ Whenever the content of a record exceeds the given limits (see table), the record must be split. Several CONTINUE records containing the additional data are added after the parent record. BIFF version Maximum data size of a record BIFF2-BIFF7 2080 bytes (2084 bytes including record header) BIFF8 8224 bytes (8228 bytes including record header) (0x2020) Record CONTINUE, BIFF2-BIFF8: Offset Size Contents 0 var. Data continuation of the previous record Unicode strings are split in a special way. At the beginning of each CONTINUE record the option flags byte is repeated. Only the character size flag will be set in this flags byte, the Rich-Text flag and the Far-East flag are set to zero. In each CONTINUE record it is possible that the character size changes from 8-bit characters to 16-bit characters and vice versa. Never a Unicode string is split until and including the first character. That means, all header fields (string length, option flags, optional Rich-Text size, and optional Far-East data size) and the first character of the string have to occur together in the leading record, or have to be moved completely into the CONTINUE record. Formatting runs cannot be split between their components (character index and FONT record index). If a string is split between two formatting runs, the option flags field will not be repeated in the CONTINUE record. """ _REC_ID = 0x003C class SSTRecord(BiffRecord): """ This record contains a list of all strings used anywhere in the workbook. Each string occurs only once. The workbook uses indexes into the list to reference the strings. Record SST, BIFF8: Offset Size Contents 0 4 Total number of strings in the workbook (see below) 4 4 Number of following strings (nm) 8 var. List of nm Unicode strings, 16-bit string length The first field of the SST record counts the total occurrence of strings in the workbook. For instance, the string AAA is used 3 times and the string BBB is used 2 times. The first field contains 5 and the second field contains 2, followed by the two strings. """ _REC_ID = 0x00FC class ExtSSTRecord(BiffRecord): """ This record occurs in conjunction with the SST record. It is used by Excel to create a hash table with stream offsets to the SST record to optimise string search operations. Excel may not shorten this record if strings are deleted from the shared string table, so the last part might contain invalid data. The stream indexes in this record divide the SST into portions containing a constant number of strings. Record EXTSST, BIFF8: Offset Size Contents 0 2 Number of strings in a portion, this number is >=8 2 var. List of OFFSET structures for all portions. Each OFFSET contains the following data: Offset Size Contents 0 4 Absolute stream position of first string of the portion 4 2 Position of first string of the portion inside of current record, including record header. This counter restarts at zero, if the SST record is continued with a CONTINUE record. 6 2 Not used """ _REC_ID = 0x00FF def __init__(self, sst_stream_pos, str_placement, portions_len): BiffRecord.__init__(self) extsst = {} abs_stream_pos = sst_stream_pos str_counter = 0 portion_counter = 0 while str_counter < len(str_placement): str_chunk_num, pos_in_chunk = str_placement[str_counter] if str_chunk_num <> portion_counter: portion_counter = str_chunk_num abs_stream_pos += portions_len[portion_counter-1] #print hex(abs_stream_pos) str_stream_pos = abs_stream_pos + pos_in_chunk + 4 # header extsst[str_counter] = (pos_in_chunk, str_stream_pos) str_counter += 1 exsst_str_count_delta = max(8, len(str_placement)*8/0x2000) # maybe smth else? self._rec_data = pack('<H', exsst_str_count_delta) str_counter = 0 while str_counter < len(str_placement): self._rec_data += pack('<IHH', extsst[str_counter][1], extsst[str_counter][0], 0) str_counter += exsst_str_count_delta class DimensionsRecord(BiffRecord): """ Record DIMENSIONS, BIFF8: Offset Size Contents 0 4 Index to first used row 4 4 Index to last used row, increased by 1 8 2 Index to first used column 10 2 Index to last used column, increased by 1 12 2 Not used """ _REC_ID = 0x0200 def __init__(self, first_used_row, last_used_row, first_used_col, last_used_col): BiffRecord.__init__(self) self._rec_data = struct.pack('<2L3H', first_used_row, last_used_row + 1, first_used_col, last_used_col + 1, 0x00) class Window2Record(BiffRecord): """ Record WINDOW2, BIFF8: Offset Size Contents 0 2 Option flags (see below) 2 2 Index to first visible row 4 2 Index to first visible column 6 2 Colour index of grid line colour. Note that in BIFF2-BIFF7 an RGB colour is written instead. 8 2 Not used 10 2 Cached magnification factor in page break preview (in percent); 0 = Default (60%) 12 2 Cached magnification factor in normal view (in percent); 0 = Default (100%) 14 4 Not used In BIFF8 this record stores used magnification factors for page break preview and normal view. These values are used to restore the magnification, when the view is changed. The real magnification of the currently active view is stored in the SCL record. The type of the active view is stored in the option flags field (see below). 0 0001H 0 = Show formula results 1 = Show formulas 1 0002H 0 = Do not show grid lines 1 = Show grid lines 2 0004H 0 = Do not show sheet headers 1 = Show sheet headers 3 0008H 0 = Panes are not frozen 1 = Panes are frozen (freeze) 4 0010H 0 = Show zero values as empty cells 1 = Show zero values 5 0020H 0 = Manual grid line colour 1 = Automatic grid line colour 6 0040H 0 = Columns from left to right 1 = Columns from right to left 7 0080H 0 = Do not show outline symbols 1 = Show outline symbols 8 0100H 0 = Keep splits if pane freeze is removed 1 = Remove splits if pane freeze is removed 9 0200H 0 = Sheet not selected 1 = Sheet selected (BIFF5-BIFF8) 10 0400H 0 = Sheet not visible 1 = Sheet visible (BIFF5-BIFF8) 11 0800H 0 = Show in normal view 1 = Show in page break preview (BIFF8) The freeze flag specifies, if a following PANE record describes unfrozen or frozen panes. """ _REC_ID = 0x023E def __init__(self, options, first_visible_row, first_visible_col, grid_colour, preview_magn, normal_magn): BiffRecord.__init__(self) self._rec_data = struct.pack('<7HL', options, first_visible_row, first_visible_col, grid_colour, 0x00, preview_magn, normal_magn, 0x00L) class PanesRecord(BiffRecord): """ This record stores the position of window panes. It is part of the Sheet View Settings Block. If the sheet does not contain any splits, this record will not occur. A sheet can be split in two different ways, with unfrozen panes or with frozen panes. A flag in the WINDOW2 record specifies, if the panes are frozen, which affects the contents of this record. Record PANE, BIFF2-BIFF8: Offset Size Contents 0 2 Position of the vertical split (px, 0 = No vertical split): Unfrozen pane: Width of the left pane(s) (in twips = 1/20 of a point) Frozen pane: Number of visible columns in left pane(s) 2 2 Position of the horizontal split (py, 0 = No horizontal split): Unfrozen pane: Height of the top pane(s) (in twips = 1/20 of a point) Frozen pane: Number of visible rows in top pane(s) 4 2 Index to first visible row in bottom pane(s) 6 2 Index to first visible column in right pane(s) 8 1 Identifier of pane with active cell cursor [9] 1 Not used (BIFF5-BIFF8 only, not written in BIFF2-BIFF4) If the panes are frozen, pane 0 is always active, regardless of the cursor position. The correct identifiers for all possible combinations of visible panes are shown in the following pictures. px = 0, py = 0 px = 0, py > 0 -------------------------- ------------|------------- | | | | | | | 3 | | | | | - 3 - -------------------------- | | | | | | | 2 | | | | | -------------------------- ------------|------------- px > 0, py = 0 px > 0, py > 0 ------------|------------- ------------|------------- | | | | | | | | | | 3 | 2 | | | | | | | - 3 | 1 - -------------------------- | | | | | | | | | | 1 | 0 | | | | | | | ------------|------------- ------------|------------- """ _REC_ID = 0x0041 def __init__(self, px, py, first_row_bottom, first_col_right, active_pane): BiffRecord.__init__(self) self._rec_data = struct.pack('<5H', px, py, first_row_bottom, first_col_right, active_pane) class RowRecord(BiffRecord): """ This record contains the properties of a single row in a sheet. Rows and cells in a sheet are divided into blocks of 32 rows. Record ROW, BIFF3-BIFF8: Offset Size Contents 0 2 Index of this row 2 2 Index to column of the first cell which is described by a cell record 4 2 Index to column of the last cell which is described by a cell record, increased by 1 6 2 Bit Mask Contents 14-0 7FFFH Height of the row, in twips = 1/20 of a point 15 8000H 0 = Row has custom height; 1 = Row has default height 8 2 Not used 10 2 In BIFF3-BIFF4 this field contains a relative offset to calculate stream position of the first cell record for this row. In BIFF5-BIFF8 this field is not used anymore, but the DBCELL record instead. 12 4 Option flags and default row formatting: Bit Mask Contents 2-0 00000007H Outline level of the row 4 00000010H 1 = Outline group starts or ends here (depending on where the outline buttons are located, see WSBOOL record), and is collapsed 5 00000020H 1 = Row is hidden (manually, or by a filter or outline group) 6 00000040H 1 = Row height and default font height do not match 7 00000080H 1 = Row has explicit default format (fl) 8 00000100H Always 1 27-16 0FFF0000H If fl=1: Index to default XF record 28 10000000H 1 = Additional space above the row. This flag is set, if the upper border of at least one cell in this row or if the lower border of at least one cell in the row above is formatted with a thick line style. Thin and medium line styles are not taken into account. 29 20000000H 1 = Additional space below the row. This flag is set, if the lower border of at least one cell in this row or if the upper border of at least one cell in the row below is formatted with a medium or thick line style. Thin line styles are not taken into account. """ _REC_ID = 0x0208 def __init__(self, index, first_col, last_col, height_options, options): BiffRecord.__init__(self) self._rec_data = struct.pack('<6HL', index, first_col, last_col + 1, height_options, 0x00, 0x00, options) class LabelSSTRecord(BiffRecord): """ This record represents a cell that contains a string. It replaces the LABEL record and RSTRING record used in BIFF2-BIFF7. """ _REC_ID = 0x00FD def __init__(self, row, col, xf_idx, sst_idx): BiffRecord.__init__(self) self._rec_data = struct.pack('<3HL', row, col, xf_idx, sst_idx) class MergedCellsRecord(BiffRecord): """ This record contains all merged cell ranges of the current sheet. Record MERGEDCELLS, BIFF8: Offset Size Contents 0 var. Cell range address list with all merged ranges ------------------------------------------------------------------ A cell range address list consists of a field with the number of ranges and the list of the range addresses. Cell range address list, BIFF8: Offset Size Contents 0 2 Number of following cell range addresses (nm) 2 8*nm List of nm cell range addresses --------------------------------------------------------------------- Cell range address, BIFF8: Offset Size Contents 0 2 Index to first row 2 2 Index to last row 4 2 Index to first column 6 2 Index to last column """ _REC_ID = 0x00E5 def __init__(self, merged_list): BiffRecord.__init__(self) i = len(merged_list) - 1 while i >= 0: j = 0 merged = '' while (i >= 0) and (j < 0x403): r1, r2, c1, c2 = merged_list[i] merged += struct.pack('<4H', r1, r2, c1, c2) i -= 1 j += 1 self._rec_data += struct.pack('<3H', self._REC_ID, len(merged) + 2, j) + \ merged # for some reason Excel doesn't use CONTINUE def get(self): return self._rec_data class MulBlankRecord(BiffRecord): """ This record represents a cell range of empty cells. All cells are located in the same row. Record MULBLANK, BIFF5-BIFF8: Offset Size Contents 0 2 Index to row 2 2 Index to first column (fc) 4 2*nc List of nc=lc-fc+1 16-bit indexes to XF records 4+2*nc 2 Index to last column (lc) """ _REC_ID = 0x00BE def __init__(self, row, first_col, last_col, xf_index): BiffRecord.__init__(self) blanks_count = last_col-first_col+1 self._rec_data = struct.pack('%dH' % blanks_count, *([xf_index]*blanks_count)) self._rec_data = struct.pack('<2H', row, first_col) + self._rec_data + struct.pack('<H', last_col) class BlankRecord(BiffRecord): """ This record represents an empty cell. Record BLANK, BIFF5-BIFF8: Offset Size Contents 0 2 Index to row 2 2 Index to first column (fc) 4 2 indexes to XF record """ _REC_ID = 0x0201 def __init__(self, row, col, xf_index): BiffRecord.__init__(self) self._rec_data = struct.pack('<3H', row, col, xf_index) class RKRecord(BiffRecord): """ This record represents a cell that contains an RK value (encoded integer or floating-point value). If a floating-point value cannot be encoded to an RK value, a NUMBER record will be written. """ _REC_ID = 0x027E def __init__(self, row, col, xf_index, rk_encoded): BiffRecord.__init__(self) self._rec_data = struct.pack('<3HI', row, col, xf_index, rk_encoded) class NumberRecord(BiffRecord): """ This record represents a cell that contains an IEEE-754 floating-point value. """ _REC_ID = 0x0203 def __init__(self, row, col, xf_index, number): BiffRecord.__init__(self) self._rec_data = struct.pack('<3Hd', row, col, xf_index, number) class FormulaRecord(BiffRecord): """ Offset Size Contents 0 2 Index to row 2 2 Index to column 4 2 Index to XF record 6 8 Result of the formula 14 2 Option flags: Bit Mask Contents 0 0001H 1 = Recalculate always 1 0002H 1 = Calculate on open 3 0008H 1 = Part of a shared formula 16 4 Not used 20 var. Formula data (RPN token array) """ _REC_ID = 0x0006 def __init__(self, row, col, xf_index, rpn): BiffRecord.__init__(self) self._rec_data = struct.pack('<3HQHL', row, col, xf_index, 0xFFFF000000000003, 0, 0) + rpn class GutsRecord(BiffRecord): """ This record contains information about the layout of outline symbols. Record GUTS, BIFF3-BIFF8: Offset Size Contents 0 2 Width of the area to display row outlines (left of the sheet), in pixel 2 2 Height of the area to display column outlines (above the sheet), in pixel 4 2 Number of visible row outline levels (used row levels + 1; or 0, if not used) 6 2 Number of visible column outline levels (used column levels + 1; or 0, if not used) """ _REC_ID = 0x0080 def __init__(self, row_gut_width, col_gut_height, row_visible_levels, col_visible_levels): BiffRecord.__init__(self) self._rec_data = struct.pack('<4H', row_gut_width, col_gut_height, row_visible_levels, col_visible_levels) class WSBoolRecord(BiffRecord): """ This record stores a 16 bit value with Boolean options for the current sheet. From BIFF5 on the "Save external linked values" option is moved to the record BOOKBOOL. Option flags of record WSBOOL, BIFF3-BIFF8: Bit Mask Contents 0 0001H 0 = Do not show automatic page breaks 1 = Show automatic page breaks 4 0010H 0 = Standard sheet 1 = Dialogue sheet (BIFF5-BIFF8) 5 0020H 0 = No automatic styles in outlines 1 = Apply automatic styles to outlines 6 0040H 0 = Outline buttons above outline group 1 = Outline buttons below outline group 7 0080H 0 = Outline buttons left of outline group 1 = Outline buttons right of outline group 8 0100H 0 = Scale printout in percent 1 = Fit printout to number of pages 9 0200H 0 = Save external linked values (BIFF3?BIFF4 only) 1 = Do not save external linked values (BIFF3?BIFF4 only) 10 0400H 0 = Do not show row outline symbols 1 = Show row outline symbols 11 0800H 0 = Do not show column outline symbols 1 = Show column outline symbols 13-12 3000H These flags specify the arrangement of windows. They are stored in BIFF4 only. 00 = Arrange windows tiled 01 = Arrange windows horizontal 10 = Arrange windows vertical112 = Arrange windows cascaded The following flags are valid for BIFF4-BIFF8 only: 14 4000H 0 = Standard expression evaluation 1 = Alternative expression evaluation 15 8000H 0 = Standard formula entries 1 = Alternative formula entries """ _REC_ID = 0x0081 def __init__(self, options): BiffRecord.__init__(self) self._rec_data = struct.pack('<H', options) class ColInfoRecord(BiffRecord): """ This record specifies the width for a given range of columns. If a column does not have a corresponding COLINFO record, the width specified in the record STANDARDWIDTH is used. If this record is also not present, the contents of the record DEFCOLWIDTH is used instead. This record also specifies a default XF record to use for cells in the columns that are not described by any cell record (which contain the XF index for that cell). Additionally, the option flags field contains hidden, outline, and collapsed options applied at the columns. Record COLINFO, BIFF3-BIFF8: Offset Size Contents 0 2 Index to first column in the range 2 2 Index to last column in the range 4 2 Width of the columns in 1/256 of the width of the zero character, using default font (first FONT record in the file) 6 2 Index to XF record for default column formatting 8 2 Option flags: Bits Mask Contents 0 0001H 1 = Columns are hidden 10-8 0700H Outline level of the columns (0 = no outline) 12 1000H 1 = Columns are collapsed 10 2 Not used """ _REC_ID = 0x007D def __init__(self, first_col, last_col, width, xf_index, options): BiffRecord.__init__(self) self._rec_data = struct.pack('<6H', first_col, last_col, width, xf_index, options, 0) class CalcModeRecord(BiffRecord): """ This record is part of the Calculation Settings Block. It specifies whether to calculate formulas manually, automatically or automatically except for multiple table operations. Record CALCMODE, BIFF2-BIFF8: Offset Size Contents 0 2 FFFFH = automatic except for multiple table operations 0000H = manually 0001H = automatically (default) """ _REC_ID = 0x000D def __init__(self, calc_mode): BiffRecord.__init__(self) self._rec_data = struct.pack('<h', calc_mode) class CalcCountRecord(BiffRecord): """ This record is part of the Calculation Settings Block. It specifies the maximum number of times the formulas should be iteratively calculated. This is a fail-safe against mutually recursive formulas locking up a spreadsheet application. Record CALCCOUNT, BIFF2-BIFF8: Offset Size Contents 0 2 Maximum number of iterations allowed in circular references """ _REC_ID = 0x000C def __init__(self, calc_count): BiffRecord.__init__(self) self._rec_data = struct.pack('<H', calc_count) class RefModeRecord(BiffRecord): """ This record is part of the Calculation Settings Block. It stores which method is used to show cell addresses in formulas. The “RC” mode uses numeric indexes for rows and columns, i.e. “R(1)C(-1)”, or “R1C1:R2C2”. The “A1” mode uses characters for columns and numbers for rows, i.e. “B1”, or “$A$1:$B$2”. Record REFMODE, BIFF2-BIFF8: Offset Size Contents 0 2 0 = RC mode; 1 = A1 mode """ _REC_ID = 0x00F def __init__(self, ref_mode): BiffRecord.__init__(self) self._rec_data = struct.pack('<H', ref_mode) class IterationRecord(BiffRecord): """ This record is part of the Calculation Settings Block. It stores if iterations are allowed while calculating recursive formulas. Record ITERATION, BIFF2-BIFF8: Offset Size Contents 0 2 0 = Iterations off; 1 = Iterations on """ _REC_ID = 0x011 def __init__(self, iterations_on): BiffRecord.__init__(self) self._rec_data = struct.pack('<H', iterations_on) class DeltaRecord(BiffRecord): """ This record is part of the Calculation Settings Block. It stores the maximum change of the result to exit an iteration. Record DELTA, BIFF2-BIFF8: Offset Size Contents 0 8 Maximum change in iteration (IEEE 754 floating-point value, 64bit double precision) """ _REC_ID = 0x010 def __init__(self, delta): BiffRecord.__init__(self) self._rec_data = struct.pack('<d', delta) class SaveRecalcRecord(BiffRecord): """ This record is part of the Calculation Settings Block. It contains the “Recalculate before save” option in Excel's calculation settings dialogue. Record SAVERECALC, BIFF3-BIFF8: Offset Size Contents 0 2 0 = Do not recalculate; 1 = Recalculate before saving the document """ _REC_ID = 0x05F def __init__(self, recalc): BiffRecord.__init__(self) self._rec_data = struct.pack('<H', recalc) class PrintHeadersRecord(BiffRecord): """ This record stores if the row and column headers (the areas with row numbers and column letters) will be printed. Record PRINTHEADERS, BIFF2-BIFF8: Offset Size Contents 0 2 0 = Do not print row/column headers; 1 = Print row/column headers """ _REC_ID = 0x02A def __init__(self, print_headers): BiffRecord.__init__(self) self._rec_data = struct.pack('<H', print_headers) class PrintGridLinesRecord(BiffRecord): """ This record stores if sheet grid lines will be printed. Record PRINTGRIDLINES, BIFF2-BIFF8: Offset Size Contents 0 2 0 = Do not print sheet grid lines; 1 = Print sheet grid lines """ _REC_ID = 0x02B def __init__(self, print_grid): BiffRecord.__init__(self) self._rec_data = struct.pack('<H', print_grid) class GridSetRecord(BiffRecord): """ This record specifies if the option to print sheet grid lines (record PRINTGRIDLINES) has ever been changed. Record GRIDSET, BIFF3-BIFF8: Offset Size Contents 0 2 0 = Print grid lines option never changed 1 = Print grid lines option changed """ _REC_ID = 0x082 def __init__(self, print_grid_changed): BiffRecord.__init__(self) self._rec_data = struct.pack('<H', print_grid_changed) class DefaultRowHeight(BiffRecord): """ This record specifies the default height and default flags for rows that do not have a corresponding ROW record. Record DEFAULTROWHEIGHT, BIFF3-BIFF8: Offset Size Contents 0 2 Option flags: Bit Mask Contents 0 0001H 1 = Row height and default font height do not match 1 0002H 1 = Row is hidden 2 0004H 1 = Additional space above the row 3 0008H 1 = Additional space below the row 2 2 Default height for unused rows, in twips = 1/20 of a point """ _REC_ID = 0x0225 def __init__(self, options, def_height): BiffRecord.__init__(self) self._rec_data = struct.pack('<2H', options, def_height) class DefColWidthRecord(BiffRecord): """ This record specifies the default column width for columns that do not have a specific width set using the record COLINFO or COLWIDTH. This record has no effect, if a STANDARDWIDTH record is present in the file. Record DEFCOLWIDTH, BIFF2-BIFF8: Offset Size Contents 0 2 Column width in characters, using the width of the zero character from default font (first FONT record in the file) """ _REC_ID = 0x0055 def __init__(self, def_width): BiffRecord.__init__(self) self._rec_data = struct.pack('<H', options, def_width) class HorizontalPageBreaksRecord(BiffRecord): """ This record is part of the Page Settings Block. It contains all horizontal manual page breaks. Record HORIZONTALPAGEBREAKS, BIFF8: Offset Size Contents 0 2 Number of following row index structures (nm) 2 6nm List of nm row index structures. Each row index structure contains: Offset Size Contents 0 2 Index to first row below the page break 2 2 Index to first column of this page break 4 2 Index to last column of this page break The row indexes in the lists must be ordered ascending. If in BIFF8 a row contains several page breaks, they must be ordered ascending by start column index. """ _REC_ID = 0x001B def __init__(self, breaks_list): BiffRecord.__init__(self) self._rec_data = struct.pack('<H', len(breaks_list)) for r, c1, c2 in breaks_list: self._rec_data += struct.pack('<3H', r, c1, c2) class VerticalPageBreaksRecord(BiffRecord): """ This record is part of the Page Settings Block. It contains all vertical manual page breaks. Record VERTICALPAGEBREAKS, BIFF8: Offset Size Contents 0 2 Number of following column index structures (nm) 2 6nm List of nm column index structures. Each column index structure contains: Offset Size Contents 0 2 Index to first column following the page break 2 2 Index to first row of this page break 4 2 Index to last row of this page break The column indexes in the lists must be ordered ascending. If in BIFF8 a column contains several page breaks, they must be ordered ascending by start row index. """ _REC_ID = 0x001A def __init__(self, breaks_list): BiffRecord.__init__(self) self._rec_data = struct.pack('<H', len(breaks_list)) for r, c1, c2 in breaks_list: self._rec_data += struct.pack('<3H', r, c1, c2) class HeaderRecord(BiffRecord): """ This record is part of the Page Settings Block. It specifies the page header string for the current worksheet. If this record is not present or completely empty (record size is 0), the sheet does not contain a page header. Record HEADER for non-empty page header, BIFF2-BIFF8: Offset Size Contents 0 var. Page header string BIFF2-BIFF7: Non-empty byte string, 8bit string length BIFF8: Non-empty Unicode string, 16bit string length The header string may contain special commands, i.e. placeholders for the page number, current date, or text formatting attributes. These fields are represented by single letters (exception: font name and size, see below) with a leading ampersand ("&"). If the ampersand is part of the regular header text, it will be duplicated ("&&"). The page header is divided into 3 sections: the left, the centred, and the right section. Each section is introduced by a special command. All text and all commands following are part of the selected section. Each section starts with the text formatting specified in the default font (first FONT record in the file). Active formatting attributes from a previous section do not go into the next section. The following table shows all available commands: Command Contents && The "&" character itself &L Start of the left section &C Start of the centred section &R Start of the right section &P Current page number &N Page count &D Current date &T Current time &A Sheet name (BIFF5-BIFF8) &F File name without path &Z File path without file name (BIFF8X) &G Picture (BIFF8X) &B Bold on/off (BIFF2-BIFF4) &I Italic on/off (BIFF2-BIFF4) &U Underlining on/off &E Double underlining on/off (BIFF5-BIFF8) &S Strikeout on/off &X Superscript on/off (BIFF5-BIFF8) &Y Subscript on/off (BIFF5-BIFF8) &"<fontname>" Set new font <fontname> &"<fontname>,<fontstyle>" Set new font with specified style <fontstyle>. The style <fontstyle> is in most cases one of "Regular", "Bold", "Italic", or "Bold Italic". But this setting is dependent on the used font, it may differ (localised style names, or "Standard", "Oblique", ...). (BIFF5-BIFF8) &<fontheight> Set font height in points (<fontheight> is a decimal value). If this command is followed by a plain number to be printed in the header, it will be separated from the font height with a space character. """ _REC_ID = 0x0014 def __init__(self, header_str): BiffRecord.__init__(self) self._rec_data = upack2(header_str) class FooterRecord(BiffRecord): """ Semantic is equal to HEADER record """ _REC_ID = 0x0015 def __init__(self, footer_str): BiffRecord.__init__(self) self._rec_data = upack2(footer_str) class HCenterRecord(BiffRecord): """ This record is part of the Page Settings Block. It specifies if the sheet is centred horizontally when printed. Record HCENTER, BIFF3-BIFF8: Offset Size Contents 0 2 0 = Print sheet left aligned 1 = Print sheet centred horizontally """ _REC_ID = 0x0083 def __init__(self, is_horz_center): BiffRecord.__init__(self) self._rec_data = struct.pack('<H', is_horz_center) class VCenterRecord(BiffRecord): """ This record is part of the Page Settings Block. It specifies if the sheet is centred vertically when printed. Record VCENTER, BIFF3-BIFF8: Offset Size Contents 0 2 0 = Print sheet aligned at top page border 1 = Print sheet vertically centred """ _REC_ID = 0x0084 def __init__(self, is_vert_center): BiffRecord.__init__(self) self._rec_data = struct.pack('<H', is_vert_center) class LeftMarginRecord(BiffRecord): """ This record is part of the Page Settings Block. It contains the left page margin of the current worksheet. Record LEFTMARGIN, BIFF2-BIFF8: Offset Size Contents 0 8 Left page margin in inches (IEEE 754 floating-point value, 64bit double precision) """ _REC_ID = 0x0026 def __init__(self, margin): BiffRecord.__init__(self) self._rec_data = struct.pack('<d', margin) class RightMarginRecord(BiffRecord): """ This record is part of the Page Settings Block. It contains the right page margin of the current worksheet. Offset Size Contents 0 8 Right page margin in inches (IEEE 754 floating-point value, 64?bit double precision) """ _REC_ID = 0x0027 def __init__(self, margin): BiffRecord.__init__(self) self._rec_data = struct.pack('<d', margin) class TopMarginRecord(BiffRecord): """ This record is part of the Page Settings Block. It contains the top page margin of the current worksheet. Offset Size Contents 0 8 Top page margin in inches (IEEE 754 floating-point value, 64?bit double precision) """ _REC_ID = 0x0028 def __init__(self, margin): BiffRecord.__init__(self) self._rec_data = struct.pack('<d', margin) class BottomMarginRecord(BiffRecord): """ This record is part of the Page Settings Block. It contains the bottom page margin of the current worksheet. Offset Size Contents 0 8 Bottom page margin in inches (IEEE 754 floating-point value, 64?bit double precision) """ _REC_ID = 0x0029 def __init__(self, margin): BiffRecord.__init__(self) self._rec_data = struct.pack('<d', margin) class SetupPageRecord(BiffRecord): """ This record is part of the Page Settings Block. It stores the page format settings of the current sheet. The pages may be scaled in percent or by using an absolute number of pages. This setting is located in the WSBOOL record. If pages are scaled in percent, the scaling factor in this record is used, otherwise the "Fit to pages" values. One of the "Fit to pages" values may be 0. In this case the sheet is scaled to fit only to the other value. Record SETUP, BIFF5-BIFF8: Offset Size Contents 0 2 Paper size (see below) 2 2 Scaling factor in percent 4 2 Start page number 6 2 Fit worksheet width to this number of pages (0 = use as many as needed) 8 2 Fit worksheet height to this number of pages (0 = use as many as needed) 10 2 Option flags: Bit Mask Contents 0 0001H 0 = Print pages in columns 1 = Print pages in rows 1 0002H 0 = Landscape 1 = Portrait 2 0004H 1 = Paper size, scaling factor, paper orientation (portrait/landscape), print resolution and number of copies are not initialised 3 0008H 0 = Print coloured 1 = Print black and white 4 0010H 0 = Default print quality 1 = Draft quality 5 0020H 0 = Do not print cell notes 1 = Print cell notes 6 0040H 0 = Paper orientation setting is valid 1 = Paper orientation setting not initialised 7 0080H 0 = Automatic page numbers 1 = Use start page number The following flags are valid for BIFF8 only: 9 0200H 0 = Print notes as displayed 1 = Print notes at end of sheet 11-10 0C00H 00 = Print errors as displayed 01 = Do not print errors 10 = Print errors as "--" 11 = Print errors as "#N/A!" 12 2 Print resolution in dpi 14 2 Vertical print resolution in dpi 16 8 Header margin (IEEE 754 floating-point value, 64bit double precision) 24 8 Footer margin (IEEE 754 floating-point value, 64bit double precision) 32 2 Number of copies to print PAPER TYPES: Index Paper type Paper size 0 Undefined 1 Letter 8 1/2" x 11" 2 Letter small 8 1/2" x 11" 3 Tabloid 11" x 17" 4 Ledger 17" x 11" 5 Legal 8 1/2" x 14" 6 Statement 5 1/2" x 8 1/2" 7 Executive 7 1/4" x 10 1/2" 8 A3 297mm x 420mm 9 A4 210mm x 297mm 10 A4 small 210mm x 297mm 11 A5 148mm x 210mm 12 B4 (JIS) 257mm x 364mm 13 B5 (JIS) 182mm x 257mm 14 Folio 8 1/2" x 13" 15 Quarto 215mm x 275mm 16 10x14 10" x 14" 17 11x17 11" x 17" 18 Note 8 1/2" x 11" 19 Envelope #9 3 7/8" x 8 7/8" 20 Envelope #10 4 1/8" x 9 1/2" 21 Envelope #11 4 1/2" x 10 3/8" 22 Envelope #12 4 3/4" x 11" 23 Envelope #14 5" x 11 1/2" 24 C 17" x 22" 25 D 22" x 34" 26 E 34" x 44" 27 Envelope DL 110mm x 220mm 28 Envelope C5 162mm x 229mm 29 Envelope C3 324mm x 458mm 30 Envelope C4 229mm x 324mm 31 Envelope C6 114mm x 162mm 32 Envelope C6/C5 114mm x 229mm 33 B4 (ISO) 250mm x 353mm 34 B5 (ISO) 176mm x 250mm 35 B6 (ISO) 125mm x 176mm 36 Envelope Italy 110mm x 230mm 37 Envelope Monarch 3 7/8" x 7 1/2" 38 63/4 Envelope 3 5/8" x 6 1/2" 39 US Standard Fanfold 14 7/8" x 11" 40 German Std. Fanfold 8 1/2" x 12" 41 German Legal Fanfold 8 1/2" x 13" 42 B4 (ISO) 250mm x 353mm 43 Japanese Postcard 100mm x 148mm 44 9x11 9" x 11" 45 10x11 10" x 11" 46 15x11 15" x 11" 47 Envelope Invite 220mm x 220mm 48 Undefined 49 Undefined 50 Letter Extra 9 1/2" x 12" 51 Legal Extra 9 1/2" x 15" 52 Tabloid Extra 11 11/16" x 18" 53 A4 Extra 235mm x 322mm 54 Letter Transverse 8 1/2" x 11" 55 A4 Transverse 210mm x 297mm 56 Letter Extra Transv. 9 1/2" x 12" 57 Super A/A4 227mm x 356mm 58 Super B/A3 305mm x 487mm 59 Letter Plus 8 1/2" x 12 11/16" 60 A4 Plus 210mm x 330mm 61 A5 Transverse 148mm x 210mm 62 B5 (JIS) Transverse 182mm x 257mm 63 A3 Extra 322mm x 445mm 64 A5 Extra 174mm x 235mm 65 B5 (ISO) Extra 201mm x 276mm 66 A2 420mm x 594mm 67 A3 Transverse 297mm x 420mm 68 A3 Extra Transverse 322mm x 445mm 69 Dbl. Japanese Postcard 200mm x 148mm 70 A6 105mm x 148mm 71 72 73 74 75 Letter Rotated 11" x 8 1/2" 76 A3 Rotated 420mm x 297mm 77 A4 Rotated 297mm x 210mm 78 A5 Rotated 210mm x 148mm 79 B4 (JIS) Rotated 364mm x 257mm 80 B5 (JIS) Rotated 257mm x 182mm 81 Japanese Postcard Rot. 148mm x 100mm 82 Dbl. Jap. Postcard Rot. 148mm x 200mm 83 A6 Rotated 148mm x 105mm 84 85 86 87 88 B6 (JIS) 128mm x 182mm 89 B6 (JIS) Rotated 182mm x 128mm 90 12x11 12" x 11" """ _REC_ID = 0x00A1 def __init__(self, paper, scaling, start_num, fit_width_to, fit_height_to, options, hres, vres, header_margin, footer_margin, num_copies): BiffRecord.__init__(self) self._rec_data = struct.pack('<8H2dH', paper, scaling, start_num, fit_width_to, fit_height_to, \ options, hres, vres, header_margin, footer_margin, num_copies)
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 10061, 13, 21381, 1882, 199, 199, 3, 221, 1898, 334, 35, 9, 11811, 820, 21604, 812, 14, 1804, 572, 317, 8822, 199, 3, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 221, 787, 7647, 26, 199, 3, 199, 3, 221, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 221, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 199, 3, 258, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 258, 4084, 14, 199, 3, 199, 3, 221, 650, 14, 2900, 19613, 1044, 8418, 20811, 316, 4534, 503, 675, 402, 642, 199, 3, 258, 2032, 1471, 2929, 314, 2569, 19807, 28609, 4740, 26, 199, 3, 258, 298, 2765, 3336, 6952, 2032, 477, 27813, 701, 199, 3, 420, 820, 21604, 812, 14, 1804, 572, 317, 8822, 665, 20971, 32, 75, 572, 317, 8822, 14, 6558, 30, 2122, 199, 3, 199, 3, 221, 841, 14, 6823, 402, 1263, 1824, 4052, 1152, 5907, 1471, 8074, 314, 2569, 199, 3, 258, 19807, 28609, 4740, 26, 199, 3, 258, 298, 2765, 3336, 6952, 2032, 477, 27813, 701, 199, 3, 420, 820, 21604, 812, 14, 1804, 572, 317, 8822, 665, 20971, 32, 75, 572, 317, 8822, 14, 6558, 30, 2122, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 820, 21604, 812, 14, 1804, 572, 317, 8822, 1124, 1179, 2281, 891, 2401, 1821, 199, 3, 221, 3651, 14956, 10934, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 221, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 221, 3104, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 820, 21604, 812, 14, 1804, 572, 317, 8822, 1549, 199, 3, 221, 473, 9730, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 221, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 199, 3, 221, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 221, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 199, 3, 221, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 199, 3, 221, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 199, 3, 221, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 199, 3, 221, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 363, 4964, 63, 344, 363, 275, 408, 4, 1304, 26, 699, 24150, 14941, 14, 647, 12, 86, 413, 14, 23, 11811, 15, 709, 15, 1479, 24937, 26, 1602, 26, 1194, 4336, 75, 7910, 2672, 624, 421, 199, 504, 2702, 492, 1706, 199, 504, 6140, 7535, 492, 627, 199, 646, 984, 199, 199, 533, 23752, 1558, 3186, 8, 785, 304, 272, 485, 51, 840, 63, 998, 275, 378, 88, 383, 4161, 272, 485, 26663, 4187, 63, 998, 275, 378, 88, 8262, 35, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 83, 270, 63, 3059, 275, 2125, 267, 291, 423, 6958, 83, 275, 942, 267, 291, 423, 1818, 63, 20082, 275, 1706, 4827, 8921, 297, 378, 12, 378, 9, 267, 291, 423, 1712, 275, 822, 8, 277, 423, 1818, 63, 20082, 9, 398, 291, 423, 495, 63, 10116, 275, 1052, 267, 291, 423, 525, 63, 5352, 275, 378, 339, 347, 1050, 63, 495, 8, 277, 12, 308, 304, 267, 291, 423, 525, 63, 5352, 847, 413, 267, 340, 308, 440, 315, 291, 423, 495, 63, 10116, 26, 288, 291, 423, 495, 63, 10116, 59, 83, 61, 275, 822, 8, 277, 423, 495, 63, 10116, 9, 288, 291, 423, 525, 63, 475, 63, 83, 270, 8, 83, 9, 267, 372, 291, 423, 495, 63, 10116, 59, 83, 61, 339, 347, 620, 63, 1080, 8, 277, 12, 308, 304, 267, 372, 291, 423, 495, 63, 10116, 59, 83, 61, 339, 347, 664, 63, 4492, 556, 63, 3059, 8, 277, 304, 267, 291, 423, 1222, 63, 20082, 342, 267, 754, 275, 1706, 4827, 18, 40, 8921, 297, 291, 423, 51, 840, 63, 998, 12, 822, 8, 277, 423, 83, 270, 63, 3059, 395, 291, 423, 525, 63, 5352, 12, 822, 8, 277, 423, 495, 63, 10116, 430, 267, 754, 847, 291, 423, 83, 270, 63, 3059, 59, 24, 2938, 267, 754, 847, 6522, 904, 8, 277, 423, 6958, 83, 9, 267, 372, 754, 339, 347, 485, 525, 63, 475, 63, 83, 270, 8, 277, 12, 308, 304, 267, 399, 63, 495, 275, 1536, 564, 18, 8, 83, 9, 267, 340, 822, 8, 85, 63, 495, 9, 690, 378, 23973, 26, 288, 746, 2186, 360, 705, 26, 7437, 1846, 1059, 2659, 398, 365, 63, 2975, 63, 495, 275, 399, 63, 495, 59, 18, 61, 508, 1557, 88, 614, 7, 267, 340, 365, 63, 2975, 63, 495, 26, 288, 6222, 63, 552, 275, 959, 327, 499, 3696, 1553, 822, 12, 586, 327, 413, 3696, 1553, 1511, 12, 586, 327, 499, 3696, 1553, 413, 270, 4678, 267, 587, 26, 288, 6222, 63, 552, 275, 841, 327, 499, 3696, 1553, 822, 12, 586, 327, 413, 3696, 1553, 1511, 12, 586, 327, 413, 3696, 1553, 413, 270, 4678, 398, 291, 423, 2117, 63, 4188, 8, 85, 63, 495, 59, 16, 26, 4188, 63, 552, 566, 267, 291, 423, 2117, 63, 1294, 471, 8, 85, 63, 495, 59, 4188, 63, 552, 8429, 365, 63, 2975, 63, 495, 9, 339, 347, 485, 1222, 63, 20082, 8, 277, 304, 267, 340, 291, 423, 83, 270, 63, 3059, 508, 8061, 288, 291, 423, 83, 270, 63, 3059, 275, 291, 423, 1818, 63, 20082, 267, 587, 26, 288, 8230, 63, 20082, 63, 552, 275, 822, 8, 277, 423, 1818, 63, 20082, 9, 288, 291, 423, 6958, 83, 14, 740, 8, 1389, 4827, 18, 40, 5, 795, 5956, 9808 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 10061, 13, 21381, 1882, 199, 199, 3, 221, 1898, 334, 35, 9, 11811, 820, 21604, 812, 14, 1804, 572, 317, 8822, 199, 3, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 221, 787, 7647, 26, 199, 3, 199, 3, 221, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 221, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 199, 3, 258, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 258, 4084, 14, 199, 3, 199, 3, 221, 650, 14, 2900, 19613, 1044, 8418, 20811, 316, 4534, 503, 675, 402, 642, 199, 3, 258, 2032, 1471, 2929, 314, 2569, 19807, 28609, 4740, 26, 199, 3, 258, 298, 2765, 3336, 6952, 2032, 477, 27813, 701, 199, 3, 420, 820, 21604, 812, 14, 1804, 572, 317, 8822, 665, 20971, 32, 75, 572, 317, 8822, 14, 6558, 30, 2122, 199, 3, 199, 3, 221, 841, 14, 6823, 402, 1263, 1824, 4052, 1152, 5907, 1471, 8074, 314, 2569, 199, 3, 258, 19807, 28609, 4740, 26, 199, 3, 258, 298, 2765, 3336, 6952, 2032, 477, 27813, 701, 199, 3, 420, 820, 21604, 812, 14, 1804, 572, 317, 8822, 665, 20971, 32, 75, 572, 317, 8822, 14, 6558, 30, 2122, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 820, 21604, 812, 14, 1804, 572, 317, 8822, 1124, 1179, 2281, 891, 2401, 1821, 199, 3, 221, 3651, 14956, 10934, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 221, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 221, 3104, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 820, 21604, 812, 14, 1804, 572, 317, 8822, 1549, 199, 3, 221, 473, 9730, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 221, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 199, 3, 221, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 221, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 199, 3, 221, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 199, 3, 221, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 199, 3, 221, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 199, 3, 221, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 363, 4964, 63, 344, 363, 275, 408, 4, 1304, 26, 699, 24150, 14941, 14, 647, 12, 86, 413, 14, 23, 11811, 15, 709, 15, 1479, 24937, 26, 1602, 26, 1194, 4336, 75, 7910, 2672, 624, 421, 199, 504, 2702, 492, 1706, 199, 504, 6140, 7535, 492, 627, 199, 646, 984, 199, 199, 533, 23752, 1558, 3186, 8, 785, 304, 272, 485, 51, 840, 63, 998, 275, 378, 88, 383, 4161, 272, 485, 26663, 4187, 63, 998, 275, 378, 88, 8262, 35, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 83, 270, 63, 3059, 275, 2125, 267, 291, 423, 6958, 83, 275, 942, 267, 291, 423, 1818, 63, 20082, 275, 1706, 4827, 8921, 297, 378, 12, 378, 9, 267, 291, 423, 1712, 275, 822, 8, 277, 423, 1818, 63, 20082, 9, 398, 291, 423, 495, 63, 10116, 275, 1052, 267, 291, 423, 525, 63, 5352, 275, 378, 339, 347, 1050, 63, 495, 8, 277, 12, 308, 304, 267, 291, 423, 525, 63, 5352, 847, 413, 267, 340, 308, 440, 315, 291, 423, 495, 63, 10116, 26, 288, 291, 423, 495, 63, 10116, 59, 83, 61, 275, 822, 8, 277, 423, 495, 63, 10116, 9, 288, 291, 423, 525, 63, 475, 63, 83, 270, 8, 83, 9, 267, 372, 291, 423, 495, 63, 10116, 59, 83, 61, 339, 347, 620, 63, 1080, 8, 277, 12, 308, 304, 267, 372, 291, 423, 495, 63, 10116, 59, 83, 61, 339, 347, 664, 63, 4492, 556, 63, 3059, 8, 277, 304, 267, 291, 423, 1222, 63, 20082, 342, 267, 754, 275, 1706, 4827, 18, 40, 8921, 297, 291, 423, 51, 840, 63, 998, 12, 822, 8, 277, 423, 83, 270, 63, 3059, 395, 291, 423, 525, 63, 5352, 12, 822, 8, 277, 423, 495, 63, 10116, 430, 267, 754, 847, 291, 423, 83, 270, 63, 3059, 59, 24, 2938, 267, 754, 847, 6522, 904, 8, 277, 423, 6958, 83, 9, 267, 372, 754, 339, 347, 485, 525, 63, 475, 63, 83, 270, 8, 277, 12, 308, 304, 267, 399, 63, 495, 275, 1536, 564, 18, 8, 83, 9, 267, 340, 822, 8, 85, 63, 495, 9, 690, 378, 23973, 26, 288, 746, 2186, 360, 705, 26, 7437, 1846, 1059, 2659, 398, 365, 63, 2975, 63, 495, 275, 399, 63, 495, 59, 18, 61, 508, 1557, 88, 614, 7, 267, 340, 365, 63, 2975, 63, 495, 26, 288, 6222, 63, 552, 275, 959, 327, 499, 3696, 1553, 822, 12, 586, 327, 413, 3696, 1553, 1511, 12, 586, 327, 499, 3696, 1553, 413, 270, 4678, 267, 587, 26, 288, 6222, 63, 552, 275, 841, 327, 499, 3696, 1553, 822, 12, 586, 327, 413, 3696, 1553, 1511, 12, 586, 327, 413, 3696, 1553, 413, 270, 4678, 398, 291, 423, 2117, 63, 4188, 8, 85, 63, 495, 59, 16, 26, 4188, 63, 552, 566, 267, 291, 423, 2117, 63, 1294, 471, 8, 85, 63, 495, 59, 4188, 63, 552, 8429, 365, 63, 2975, 63, 495, 9, 339, 347, 485, 1222, 63, 20082, 8, 277, 304, 267, 340, 291, 423, 83, 270, 63, 3059, 508, 8061, 288, 291, 423, 83, 270, 63, 3059, 275, 291, 423, 1818, 63, 20082, 267, 587, 26, 288, 8230, 63, 20082, 63, 552, 275, 822, 8, 277, 423, 1818, 63, 20082, 9, 288, 291, 423, 6958, 83, 14, 740, 8, 1389, 4827, 18, 40, 5, 795, 5956, 9808, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
realsaiko/odoo
openerp/report/render/html2html/html2html.py
443
4238
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.report.render.rml2pdf import utils import copy import base64 import cStringIO import re from reportlab.lib.utils import ImageReader _regex = re.compile('\[\[(.+?)\]\]') utils._regex = re.compile('\[\[\s*(.+?)\s*\]\]',re.DOTALL) class html2html(object): def __init__(self, html, localcontext): self.localcontext = localcontext self.etree = html self._node = None def render(self): def process_text(node,new_node): if new_node.tag in ['story','tr','section']: new_node.attrib.clear() for child in utils._child_get(node, self): new_child = copy.deepcopy(child) new_node.append(new_child) if len(child): for n in new_child: new_child.text = utils._process_text(self, child.text) new_child.tail = utils._process_text(self, child.tail) new_child.remove(n) process_text(child, new_child) else: if new_child.tag=='img' and new_child.get('name'): if _regex.findall(new_child.get('name')) : src = utils._process_text(self, new_child.get('name')) if src : new_child.set('src','data:image/gif;base64,%s'%src) output = cStringIO.StringIO(base64.decodestring(src)) img = ImageReader(output) (width,height) = img.getSize() if not new_child.get('width'): new_child.set('width',str(width)) if not new_child.get('height') : new_child.set('height',str(height)) else : new_child.getparent().remove(new_child) new_child.text = utils._process_text(self, child.text) new_child.tail = utils._process_text(self, child.tail) self._node = copy.deepcopy(self.etree) for n in self._node: self._node.remove(n) process_text(self.etree, self._node) return self._node def url_modify(self,root): for n in root: if (n.text.find('<a ')>=0 or n.text.find('&lt;a')>=0) and n.text.find('href')>=0 and n.text.find('style')<=0 : node = (n.tag=='span' and n.getparent().tag=='u') and n.getparent().getparent() or ((n.tag=='span') and n.getparent()) or n style = node.get('color') and "style='color:%s; text-decoration: none;'"%node.get('color') or '' if n.text.find('&lt;a')>=0: t = '&lt;a ' else : t = '<a ' href = n.text.split(t)[-1] n.text = ' '.join([t,style,href]) self.url_modify(n) return root def parseString(node, localcontext = {}): r = html2html(node, localcontext) root = r.render() root = r.url_modify(root) return root # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 258, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 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, 420, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 3070, 14, 3352, 14, 16300, 18, 5607, 492, 3778, 199, 646, 1331, 199, 646, 1300, 772, 199, 646, 15073, 199, 646, 295, 199, 504, 21773, 14, 773, 14, 1208, 492, 6047, 5929, 199, 199, 63, 3821, 275, 295, 14, 2014, 2258, 7023, 7528, 11198, 2862, 7272, 10374, 199, 1208, 423, 3821, 275, 295, 14, 2014, 2258, 7023, 7023, 83, 5830, 11198, 2862, 83, 7590, 7272, 4300, 264, 14, 16504, 9, 199, 533, 3517, 18, 1360, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3517, 12, 2257, 1100, 304, 267, 291, 14, 17886, 275, 2257, 1100, 267, 291, 14, 9464, 275, 3517, 267, 291, 423, 932, 275, 488, 2378, 347, 3795, 8, 277, 304, 267, 347, 2112, 63, 505, 8, 932, 12, 1222, 63, 932, 304, 288, 340, 892, 63, 932, 14, 1450, 315, 788, 17372, 1673, 454, 1673, 2792, 2565, 355, 892, 63, 932, 14, 6640, 14, 3584, 342, 288, 367, 1982, 315, 3778, 423, 1739, 63, 362, 8, 932, 12, 291, 304, 355, 892, 63, 1739, 275, 1331, 14, 8293, 8, 1739, 9, 355, 892, 63, 932, 14, 740, 8, 1222, 63, 1739, 9, 355, 340, 822, 8, 1739, 304, 490, 367, 302, 315, 892, 63, 1739, 26, 717, 892, 63, 1739, 14, 505, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 505, 9, 717, 892, 63, 1739, 14, 1521, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 1521, 9, 717, 892, 63, 1739, 14, 2168, 8, 78, 9, 490, 2112, 63, 505, 8, 1739, 12, 892, 63, 1739, 9, 355, 587, 26, 490, 340, 892, 63, 1739, 14, 1450, 6803, 4060, 7, 436, 892, 63, 1739, 14, 362, 360, 354, 735, 717, 340, 485, 3821, 14, 6452, 8, 1222, 63, 1739, 14, 362, 360, 354, 1333, 520, 1169, 2928, 275, 221, 3778, 423, 1412, 63, 505, 8, 277, 12, 892, 63, 1739, 14, 362, 360, 354, 1333, 1169, 340, 2928, 520, 1816, 892, 63, 1739, 14, 409, 360, 2164, 1673, 576, 26, 1569, 15, 14513, 27, 1095, 772, 8719, 83, 5956, 2164, 9, 1816, 1072, 275, 15073, 14, 6424, 8, 1095, 772, 14, 2708, 875, 8, 2164, 430, 1816, 6050, 275, 6047, 5929, 8, 1199, 9, 1816, 334, 2063, 12, 3333, 9, 275, 6050, 14, 362, 2320, 342, 1816, 340, 440, 892, 63, 1739, 14, 362, 360, 2063, 735, 2511, 892, 63, 1739, 14, 409, 360, 2063, 297, 495, 8, 2063, 430, 1816, 340, 440, 892, 63, 1739, 14, 362, 360, 3333, 358, 520, 2511, 892, 63, 1739, 14, 409, 360, 3333, 297, 495, 8, 3333, 430, 1169, 587, 520, 1816, 892, 63, 1739, 14, 362, 1708, 1252, 2168, 8, 1222, 63, 1739, 9, 490, 892, 63, 1739, 14, 505, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 505, 9, 490, 892, 63, 1739, 14, 1521, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 1521, 9, 267, 291, 423, 932, 275, 1331, 14, 8293, 8, 277, 14, 9464, 9, 267, 367, 302, 315, 291, 423, 932, 26, 288, 291, 423, 932, 14, 2168, 8, 78, 9, 267, 2112, 63, 505, 8, 277, 14, 9464, 12, 291, 423, 932, 9, 267, 372, 291, 423, 932, 5493, 347, 1166, 63, 8951, 8, 277, 12, 1231, 304, 267, 367, 302, 315, 1738, 26, 288, 340, 334, 78, 14, 505, 14, 1623, 4827, 65, 5320, 8119, 16, 503, 302, 14, 505, 14, 1623, 20040, 4116, 27, 65, 358, 8119, 16, 9, 436, 302, 14, 505, 14, 1623, 360, 6399, 358, 8119, 16, 436, 302, 14, 505, 14, 1623, 360, 2487, 358, 12932, 16, 520, 355, 1031, 275, 334, 78, 14, 1450, 6803, 3751, 7, 436, 302, 14, 362, 1708, 1252, 1450, 6803, 85, 358, 436, 302, 14, 362, 1708, 1252, 362, 1708, 342, 503, 3666, 78, 14, 1450, 6803, 3751, 358, 436, 302, 14, 362, 1708, 1012, 503, 302, 355, 3449, 275, 1031, 14, 362, 360, 2326, 358, 436, 298, 2487, 534, 2326, 2689, 83, 27, 1318, 13, 6518, 425, 26, 7179, 27, 4065, 5, 932, 14, 362, 360, 2326, 358, 503, 2125, 355, 340, 302, 14, 505, 14, 1623, 20040, 4116, 27, 65, 358, 8119, 16, 26, 490, 307, 275, 7673, 4116, 27, 65, 283, 355, 587, 520, 490, 307, 275, 2650, 65, 283, 355, 4369, 275, 302, 14, 505, 14, 1294, 8, 84, 15786, 17, 61, 355, 302, 14, 505, 275, 283, 1987, 904, 779, 84, 12, 2487, 12, 6399, 566, 288, 291, 14, 633, 63, 8951, 8, 78, 9, 267, 372, 1738, 199, 199, 318, 2198, 1558, 8, 932, 12, 2257, 1100, 275, 1052, 304, 272, 519, 275, 3517, 18, 1360, 8, 932, 12, 2257, 1100, 9, 272, 1738, 275, 519, 14, 3352, 342, 272, 1738, 275, 519, 14, 633, 63, 8951, 8, 1231, 9, 272, 372, 1738, 421, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 258, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 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, 420, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 3070, 14, 3352, 14, 16300, 18, 5607, 492, 3778, 199, 646, 1331, 199, 646, 1300, 772, 199, 646, 15073, 199, 646, 295, 199, 504, 21773, 14, 773, 14, 1208, 492, 6047, 5929, 199, 199, 63, 3821, 275, 295, 14, 2014, 2258, 7023, 7528, 11198, 2862, 7272, 10374, 199, 1208, 423, 3821, 275, 295, 14, 2014, 2258, 7023, 7023, 83, 5830, 11198, 2862, 83, 7590, 7272, 4300, 264, 14, 16504, 9, 199, 533, 3517, 18, 1360, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3517, 12, 2257, 1100, 304, 267, 291, 14, 17886, 275, 2257, 1100, 267, 291, 14, 9464, 275, 3517, 267, 291, 423, 932, 275, 488, 2378, 347, 3795, 8, 277, 304, 267, 347, 2112, 63, 505, 8, 932, 12, 1222, 63, 932, 304, 288, 340, 892, 63, 932, 14, 1450, 315, 788, 17372, 1673, 454, 1673, 2792, 2565, 355, 892, 63, 932, 14, 6640, 14, 3584, 342, 288, 367, 1982, 315, 3778, 423, 1739, 63, 362, 8, 932, 12, 291, 304, 355, 892, 63, 1739, 275, 1331, 14, 8293, 8, 1739, 9, 355, 892, 63, 932, 14, 740, 8, 1222, 63, 1739, 9, 355, 340, 822, 8, 1739, 304, 490, 367, 302, 315, 892, 63, 1739, 26, 717, 892, 63, 1739, 14, 505, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 505, 9, 717, 892, 63, 1739, 14, 1521, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 1521, 9, 717, 892, 63, 1739, 14, 2168, 8, 78, 9, 490, 2112, 63, 505, 8, 1739, 12, 892, 63, 1739, 9, 355, 587, 26, 490, 340, 892, 63, 1739, 14, 1450, 6803, 4060, 7, 436, 892, 63, 1739, 14, 362, 360, 354, 735, 717, 340, 485, 3821, 14, 6452, 8, 1222, 63, 1739, 14, 362, 360, 354, 1333, 520, 1169, 2928, 275, 221, 3778, 423, 1412, 63, 505, 8, 277, 12, 892, 63, 1739, 14, 362, 360, 354, 1333, 1169, 340, 2928, 520, 1816, 892, 63, 1739, 14, 409, 360, 2164, 1673, 576, 26, 1569, 15, 14513, 27, 1095, 772, 8719, 83, 5956, 2164, 9, 1816, 1072, 275, 15073, 14, 6424, 8, 1095, 772, 14, 2708, 875, 8, 2164, 430, 1816, 6050, 275, 6047, 5929, 8, 1199, 9, 1816, 334, 2063, 12, 3333, 9, 275, 6050, 14, 362, 2320, 342, 1816, 340, 440, 892, 63, 1739, 14, 362, 360, 2063, 735, 2511, 892, 63, 1739, 14, 409, 360, 2063, 297, 495, 8, 2063, 430, 1816, 340, 440, 892, 63, 1739, 14, 362, 360, 3333, 358, 520, 2511, 892, 63, 1739, 14, 409, 360, 3333, 297, 495, 8, 3333, 430, 1169, 587, 520, 1816, 892, 63, 1739, 14, 362, 1708, 1252, 2168, 8, 1222, 63, 1739, 9, 490, 892, 63, 1739, 14, 505, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 505, 9, 490, 892, 63, 1739, 14, 1521, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 1521, 9, 267, 291, 423, 932, 275, 1331, 14, 8293, 8, 277, 14, 9464, 9, 267, 367, 302, 315, 291, 423, 932, 26, 288, 291, 423, 932, 14, 2168, 8, 78, 9, 267, 2112, 63, 505, 8, 277, 14, 9464, 12, 291, 423, 932, 9, 267, 372, 291, 423, 932, 5493, 347, 1166, 63, 8951, 8, 277, 12, 1231, 304, 267, 367, 302, 315, 1738, 26, 288, 340, 334, 78, 14, 505, 14, 1623, 4827, 65, 5320, 8119, 16, 503, 302, 14, 505, 14, 1623, 20040, 4116, 27, 65, 358, 8119, 16, 9, 436, 302, 14, 505, 14, 1623, 360, 6399, 358, 8119, 16, 436, 302, 14, 505, 14, 1623, 360, 2487, 358, 12932, 16, 520, 355, 1031, 275, 334, 78, 14, 1450, 6803, 3751, 7, 436, 302, 14, 362, 1708, 1252, 1450, 6803, 85, 358, 436, 302, 14, 362, 1708, 1252, 362, 1708, 342, 503, 3666, 78, 14, 1450, 6803, 3751, 358, 436, 302, 14, 362, 1708, 1012, 503, 302, 355, 3449, 275, 1031, 14, 362, 360, 2326, 358, 436, 298, 2487, 534, 2326, 2689, 83, 27, 1318, 13, 6518, 425, 26, 7179, 27, 4065, 5, 932, 14, 362, 360, 2326, 358, 503, 2125, 355, 340, 302, 14, 505, 14, 1623, 20040, 4116, 27, 65, 358, 8119, 16, 26, 490, 307, 275, 7673, 4116, 27, 65, 283, 355, 587, 520, 490, 307, 275, 2650, 65, 283, 355, 4369, 275, 302, 14, 505, 14, 1294, 8, 84, 15786, 17, 61, 355, 302, 14, 505, 275, 283, 1987, 904, 779, 84, 12, 2487, 12, 6399, 566, 288, 291, 14, 633, 63, 8951, 8, 78, 9, 267, 372, 1738, 199, 199, 318, 2198, 1558, 8, 932, 12, 2257, 1100, 275, 1052, 304, 272, 519, 275, 3517, 18, 1360, 8, 932, 12, 2257, 1100, 9, 272, 1738, 275, 519, 14, 3352, 342, 272, 1738, 275, 519, 14, 633, 63, 8951, 8, 1231, 9, 272, 372, 1738, 421, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bmars/sisko
sisko/app.py
1
4908
# Copyright (C) 2014 Brian Marshall # # 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 operator import attrgetter from gi.repository import Gio import urwid from sisko.widgets import Dialog, OverlayStack, PathBar, FileItem # Vim-like cursor movement. urwid.command_map['k'] = 'cursor up' urwid.command_map['j'] = 'cursor down' urwid.command_map['h'] = 'cursor left' urwid.command_map['l'] = 'cursor right' class Application: """ Main application class. """ _PALETTE = [('dialog', 'black', 'light gray'), ('focused', 'white', 'dark blue'), ('folder', 'bold', ''), ('folder focused', 'white, bold', 'dark blue'), ('footer', 'light gray', 'dark gray'), ('footer key', 'white, bold', 'black'), ('path-bar', 'white', 'black'), ('path-bar current', 'white, bold', 'dark gray')] _FOOTER = [('footer key', " Alt+H "), " ", _("Hidden Files"), " ", ('footer key', " Q "), " ", _("Quit")] def __init__(self): self._path_bar = PathBar() self._files = urwid.SimpleFocusListWalker([]) self._toplevel = OverlayStack(urwid.Frame( urwid.ListBox(self._files), header=self._path_bar, footer=urwid.AttrMap(urwid.Text(self._FOOTER), 'footer'))) self._show_hidden = False def run(self, folder: Gio.File): """ Run the application, opening the given folder. """ self._open(folder) main = urwid.MainLoop(self._toplevel, self._PALETTE, unhandled_input=self._unhandled_input) main.screen.set_terminal_properties(bright_is_bold=False) main.run() def _open(self, folder: Gio.File): """ Open a folder. """ children = folder.enumerate_children( ','.join([Gio.FILE_ATTRIBUTE_STANDARD_IS_HIDDEN, Gio.FILE_ATTRIBUTE_STANDARD_IS_BACKUP, Gio.FILE_ATTRIBUTE_STANDARD_NAME, FileItem.FILE_ATTRIBUTES]), Gio.FileQueryInfoFlags.NONE, None) self._path_bar.location = folder del self._files[:] for info in children: if self._show_hidden or not (info.get_is_hidden() or info.get_is_backup()): self._files.append(FileItem(folder.get_child(info.get_name()), info)) list.sort(self._files, key=attrgetter('name_key')) def _open_focused(self): """ Open the focused folder. """ focus = self._files.get_focus()[0] if (focus is not None and focus.info.get_file_type() == Gio.FileType.DIRECTORY): self._open(focus.file) def _trash_focused(self): """ Move the focused file to the Trash. """ focus = self._files.get_focus()[0] if focus is None: return dialog = Dialog( _("Are you sure you want to move \"{}\" to the Trash?").format( focus.info.get_display_name()), [(_("Cancel"), 'cancel'), (_("Move to Trash"), 'trash')]) def on_response(response_id): if response_id == 'trash': focus.file.trash(None) del self._files[self._files.index(focus)] self._toplevel.show_dialog(dialog, on_response) def _unhandled_input(self, key): """ Handle application key commands. """ if urwid.command_map[key] == 'cursor left': # Open previous folder in the path. if self._path_bar.previous is not None: self._open(self._path_bar.previous) elif urwid.command_map[key] == 'cursor right': # Open next folder in the path. if self._path_bar.next is not None: self._open(self._path_bar.next) elif urwid.command_map[key] == 'activate': self._open_focused() elif key == 'delete': self._trash_focused() elif key == 'meta h': self._show_hidden = not self._show_hidden self._open(self._path_bar.location) elif key in ('Q', 'q'): raise urwid.ExitMainLoop
gpl-3.0
[ 3, 1898, 334, 35, 9, 6927, 699, 18429, 16794, 609, 452, 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, 4182, 492, 21829, 199, 199, 504, 18895, 14, 8421, 492, 598, 2308, 199, 646, 7629, 19686, 199, 199, 504, 308, 374, 7697, 14, 8583, 492, 30631, 12, 7259, 817, 4851, 12, 6912, 5281, 12, 3814, 2081, 199, 199, 3, 812, 1017, 13, 2930, 3920, 4057, 434, 14, 199, 300, 19686, 14, 1531, 63, 1130, 459, 75, 418, 275, 283, 3937, 1536, 7, 199, 300, 19686, 14, 1531, 63, 1130, 459, 74, 418, 275, 283, 3937, 3224, 7, 199, 300, 19686, 14, 1531, 63, 1130, 459, 72, 418, 275, 283, 3937, 3602, 7, 199, 300, 19686, 14, 1531, 63, 1130, 459, 76, 418, 275, 283, 3937, 2451, 7, 199, 199, 533, 13515, 26, 272, 408, 272, 11298, 4223, 1021, 14, 272, 408, 339, 485, 29586, 275, 4274, 7196, 297, 283, 8399, 297, 283, 4040, 21977, 659, 355, 661, 32621, 297, 283, 7510, 297, 283, 13625, 10030, 659, 355, 661, 3741, 297, 283, 9771, 297, 9929, 355, 661, 3741, 289, 679, 2972, 297, 283, 7510, 12, 17268, 297, 283, 13625, 10030, 659, 355, 661, 12781, 297, 283, 4040, 21977, 297, 283, 13625, 21977, 659, 355, 661, 12781, 790, 297, 283, 7510, 12, 17268, 297, 283, 8399, 659, 355, 661, 515, 13, 1700, 297, 283, 7510, 297, 283, 8399, 659, 355, 661, 515, 13, 1700, 1453, 297, 283, 7510, 12, 17268, 297, 283, 13625, 21977, 5440, 339, 485, 13046, 1157, 275, 4274, 12781, 790, 297, 298, 437, 4116, 11, 40, 26261, 298, 3872, 3824, 14983, 16920, 1288, 298, 221, 3872, 2049, 661, 12781, 790, 297, 298, 1413, 26261, 298, 3872, 3824, 24145, 11323, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 515, 63, 1700, 275, 6912, 5281, 342, 267, 291, 423, 1725, 275, 7629, 19686, 14, 3184, 17310, 1296, 26020, 4157, 267, 291, 423, 13517, 275, 7259, 817, 4851, 8, 300, 19686, 14, 3160, 8, 288, 7629, 19686, 14, 26764, 8, 277, 423, 1725, 395, 288, 1406, 29, 277, 423, 515, 63, 1700, 12, 288, 14178, 29, 300, 19686, 14, 7144, 2956, 8, 300, 19686, 14, 1872, 8, 277, 423, 13046, 1157, 395, 283, 12781, 7058, 267, 291, 423, 2384, 63, 5642, 275, 756, 339, 347, 1255, 8, 277, 12, 4922, 26, 598, 2308, 14, 1173, 304, 267, 408, 267, 3378, 314, 4223, 12, 13618, 314, 1627, 4922, 14, 267, 408, 267, 291, 423, 1490, 8, 3741, 9, 267, 2446, 275, 7629, 19686, 14, 6756, 7382, 8, 277, 423, 13517, 12, 291, 423, 29586, 12, 2892, 23090, 63, 1210, 29, 277, 423, 23648, 63, 1210, 9, 267, 2446, 14, 5410, 14, 409, 63, 12010, 63, 3282, 8, 27454, 63, 374, 63, 9771, 29, 797, 9, 267, 2446, 14, 1065, 342, 339, 347, 485, 1490, 8, 277, 12, 4922, 26, 598, 2308, 14, 1173, 304, 267, 408, 267, 3232, 282, 4922, 14, 267, 408, 267, 4978, 275, 4922, 14, 26318, 63, 3223, 8, 288, 12814, 904, 779, 39, 2308, 14, 3817, 63, 17075, 63, 19547, 63, 1311, 63, 40, 22436, 12, 1993, 598, 2308, 14, 3817, 63, 17075, 63, 19547, 63, 1311, 63, 31752, 12, 1993, 598, 2308, 14, 3817, 63, 17075, 63, 19547, 63, 2339, 12, 1993, 3814, 2081, 14, 3817, 63, 18166, 2522, 288, 598, 2308, 14, 1173, 3227, 2354, 6381, 14, 9185, 12, 488, 9, 267, 291, 423, 515, 63, 1700, 14, 1985, 275, 4922, 267, 2150, 291, 423, 1725, 5873, 267, 367, 2256, 315, 4978, 26, 288, 340, 291, 423, 2384, 63, 5642, 503, 440, 334, 815, 14, 362, 63, 374, 63, 5642, 342, 503, 1460, 2256, 14, 362, 63, 374, 63, 5751, 5109, 355, 291, 423, 1725, 14, 740, 8, 1173, 2081, 8, 3741, 14, 362, 63, 1739, 8, 815, 14, 362, 63, 354, 4000, 4490, 2256, 430, 267, 769, 14, 3191, 8, 277, 423, 1725, 12, 790, 29, 18600, 360, 354, 63, 498, 1333, 339, 347, 485, 1490, 63, 32621, 8, 277, 304, 267, 408, 267, 3232, 314, 289, 679, 2972, 4922, 14, 267, 408, 267, 16470, 275, 291, 423, 1725, 14, 362, 63, 12283, 3430, 16, 61, 267, 340, 334, 12283, 365, 440, 488, 436, 355, 16470, 14, 815, 14, 362, 63, 493, 63, 466, 342, 508, 598, 2308, 14, 20683, 14, 16436, 304, 288, 291, 423, 1490, 8, 12283, 14, 493, 9, 339, 347, 485, 28272, 63, 32621, 8, 277, 304, 267, 408, 267, 14171, 314, 289, 679, 2972, 570, 370, 314, 28814, 1119, 14, 267, 408, 267, 16470, 275, 291, 423, 1725, 14, 362, 63, 12283, 3430, 16, 61, 267, 340, 16470, 365, 488, 26, 288, 372, 267, 9592, 275, 30631, 8, 288, 3824, 17683, 1265, 3238, 1265, 2934, 370, 4057, 8441, 2440, 4451, 370, 314, 28814, 1119, 31, 3471, 908, 8, 355, 16470, 14, 815, 14, 362, 63, 2918, 63, 354, 4000, 288, 359, 6115, 9083, 1288, 283, 6406, 659, 26542, 10370, 370, 28814, 1119, 1288, 283, 28272, 2023, 267, 347, 641, 63, 1310, 8, 1310, 63, 344, 304, 288, 340, 1177, 63, 344, 508, 283, 28272, 356, 355, 16470, 14, 493, 14, 28272, 8, 403, 9, 355, 2150, 291, 423, 1725, 59, 277, 423, 1725, 14, 1080, 8, 12283, 1874, 267, 291, 423, 13517, 14, 2384, 63, 7196, 8, 7196, 12, 641, 63, 1310, 9, 339, 347, 485, 23648, 63 ]
[ 1898, 334, 35, 9, 6927, 699, 18429, 16794, 609, 452, 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, 4182, 492, 21829, 199, 199, 504, 18895, 14, 8421, 492, 598, 2308, 199, 646, 7629, 19686, 199, 199, 504, 308, 374, 7697, 14, 8583, 492, 30631, 12, 7259, 817, 4851, 12, 6912, 5281, 12, 3814, 2081, 199, 199, 3, 812, 1017, 13, 2930, 3920, 4057, 434, 14, 199, 300, 19686, 14, 1531, 63, 1130, 459, 75, 418, 275, 283, 3937, 1536, 7, 199, 300, 19686, 14, 1531, 63, 1130, 459, 74, 418, 275, 283, 3937, 3224, 7, 199, 300, 19686, 14, 1531, 63, 1130, 459, 72, 418, 275, 283, 3937, 3602, 7, 199, 300, 19686, 14, 1531, 63, 1130, 459, 76, 418, 275, 283, 3937, 2451, 7, 199, 199, 533, 13515, 26, 272, 408, 272, 11298, 4223, 1021, 14, 272, 408, 339, 485, 29586, 275, 4274, 7196, 297, 283, 8399, 297, 283, 4040, 21977, 659, 355, 661, 32621, 297, 283, 7510, 297, 283, 13625, 10030, 659, 355, 661, 3741, 297, 283, 9771, 297, 9929, 355, 661, 3741, 289, 679, 2972, 297, 283, 7510, 12, 17268, 297, 283, 13625, 10030, 659, 355, 661, 12781, 297, 283, 4040, 21977, 297, 283, 13625, 21977, 659, 355, 661, 12781, 790, 297, 283, 7510, 12, 17268, 297, 283, 8399, 659, 355, 661, 515, 13, 1700, 297, 283, 7510, 297, 283, 8399, 659, 355, 661, 515, 13, 1700, 1453, 297, 283, 7510, 12, 17268, 297, 283, 13625, 21977, 5440, 339, 485, 13046, 1157, 275, 4274, 12781, 790, 297, 298, 437, 4116, 11, 40, 26261, 298, 3872, 3824, 14983, 16920, 1288, 298, 221, 3872, 2049, 661, 12781, 790, 297, 298, 1413, 26261, 298, 3872, 3824, 24145, 11323, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 515, 63, 1700, 275, 6912, 5281, 342, 267, 291, 423, 1725, 275, 7629, 19686, 14, 3184, 17310, 1296, 26020, 4157, 267, 291, 423, 13517, 275, 7259, 817, 4851, 8, 300, 19686, 14, 3160, 8, 288, 7629, 19686, 14, 26764, 8, 277, 423, 1725, 395, 288, 1406, 29, 277, 423, 515, 63, 1700, 12, 288, 14178, 29, 300, 19686, 14, 7144, 2956, 8, 300, 19686, 14, 1872, 8, 277, 423, 13046, 1157, 395, 283, 12781, 7058, 267, 291, 423, 2384, 63, 5642, 275, 756, 339, 347, 1255, 8, 277, 12, 4922, 26, 598, 2308, 14, 1173, 304, 267, 408, 267, 3378, 314, 4223, 12, 13618, 314, 1627, 4922, 14, 267, 408, 267, 291, 423, 1490, 8, 3741, 9, 267, 2446, 275, 7629, 19686, 14, 6756, 7382, 8, 277, 423, 13517, 12, 291, 423, 29586, 12, 2892, 23090, 63, 1210, 29, 277, 423, 23648, 63, 1210, 9, 267, 2446, 14, 5410, 14, 409, 63, 12010, 63, 3282, 8, 27454, 63, 374, 63, 9771, 29, 797, 9, 267, 2446, 14, 1065, 342, 339, 347, 485, 1490, 8, 277, 12, 4922, 26, 598, 2308, 14, 1173, 304, 267, 408, 267, 3232, 282, 4922, 14, 267, 408, 267, 4978, 275, 4922, 14, 26318, 63, 3223, 8, 288, 12814, 904, 779, 39, 2308, 14, 3817, 63, 17075, 63, 19547, 63, 1311, 63, 40, 22436, 12, 1993, 598, 2308, 14, 3817, 63, 17075, 63, 19547, 63, 1311, 63, 31752, 12, 1993, 598, 2308, 14, 3817, 63, 17075, 63, 19547, 63, 2339, 12, 1993, 3814, 2081, 14, 3817, 63, 18166, 2522, 288, 598, 2308, 14, 1173, 3227, 2354, 6381, 14, 9185, 12, 488, 9, 267, 291, 423, 515, 63, 1700, 14, 1985, 275, 4922, 267, 2150, 291, 423, 1725, 5873, 267, 367, 2256, 315, 4978, 26, 288, 340, 291, 423, 2384, 63, 5642, 503, 440, 334, 815, 14, 362, 63, 374, 63, 5642, 342, 503, 1460, 2256, 14, 362, 63, 374, 63, 5751, 5109, 355, 291, 423, 1725, 14, 740, 8, 1173, 2081, 8, 3741, 14, 362, 63, 1739, 8, 815, 14, 362, 63, 354, 4000, 4490, 2256, 430, 267, 769, 14, 3191, 8, 277, 423, 1725, 12, 790, 29, 18600, 360, 354, 63, 498, 1333, 339, 347, 485, 1490, 63, 32621, 8, 277, 304, 267, 408, 267, 3232, 314, 289, 679, 2972, 4922, 14, 267, 408, 267, 16470, 275, 291, 423, 1725, 14, 362, 63, 12283, 3430, 16, 61, 267, 340, 334, 12283, 365, 440, 488, 436, 355, 16470, 14, 815, 14, 362, 63, 493, 63, 466, 342, 508, 598, 2308, 14, 20683, 14, 16436, 304, 288, 291, 423, 1490, 8, 12283, 14, 493, 9, 339, 347, 485, 28272, 63, 32621, 8, 277, 304, 267, 408, 267, 14171, 314, 289, 679, 2972, 570, 370, 314, 28814, 1119, 14, 267, 408, 267, 16470, 275, 291, 423, 1725, 14, 362, 63, 12283, 3430, 16, 61, 267, 340, 16470, 365, 488, 26, 288, 372, 267, 9592, 275, 30631, 8, 288, 3824, 17683, 1265, 3238, 1265, 2934, 370, 4057, 8441, 2440, 4451, 370, 314, 28814, 1119, 31, 3471, 908, 8, 355, 16470, 14, 815, 14, 362, 63, 2918, 63, 354, 4000, 288, 359, 6115, 9083, 1288, 283, 6406, 659, 26542, 10370, 370, 28814, 1119, 1288, 283, 28272, 2023, 267, 347, 641, 63, 1310, 8, 1310, 63, 344, 304, 288, 340, 1177, 63, 344, 508, 283, 28272, 356, 355, 16470, 14, 493, 14, 28272, 8, 403, 9, 355, 2150, 291, 423, 1725, 59, 277, 423, 1725, 14, 1080, 8, 12283, 1874, 267, 291, 423, 13517, 14, 2384, 63, 7196, 8, 7196, 12, 641, 63, 1310, 9, 339, 347, 485, 23648, 63, 0 ]
[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 ]
shsingh/ansible
lib/ansible/modules/network/netvisor/pn_prefix_list_network.py
35
5247
#!/usr/bin/python # Copyright: (c) 2018, Pluribus Networks # 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: pn_prefix_list_network author: "Pluribus Networks (@rajaspachipulusu17)" version_added: "2.8" short_description: CLI command to add/remove prefix-list-network description: - This module is used to add network associated with prefix list and remove networks associated with prefix list. options: pn_cliswitch: description: - Target switch to run the CLI on. required: false type: str state: description: - State the action to perform. Use C(present) to create prefix-list-network and C(absent) to delete prefix-list-network. required: true type: str choices: ['present', 'absent'] pn_netmask: description: - netmask of the network associated the prefix list. required: false type: str pn_name: description: - Prefix List Name. required: false type: str pn_network: description: - network associated with the prefix list. required: false type: str """ EXAMPLES = """ - name: prefix list network add pn_prefix_list_network: pn_cliswitch: "sw01" pn_name: "foo" pn_network: "172.16.3.1" pn_netmask: "24" state: "present" - name: prefix list network remove pn_prefix_list_network: pn_cliswitch: "sw01" state: "absent" pn_name: "foo" pn_network: "172.16.3.1" pn_netmask: "24" """ RETURN = """ command: description: the CLI command run on the target node. returned: always type: str stdout: description: set of responses from the prefix-list-network command. returned: always type: list stderr: description: set of error responses from the prefix-list-network command. returned: on error type: list changed: description: indicates whether the CLI caused changes on the target. returned: always type: bool """ from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.netvisor.pn_nvos import pn_cli, run_cli from ansible.module_utils.network.netvisor.netvisor import run_commands def check_cli(module, cli): """ This method checks for idempotency using prefix-list-network-show command. If network exists, return as True else False. :param module: The Ansible module to fetch input parameters :param cli: The CLI string """ name = module.params['pn_name'] network = module.params['pn_network'] show = cli cli += ' prefix-list-show format name no-show-headers' out = run_commands(module, cli)[1] if name not in out.split()[-1]: module.fail_json( failed=True, msg='Prefix list with name %s does not exists' % name ) cli = show cli += ' prefix-list-network-show name %s format network no-show-headers' % name rc, out, err = run_commands(module, cli) if out: out = out.split()[-1] return True if network in out.split('/')[0] else False return False def main(): """ This section is for arguments parsing """ state_map = dict( present='prefix-list-network-add', absent='prefix-list-network-remove' ) module = AnsibleModule( argument_spec=dict( pn_cliswitch=dict(required=False, type='str'), state=dict(required=True, type='str', choices=state_map.keys()), pn_netmask=dict(required=False, type='str'), pn_name=dict(required=False, type='str'), pn_network=dict(required=False, type='str'), ), required_if=( ["state", "present", ["pn_name", "pn_network", "pn_netmask"]], ["state", "absent", ["pn_name", "pn_network", "pn_netmask"]], ), required_together=( ["pn_network", "pn_netmask"], ), ) # Accessing the arguments cliswitch = module.params['pn_cliswitch'] state = module.params['state'] netmask = module.params['pn_netmask'] name = module.params['pn_name'] network = module.params['pn_network'] command = state_map[state] # Building the CLI command string cli = pn_cli(module, cliswitch) NETWORK_EXISTS = check_cli(module, cli) cli += ' %s ' % command if command == 'prefix-list-network-remove': if NETWORK_EXISTS is False: module.exit_json( skipped=True, msg='Prefix list with network %s does not exist' % network ) if command == 'prefix-list-network-add': if NETWORK_EXISTS is True: module.exit_json( skipped=True, msg='Prefix list with network %s already exists' % network ) if name: cli += ' name ' + name if network: cli += ' network ' + network if netmask: cli += ' netmask ' + netmask run_cli(module, cli, state_map) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 26, 334, 67, 9, 14894, 12, 7497, 2302, 5610, 17138, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 13631, 63, 1861, 63, 513, 63, 1200, 199, 2502, 26, 298, 3714, 2302, 5610, 17138, 8593, 345, 74, 305, 387, 28329, 15909, 85, 1196, 2924, 199, 1023, 63, 3270, 26, 298, 18, 14, 24, 2, 199, 3612, 63, 1802, 26, 14214, 1414, 370, 1050, 15, 2168, 2403, 13, 513, 13, 1200, 199, 1802, 26, 523, 446, 961, 859, 365, 1202, 370, 1050, 2784, 4568, 543, 2403, 769, 272, 436, 2813, 11759, 4568, 543, 2403, 769, 14, 199, 1419, 26, 523, 13631, 63, 2764, 5656, 26, 272, 1369, 26, 489, 446, 10256, 6258, 370, 1255, 314, 14214, 641, 14, 272, 1415, 26, 3055, 272, 730, 26, 620, 523, 1174, 26, 272, 1369, 26, 489, 446, 8511, 314, 1595, 370, 5147, 14, 3645, 445, 8, 1881, 9, 370, 1218, 267, 2403, 13, 513, 13, 1200, 436, 445, 8, 5575, 9, 370, 3145, 2403, 13, 513, 13, 1200, 14, 272, 1415, 26, 2549, 272, 730, 26, 620, 272, 3415, 26, 788, 1881, 297, 283, 5575, 418, 523, 13631, 63, 14588, 26, 272, 1369, 26, 489, 446, 20225, 402, 314, 2784, 4568, 314, 2403, 769, 14, 272, 1415, 26, 3055, 272, 730, 26, 620, 523, 13631, 63, 354, 26, 272, 1369, 26, 489, 446, 25110, 3820, 2812, 14, 272, 1415, 26, 3055, 272, 730, 26, 620, 523, 13631, 63, 1200, 26, 272, 1369, 26, 489, 446, 2784, 4568, 543, 314, 2403, 769, 14, 272, 1415, 26, 3055, 272, 730, 26, 620, 199, 624, 199, 199, 8918, 275, 408, 199, 13, 536, 26, 2403, 769, 2784, 1050, 523, 13631, 63, 1861, 63, 513, 63, 1200, 26, 272, 13631, 63, 2764, 5656, 26, 298, 3519, 614, 2, 272, 13631, 63, 354, 26, 298, 1421, 2, 272, 13631, 63, 1200, 26, 298, 10419, 14, 975, 14, 19, 14, 17, 2, 272, 13631, 63, 14588, 26, 298, 1194, 2, 272, 1174, 26, 298, 1881, 2, 199, 199, 13, 536, 26, 2403, 769, 2784, 2813, 523, 13631, 63, 1861, 63, 513, 63, 1200, 26, 272, 13631, 63, 2764, 5656, 26, 298, 3519, 614, 2, 272, 1174, 26, 298, 5575, 2, 272, 13631, 63, 354, 26, 298, 1421, 2, 272, 13631, 63, 1200, 26, 298, 10419, 14, 975, 14, 19, 14, 17, 2, 272, 13631, 63, 14588, 26, 298, 1194, 2, 199, 624, 199, 199, 9677, 275, 408, 199, 1531, 26, 523, 1369, 26, 314, 14214, 1414, 1255, 641, 314, 1347, 1031, 14, 523, 2138, 26, 3544, 523, 730, 26, 620, 199, 2703, 26, 523, 1369, 26, 663, 402, 9320, 687, 314, 2403, 13, 513, 13, 1200, 1414, 14, 523, 2138, 26, 3544, 523, 730, 26, 769, 199, 3083, 26, 523, 1369, 26, 663, 402, 1125, 9320, 687, 314, 2403, 13, 513, 13, 1200, 1414, 14, 523, 2138, 26, 641, 1125, 523, 730, 26, 769, 199, 2489, 26, 523, 1369, 26, 9126, 3775, 314, 14214, 18104, 4493, 641, 314, 1347, 14, 523, 2138, 26, 3544, 523, 730, 26, 2155, 199, 624, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 846, 8286, 14, 4812, 63, 15969, 736, 492, 13631, 63, 2764, 12, 1255, 63, 2764, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 846, 8286, 14, 846, 8286, 492, 1255, 63, 4405, 421, 199, 318, 1104, 63, 2764, 8, 578, 12, 5053, 304, 272, 408, 272, 961, 1083, 5920, 367, 9979, 9613, 9447, 1808, 2403, 13, 513, 13, 1200, 13, 2384, 1414, 14, 272, 982, 2784, 3495, 12, 372, 465, 715, 587, 756, 14, 272, 520, 635, 859, 26, 710, 2622, 859, 370, 5267, 1324, 2633, 272, 520, 635, 5053, 26, 710, 14214, 1059, 272, 408, 272, 536, 275, 859, 14, 1162, 459, 4812, 63, 354, 418, 272, 2784, 275, 859, 14, 1162, 459, 4812, 63, 1200, 418, 272, 2498, 275, 5053, 339, 5053, 847, 283, 2403, 13, 513, 13, 2384, 1475, 536, 949, 13, 2384, 13, 2139, 7, 272, 734, 275, 1255, 63, 4405, 8, 578, 12, 5053, 2788, 17, 61, 339, 340, 536, 440, 315, 734, 14, 1294, 19105, 17, 2189, 267, 859, 14, 1633, 63, 1001, 8, 288, 3405, 29, 549, 12, 288, 1499, 534, 4793, 769, 543, 536, 450, 83, 1630, 440, 3495, 7, 450, 536, 267, 776, 339, 5053, 275, 2498, 272, 5053, 847, 283, 2403, 13, 513, 13, 1200, 13, 2384, 536, 450, 83, 1475, 2784, 949, 13, 2384, 13, 2139, 7, 450, 536, 272, 4819, 12, 734, 12, 2329, 275, 1255, 63, 4405, 8, 578, 12, 5053, 9, 339, 340, 734, 26, 267, 734, 275, 734, 14, 1294, 19105, 17, 61, 267, 372, 715, 340, 2784, 315, 734, 14, 1294, 30746, 16, 61, 587, 756, 339, 372, 756, 421, 199, 318, 2446, 837, 272, 408, 961, 3420, 365, 367, 2368, 6057, 408, 339, 1174, 63, 1130, 275, 1211, 8, 267, 3451, 534, 1861, 13, 513, 13, 1200, 13, 525, 297, 267, 9552, 534, 1861, 13, 513, 13, 1200, 13, 2168, 7, 272, 776, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 13631, 63, 2764, 5656, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 1174, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 297, 2432, 3415, 29, 929, 63, 1130, 14, 1612, 4000, 288, 13631, 63, 14588, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 13631, 63, 354, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 13631, 63, 1200, 29, 807, 8, 2427, 29, 797, 12, 730, 534 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 26, 334, 67, 9, 14894, 12, 7497, 2302, 5610, 17138, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 13631, 63, 1861, 63, 513, 63, 1200, 199, 2502, 26, 298, 3714, 2302, 5610, 17138, 8593, 345, 74, 305, 387, 28329, 15909, 85, 1196, 2924, 199, 1023, 63, 3270, 26, 298, 18, 14, 24, 2, 199, 3612, 63, 1802, 26, 14214, 1414, 370, 1050, 15, 2168, 2403, 13, 513, 13, 1200, 199, 1802, 26, 523, 446, 961, 859, 365, 1202, 370, 1050, 2784, 4568, 543, 2403, 769, 272, 436, 2813, 11759, 4568, 543, 2403, 769, 14, 199, 1419, 26, 523, 13631, 63, 2764, 5656, 26, 272, 1369, 26, 489, 446, 10256, 6258, 370, 1255, 314, 14214, 641, 14, 272, 1415, 26, 3055, 272, 730, 26, 620, 523, 1174, 26, 272, 1369, 26, 489, 446, 8511, 314, 1595, 370, 5147, 14, 3645, 445, 8, 1881, 9, 370, 1218, 267, 2403, 13, 513, 13, 1200, 436, 445, 8, 5575, 9, 370, 3145, 2403, 13, 513, 13, 1200, 14, 272, 1415, 26, 2549, 272, 730, 26, 620, 272, 3415, 26, 788, 1881, 297, 283, 5575, 418, 523, 13631, 63, 14588, 26, 272, 1369, 26, 489, 446, 20225, 402, 314, 2784, 4568, 314, 2403, 769, 14, 272, 1415, 26, 3055, 272, 730, 26, 620, 523, 13631, 63, 354, 26, 272, 1369, 26, 489, 446, 25110, 3820, 2812, 14, 272, 1415, 26, 3055, 272, 730, 26, 620, 523, 13631, 63, 1200, 26, 272, 1369, 26, 489, 446, 2784, 4568, 543, 314, 2403, 769, 14, 272, 1415, 26, 3055, 272, 730, 26, 620, 199, 624, 199, 199, 8918, 275, 408, 199, 13, 536, 26, 2403, 769, 2784, 1050, 523, 13631, 63, 1861, 63, 513, 63, 1200, 26, 272, 13631, 63, 2764, 5656, 26, 298, 3519, 614, 2, 272, 13631, 63, 354, 26, 298, 1421, 2, 272, 13631, 63, 1200, 26, 298, 10419, 14, 975, 14, 19, 14, 17, 2, 272, 13631, 63, 14588, 26, 298, 1194, 2, 272, 1174, 26, 298, 1881, 2, 199, 199, 13, 536, 26, 2403, 769, 2784, 2813, 523, 13631, 63, 1861, 63, 513, 63, 1200, 26, 272, 13631, 63, 2764, 5656, 26, 298, 3519, 614, 2, 272, 1174, 26, 298, 5575, 2, 272, 13631, 63, 354, 26, 298, 1421, 2, 272, 13631, 63, 1200, 26, 298, 10419, 14, 975, 14, 19, 14, 17, 2, 272, 13631, 63, 14588, 26, 298, 1194, 2, 199, 624, 199, 199, 9677, 275, 408, 199, 1531, 26, 523, 1369, 26, 314, 14214, 1414, 1255, 641, 314, 1347, 1031, 14, 523, 2138, 26, 3544, 523, 730, 26, 620, 199, 2703, 26, 523, 1369, 26, 663, 402, 9320, 687, 314, 2403, 13, 513, 13, 1200, 1414, 14, 523, 2138, 26, 3544, 523, 730, 26, 769, 199, 3083, 26, 523, 1369, 26, 663, 402, 1125, 9320, 687, 314, 2403, 13, 513, 13, 1200, 1414, 14, 523, 2138, 26, 641, 1125, 523, 730, 26, 769, 199, 2489, 26, 523, 1369, 26, 9126, 3775, 314, 14214, 18104, 4493, 641, 314, 1347, 14, 523, 2138, 26, 3544, 523, 730, 26, 2155, 199, 624, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 846, 8286, 14, 4812, 63, 15969, 736, 492, 13631, 63, 2764, 12, 1255, 63, 2764, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 846, 8286, 14, 846, 8286, 492, 1255, 63, 4405, 421, 199, 318, 1104, 63, 2764, 8, 578, 12, 5053, 304, 272, 408, 272, 961, 1083, 5920, 367, 9979, 9613, 9447, 1808, 2403, 13, 513, 13, 1200, 13, 2384, 1414, 14, 272, 982, 2784, 3495, 12, 372, 465, 715, 587, 756, 14, 272, 520, 635, 859, 26, 710, 2622, 859, 370, 5267, 1324, 2633, 272, 520, 635, 5053, 26, 710, 14214, 1059, 272, 408, 272, 536, 275, 859, 14, 1162, 459, 4812, 63, 354, 418, 272, 2784, 275, 859, 14, 1162, 459, 4812, 63, 1200, 418, 272, 2498, 275, 5053, 339, 5053, 847, 283, 2403, 13, 513, 13, 2384, 1475, 536, 949, 13, 2384, 13, 2139, 7, 272, 734, 275, 1255, 63, 4405, 8, 578, 12, 5053, 2788, 17, 61, 339, 340, 536, 440, 315, 734, 14, 1294, 19105, 17, 2189, 267, 859, 14, 1633, 63, 1001, 8, 288, 3405, 29, 549, 12, 288, 1499, 534, 4793, 769, 543, 536, 450, 83, 1630, 440, 3495, 7, 450, 536, 267, 776, 339, 5053, 275, 2498, 272, 5053, 847, 283, 2403, 13, 513, 13, 1200, 13, 2384, 536, 450, 83, 1475, 2784, 949, 13, 2384, 13, 2139, 7, 450, 536, 272, 4819, 12, 734, 12, 2329, 275, 1255, 63, 4405, 8, 578, 12, 5053, 9, 339, 340, 734, 26, 267, 734, 275, 734, 14, 1294, 19105, 17, 61, 267, 372, 715, 340, 2784, 315, 734, 14, 1294, 30746, 16, 61, 587, 756, 339, 372, 756, 421, 199, 318, 2446, 837, 272, 408, 961, 3420, 365, 367, 2368, 6057, 408, 339, 1174, 63, 1130, 275, 1211, 8, 267, 3451, 534, 1861, 13, 513, 13, 1200, 13, 525, 297, 267, 9552, 534, 1861, 13, 513, 13, 1200, 13, 2168, 7, 272, 776, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 13631, 63, 2764, 5656, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 1174, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 297, 2432, 3415, 29, 929, 63, 1130, 14, 1612, 4000, 288, 13631, 63, 14588, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 13631, 63, 354, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 13631, 63, 1200, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
android-ia/platform_external_chromium_org_third_party_libyuv
gyp_libyuv.py
179
1124
#!/usr/bin/env python # # Copyright 2014 The LibYuv Project Authors. All rights reserved. # # Use of this source code is governed by a BSD-style license # that can be found in the LICENSE file in the root of the source # tree. An additional intellectual property rights grant can be found # in the file PATENTS. All contributing project authors may # be found in the AUTHORS file in the root of the source tree. # This script is a modified copy of the src/build/gyp_chromium.py file. # It is needed for parallel processing. # This file is (possibly, depending on python version) imported by # gyp_libyuv when GYP_PARALLEL=1 and it creates sub-processes # through the multiprocessing library. # Importing in Python 2.6 (fixed in 2.7) on Windows doesn't search for # imports that don't end in .py (and aren't directories with an # __init__.py). This wrapper makes "import gyp_libyuv" work with # those old versions and makes it possible to execute gyp_libyuv.py # directly on Windows where the extension is useful. import os path = os.path.abspath(os.path.split(__file__)[0]) execfile(os.path.join(path, 'gyp_libyuv'))
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6927, 710, 8003, 57, 9154, 7290, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 199, 3, 626, 883, 506, 1911, 315, 314, 5113, 570, 315, 314, 1738, 402, 314, 1350, 199, 3, 3123, 14, 1626, 4722, 27925, 1264, 1061, 3324, 4481, 16085, 883, 506, 1911, 199, 3, 315, 314, 570, 31467, 1309, 51, 14, 2900, 5914, 4655, 2199, 11462, 1443, 199, 3, 506, 1911, 315, 314, 10610, 570, 315, 314, 1738, 402, 314, 1350, 3123, 14, 421, 199, 3, 961, 2884, 365, 282, 6042, 1331, 402, 314, 2928, 15, 1506, 15, 6179, 63, 13211, 14, 647, 570, 14, 221, 199, 3, 2779, 365, 4346, 367, 9861, 6661, 14, 199, 199, 3, 961, 570, 365, 334, 19614, 12, 10298, 641, 2366, 1015, 9, 8439, 701, 199, 3, 4902, 63, 773, 89, 9154, 1380, 25686, 63, 4014, 748, 906, 44, 29, 17, 436, 652, 8491, 1007, 13, 11816, 199, 3, 4012, 314, 12866, 3555, 14, 199, 199, 3, 3161, 316, 315, 2018, 499, 14, 22, 334, 5964, 315, 499, 14, 23, 9, 641, 5417, 3181, 1133, 2754, 367, 199, 3, 8925, 626, 2793, 1133, 1284, 315, 1275, 647, 334, 460, 10621, 1133, 6602, 543, 376, 199, 3, 636, 826, 4343, 647, 680, 961, 4975, 7704, 298, 646, 4902, 63, 773, 89, 9154, 2, 1736, 543, 199, 3, 5204, 2269, 5459, 436, 7704, 652, 3962, 370, 5341, 4902, 63, 773, 89, 9154, 14, 647, 199, 3, 5370, 641, 5417, 2382, 314, 3329, 365, 2997, 14, 199, 199, 646, 747, 199, 199, 515, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 1294, 3460, 493, 363, 2788, 16, 566, 199, 1628, 493, 8, 736, 14, 515, 14, 904, 8, 515, 12, 283, 6179, 63, 773, 89, 9154, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6927, 710, 8003, 57, 9154, 7290, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 199, 3, 626, 883, 506, 1911, 315, 314, 5113, 570, 315, 314, 1738, 402, 314, 1350, 199, 3, 3123, 14, 1626, 4722, 27925, 1264, 1061, 3324, 4481, 16085, 883, 506, 1911, 199, 3, 315, 314, 570, 31467, 1309, 51, 14, 2900, 5914, 4655, 2199, 11462, 1443, 199, 3, 506, 1911, 315, 314, 10610, 570, 315, 314, 1738, 402, 314, 1350, 3123, 14, 421, 199, 3, 961, 2884, 365, 282, 6042, 1331, 402, 314, 2928, 15, 1506, 15, 6179, 63, 13211, 14, 647, 570, 14, 221, 199, 3, 2779, 365, 4346, 367, 9861, 6661, 14, 199, 199, 3, 961, 570, 365, 334, 19614, 12, 10298, 641, 2366, 1015, 9, 8439, 701, 199, 3, 4902, 63, 773, 89, 9154, 1380, 25686, 63, 4014, 748, 906, 44, 29, 17, 436, 652, 8491, 1007, 13, 11816, 199, 3, 4012, 314, 12866, 3555, 14, 199, 199, 3, 3161, 316, 315, 2018, 499, 14, 22, 334, 5964, 315, 499, 14, 23, 9, 641, 5417, 3181, 1133, 2754, 367, 199, 3, 8925, 626, 2793, 1133, 1284, 315, 1275, 647, 334, 460, 10621, 1133, 6602, 543, 376, 199, 3, 636, 826, 4343, 647, 680, 961, 4975, 7704, 298, 646, 4902, 63, 773, 89, 9154, 2, 1736, 543, 199, 3, 5204, 2269, 5459, 436, 7704, 652, 3962, 370, 5341, 4902, 63, 773, 89, 9154, 14, 647, 199, 3, 5370, 641, 5417, 2382, 314, 3329, 365, 2997, 14, 199, 199, 646, 747, 199, 199, 515, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 1294, 3460, 493, 363, 2788, 16, 566, 199, 1628, 493, 8, 736, 14, 515, 14, 904, 8, 515, 12, 283, 6179, 63, 773, 89, 9154, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
loehnertj/bsbgateway
bsbgateway/util/jos_parser.py
1
15340
############################################################################## # # Copyright (C) Johannes Loehnert, 2013-2015 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 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 Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import re __all__ = [ "Token", "AstNode", "ParserContext", "StackTrace", "seq", "multiple", "optional", "anyof", "generate_lexer", "re", "generate_parser", ] class Token(object): ntype=0 content=None srcoffset = 0 def __init__(o, ntype, content=None, srcoffset=0): o.ntype = ntype o.content = content o.srcoffset = srcoffset def __unicode__(o): if not o.content: return o.ntype content = o.content if not isinstance(content, unicode): content = unicode(content) if len(content)> 40: content = content[:37] + u"..." return unicode(o.ntype) + u"<" + content.replace("\n", "\n ") + u">" def __str__(o): if not o.content: return o.ntype content = o.content if not isinstance(content, str): content = str(content) # may throw encode error!!! if len(content)> 40: content = content[:37] + "..." return o.ntype + "<" + content.replace("\n", "\n ") + ">" __repr__ = __str__ def __call__(o): return o.content class AstNode: """represents a node of the abstract syntax tree sequence is a list of the children. Its items can be Tokens and AstNodes, mixing is allowed. Take care: a single Token object is a valid tree!! The tree structure will match the given grammar. """ ntype = "" _children = None def __init__(o, ntype, children): o.ntype = ntype o._children = children def __str__(o): s = o.ntype for c in o._children: s = s + "\n" + str(c).replace("\n", "\n ") return s def __unicode__(o): s = unicode(o.ntype) for c in o._children: s = s + u"\n" + unicode(c).replace("\n", "\n ") return s def __getattr__(o, ntype): """gets the child node(s) having the given ntype. Returns list of children that matches.""" result = [] for c in o._children: if c.ntype == ntype: result.append(c) return result def __iter__(o): """iterates over the children of this node.""" return o._children.__iter__() def __call__(o): """return token content of this subtree. The subtree must contain 0 or 1 token, multiple tokens cause an Exception. Returns token.content (None if no token is there).""" result = [c() for c in o._children] result = [x for x in result if x is not None] if len(result)>1: raise ValueError("More than one token in subtree '%s'"%o.ntype) if len(result)==0: return None return result[0] def __getitem__(o, key): if isinstance(key, basestring): l = o.__getattr__(key) if len(l) > 1: raise ValueError("more than one %s child"%key) if len(l)==0: return None return l[0] else: return o._children[key] content = property(__call__) class ParserContext: def __init__(o, tokens, ruleset): o.tokens = tokens o.ruleset = ruleset.copy() o.stack_trace = None o.stack = [] def push(o, symbol): '''processor should push HIS OWN name before calling subprocessors, and .pop() afterwards.''' o.stack.append(symbol) def pop(o): o.stack.pop() def mktrace(o, symbol, errdescription="", reached_position=-1): """create a stack trace and remember it if a bigger position was reached.""" trace = StackTrace(o.stack+[symbol], errdescription, reached_position) # remember the trace if there is none remembered, if it reached longer than the last one, # or if it extends the last remembered one. if o.stack_trace is None \ or o.stack_trace.reached_position < trace.reached_position: o.stack_trace = trace return trace class StackTrace: stack = [] reached_position =-1 errdescription = "" def __init__(o, stack, errdescription="", reached_position=-1): o.stack = stack[:] o.errdescription = errdescription o.reached_position = reached_position def __str__(o): return " ".join(o.stack) + " : '" + o.errdescription + "' (@token %d"%o.reached_position + ")" def _convert(args): """reads the given list and replaces all strings with the corresponding _expect processor. """ processors = list() for processor in args: # replace strings by the '_expect' processor. if isinstance(processor, basestring): processor = _expect(processor) processors.append(processor) return processors # Processors: ========================================================== # each of those functions returns a processor for the token stream. #def process(pcontext, position): # trys to apply itself onto the tokens, if needed branches to another rule. # it starts at position (index into tokens). # Returns (partlist, new_position): # partlist := LIST of AstNodes and Tokens # StackTrace if not applicable. # new_position: where further parsing must continue def _expect(text): """Expect processor: if text is lowercase, expect something matching that rule. if text is not lowercase, expect a token with that ntype. You do not need to use it directly. All strings given as argument to another processor are directly matched. """ if text != text.lower(): # expect that particular TOKEN def process(pcontext, position): tokens = pcontext.tokens if len(tokens) > position: token = tokens[position] else: # after end of stream there comes an infinite amount of EOF tokens. token = Token("EOF", None) if token.ntype == text: return [token], position+1 else: return pcontext.mktrace("expect", errdescription="expected %s token"%text, reached_position=position), position else: # try whether the RULE applies def process(pcontext, position): pcontext.push("<%s>"%text) result, new_position = _try_rule(pcontext, position, text) pcontext.pop() if isinstance(result, StackTrace): return result, position else: return [result], new_position return process def seq(*args): """sequence processor: match the full sequence given as arguments.""" processors = _convert(args) def process(pcontext, position): result = [] start_position = position for processor in processors: subresult, position = processor(pcontext, position) if isinstance(subresult, StackTrace): # parsing failed further down. # exception here: pass Stacktrace directly! return subresult, start_position else: # append returned list to my result result += subresult #success return result, position return process def multiple(*args): """multiple processor: match the sequence given as arguments n times (n>=0). """ subseq = seq(*args) def process(pcontext, position): result = [] while True: pcontext.push("multiple") subresult, new_position = subseq(pcontext, position) pcontext.pop() if isinstance(subresult, StackTrace): # ignore trace and return what you got so far break; # detect and break endless loop if len(subresult) == 0: subresult = pcontext.mktrace("multiple", errdescription="endless loop detected", reached_position = position) break; result += subresult position = new_position return result, position return process def optional(*args): """optional processor: match the full sequence given as argument, or empty list""" subseq = seq(*args) def process(pcontext, position): pcontext.push("optional") subresult, new_position = subseq(pcontext, position) pcontext.pop() # only thing we have to do is convert StackTrace (no match) into a valid match. if isinstance(subresult, StackTrace): return [], position else: return subresult, new_position return process def anyof(*args): """anyof processor: try the given processors in turn, return the first match. for alternative sequences, wrap them in seq(...). """ processors = _convert(args) if len(processors)==0: raise ArgumentError, "at least one alternative must be given to anyof" def process(pcontext, position): for processor in processors: pcontext.push("anyof") result, new_position = processor(pcontext, position) pcontext.pop() if not isinstance(result, StackTrace): return result, new_position # nothing matched return pcontext.mktrace("anyof", "no alternative matched", position), position return process # END of processor generators! ============================ def _try_rule(pcontext, position, rulename): """ takes a list of Tokens, the ruleset, and the name of the subtree rule. Returns the AST (tree of AstNodes and/or tokens), or StackTrace if parsing failed. """ processor = pcontext.ruleset[rulename] result, new_position = processor(pcontext, position) if isinstance(result, StackTrace): return result, position else: return AstNode(rulename, result), new_position def generate_lexer(symbols, re_flags): """generates a lexer function for the given symbol set. The symbol set is a list: ["SYMBOL1", "regex1", "SYMBOL2", "regex2", (...)]. Internally, re.Scanner is used. Look up the re module docs for regexp syntax. Applied to a source string, the lexer function returns a list of Tokens, ie. Token objects. Use the empty string "" as symbol for symbols to be ignored (e.g. whitespace). No Tokens are generated for those. Mark the content of the token by a capture group in the regexp. If there is a named group "content", it is set as Token content. If not, the first capture group is set as Token content. If there are no capture groups, content will be None. Known Bug: the first regex will always have a capture group, by default the whole match. If you want a token without content, put () at the end to make the first capture group an empty string. """ # factory that returns a specific token-generator. def factory(ntype, has_value): def mktoken(regex, match): if has_value: # From the construction of the regex, the group having the # index of the named group +1 is our value. content = match.group(regex.groupindex[ntype] + 1) else: content = None t = Token(ntype, content, match.start()) return t return mktoken regexs = [] symnames = [] funcs = {} for sym, regex in zip(symbols[::2], symbols[1::2]): if sym == "": regexs.append("r(%s)"%(sym)) else: symnames.append(sym) regexs.append(r"(?P<%s>%s)"%(sym, regex)) # check if the regex defines groups i.e. delivers a value p = re.compile(regex) funcs[sym] = factory(sym, (p.groups>0)) regex = re.compile("|".join(regexs), re_flags) def lexer(text): tokens = [] lastpos = 0 for match in regex.finditer(text): # find matched symbol groups = match.groupdict() for sym in symnames: if groups[sym]: tokens.append(funcs[sym](regex, match)) break; lastpos = match.end() return tokens, text[lastpos:] return lexer def generate_parser(ruleset, entrypoint=""): """generates a parser for the given grammar (ruleset). The ruleset must be a dictionary with: string keys (rulenames), which MUST be lowercase processor or string values. values: processors are callbacks built by nesting the functions seq, multiple, optional, anyof. string values match either another rule (if lowercase) or one token (if not lowercase). In the latter case, the string value is compared against the Token.ntype. by default, the rule "" (empty string as key) is used as entrypoint. You can give another entrypoint for testing parts of the grammar. """ rules = ruleset.copy() # convert string values into _expect for key in rules.keys(): if isinstance(rules[key], basestring): rules[key] = _expect(rules[key]) def parse(tokens): """ takes a list of Tokens. Returns (tree, pcontext) - tree: the AST (tree of AstNodes and/or tokens), or None if parsing failed. NOTE that a single Token is also a valid tree. pcontext: final state of parsing contest (for error location) .stack_trace: a StackTrace object if parsing failed .stack_trace.stack: list of called operators .stack_trace.reached_position: where the parser failed to continue use it to validate if everything was read, or for error messages. """ pcontext = ParserContext(tokens, rules) result, end_position = _try_rule(pcontext, 0, "") if isinstance(result, StackTrace): result = None print pcontext.stack_trace else: pcontext.stack_trace = None return result, pcontext return parse
gpl-3.0
[ 202, 199, 4605, 202, 199, 3, 202, 199, 3, 259, 1898, 334, 35, 9, 7135, 72, 1189, 397, 3835, 24528, 1372, 84, 12, 6171, 13, 7806, 202, 199, 3, 202, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 202, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 202, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 202, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 202, 199, 3, 202, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 202, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 202, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 202, 199, 3, 259, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 202, 199, 3, 202, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 202, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 202, 199, 3, 202, 199, 4605, 2999, 199, 646, 295, 2999, 199, 363, 452, 363, 275, 359, 1675, 298, 3264, 401, 298, 33, 270, 1716, 401, 298, 2842, 2998, 401, 298, 4851, 3921, 401, 221, 1675, 298, 3610, 401, 298, 6048, 401, 298, 4144, 401, 298, 1629, 1618, 401, 1675, 298, 4208, 63, 11729, 401, 298, 264, 401, 298, 4208, 63, 2087, 401, 1039, 1622, 202, 199, 533, 8767, 8, 785, 304, 1128, 302, 466, 29, 16, 1128, 1564, 29, 403, 1128, 11483, 18102, 275, 378, 1128, 347, 636, 826, 721, 79, 12, 302, 466, 12, 1564, 29, 403, 12, 11483, 18102, 29, 16, 304, 1039, 312, 14, 25116, 275, 302, 466, 1039, 312, 14, 1317, 275, 1564, 1039, 312, 14, 5474, 18102, 275, 11483, 18102, 2958, 347, 636, 2975, 721, 79, 304, 1039, 340, 440, 312, 14, 1317, 26, 1675, 372, 312, 14, 25116, 1039, 1564, 275, 312, 14, 1317, 1039, 340, 440, 1228, 8, 1317, 12, 2649, 304, 1675, 1564, 275, 2649, 8, 1317, 9, 1039, 340, 822, 8, 1317, 13032, 6335, 26, 221, 1675, 1564, 275, 1564, 1491, 1401, 61, 435, 399, 2, 11500, 1039, 372, 2649, 8, 79, 14, 25116, 9, 435, 399, 17030, 2, 435, 1564, 14, 1814, 4582, 78, 401, 1867, 78, 263, 6099, 435, 399, 1743, 2, 2958, 347, 636, 495, 721, 79, 304, 1039, 340, 440, 312, 14, 1317, 26, 1675, 372, 312, 14, 25116, 1039, 1564, 275, 312, 14, 1317, 1039, 340, 440, 1228, 8, 1317, 12, 620, 304, 1675, 1564, 275, 620, 8, 1317, 9, 327, 1443, 7978, 3752, 1125, 21512, 1039, 340, 822, 8, 1317, 13032, 6335, 26, 221, 1675, 1564, 275, 1564, 1491, 1401, 61, 435, 298, 11500, 1039, 372, 312, 14, 25116, 435, 3886, 2, 435, 1564, 14, 1814, 4582, 78, 401, 1867, 78, 263, 6099, 435, 28192, 1128, 636, 2722, 363, 275, 636, 495, 363, 18801, 347, 636, 1250, 721, 79, 304, 1039, 372, 312, 14, 1317, 2999, 199, 533, 31986, 1716, 26, 1128, 408, 13063, 83, 282, 1031, 402, 314, 9006, 6302, 3123, 1128, 3414, 365, 282, 769, 402, 314, 4978, 14, 22940, 2974, 1128, 883, 506, 8767, 83, 436, 31986, 6300, 12, 13667, 316, 365, 4370, 14, 1128, 18146, 10296, 26, 282, 2849, 8767, 909, 365, 282, 1686, 3123, 3480, 1128, 710, 3123, 5523, 911, 1336, 314, 1627, 12528, 14, 1128, 408, 1128, 302, 466, 275, 3087, 1128, 485, 3223, 275, 488, 1128, 347, 636, 826, 721, 79, 12, 302, 466, 12, 4978, 304, 1039, 312, 14, 25116, 275, 302, 466, 1039, 312, 423, 3223, 275, 4978, 1128, 347, 636, 495, 721, 79, 304, 1039, 308, 275, 312, 14, 25116, 1039, 367, 286, 315, 312, 423, 3223, 26, 1675, 308, 275, 308, 435, 1867, 78, 2, 435, 620, 8, 67, 680, 1814, 4582, 78, 401, 1867, 78, 259, 6099, 1039, 372, 308, 1128, 347, 636, 2975, 721, 79, 304, 1039, 308, 275, 2649, 8, 79, 14, 25116, 9, 1039, 367, 286, 315, 312, 423, 3223, 26, 1675, 308, 275, 308, 435, 399, 3212, 78, 2, 435, 2649, 8, 67, 680, 1814, 4582, 78, 401, 1867, 78, 259, 6099, 1039, 372, 308, 1128, 347, 636, 5675, 721, 79, 12, 302, 466, 304, 1039, 408, 24894, 314, 1982, 1031, 8, 83, 9, 9445, 314, 1627, 302, 466, 14, 30199, 1803, 769, 402, 4978, 626, 4450, 1041, 1039, 754, 275, 942, 1039, 367, 286, 315, 312, 423, 3223, 26, 1675, 340, 286, 14, 25116, 508, 302, 466, 26, 2628, 754, 14, 740, 8, 67, 9, 1039, 372, 754, 1128, 347, 636, 1661, 721, 79, 304, 1039, 408, 1661, 2335, 1806, 314, 4978, 402, 642, 1031, 1041, 1039, 372, 312, 423, 3223, 855, 1661, 4533, 1128, 347, 636, 1250, 721, 79, 304, 1039, 408, 1107, 1526, 1564, 402, 642, 26897, 14, 1039, 710, 26897, 1471, 1395, 378, 503, 413, 1526, 12, 3663, 4645, 7675, 376, 2186, 14, 1039, 1803, 1526, 14, 1317, 334, 403, 340, 949, 1526, 365, 2337, 10477, 1039, 754, 275, 359, 67, 342, 367, 286, 315, 312, 423, 3223, 61, 1039, 754, 275, 359, 88, 367, 671, 315, 754, 340, 671, 365, 440, 488, 61, 1039, 340, 822, 8, 1099, 13032, 17, 26, 1675, 746, 1722, 480, 11053, 2419, 1373, 1526, 315, 26897, 1543, 83, 4065, 5, 79, 14, 25116, 9, 4341, 340, 822, 8, 1099, 12694, 16, 26, 372, 488, 1039, 372, 754, 59, 16, 61, 1128, 347, 636, 6095, 721, 79, 12, 790, 304, 1039, 340, 1228, 8, 498, 12, 7116, 304, 1675, 634, 275, 312, 855, 5675, 721, 498, 9, 1675, 340, 822, 8, 76, 9, 690, 413, 26, 746, 1722, 480, 6878, 2419, 1373, 450, 83, 1982, 6808, 498, 9, 1675, 340, 822, 8, 76, 12694, 16, 26, 372, 488, 1675, 372, 634, 59, 16, 61, 1039, 587, 26, 1675, 372, 312, 423, 3223, 59, 498, 61, 18801, 1564, 275, 3324, 3460, 1250, 3368, 1223, 8065, 199, 533, 10191, 2998, 26, 1128, 347, 636, 826, 721, 79, 12, 4645, 12, 2332, 409 ]
[ 199, 4605, 202, 199, 3, 202, 199, 3, 259, 1898, 334, 35, 9, 7135, 72, 1189, 397, 3835, 24528, 1372, 84, 12, 6171, 13, 7806, 202, 199, 3, 202, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 202, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 202, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 202, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 202, 199, 3, 202, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 202, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 202, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 202, 199, 3, 259, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 202, 199, 3, 202, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 202, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 202, 199, 3, 202, 199, 4605, 2999, 199, 646, 295, 2999, 199, 363, 452, 363, 275, 359, 1675, 298, 3264, 401, 298, 33, 270, 1716, 401, 298, 2842, 2998, 401, 298, 4851, 3921, 401, 221, 1675, 298, 3610, 401, 298, 6048, 401, 298, 4144, 401, 298, 1629, 1618, 401, 1675, 298, 4208, 63, 11729, 401, 298, 264, 401, 298, 4208, 63, 2087, 401, 1039, 1622, 202, 199, 533, 8767, 8, 785, 304, 1128, 302, 466, 29, 16, 1128, 1564, 29, 403, 1128, 11483, 18102, 275, 378, 1128, 347, 636, 826, 721, 79, 12, 302, 466, 12, 1564, 29, 403, 12, 11483, 18102, 29, 16, 304, 1039, 312, 14, 25116, 275, 302, 466, 1039, 312, 14, 1317, 275, 1564, 1039, 312, 14, 5474, 18102, 275, 11483, 18102, 2958, 347, 636, 2975, 721, 79, 304, 1039, 340, 440, 312, 14, 1317, 26, 1675, 372, 312, 14, 25116, 1039, 1564, 275, 312, 14, 1317, 1039, 340, 440, 1228, 8, 1317, 12, 2649, 304, 1675, 1564, 275, 2649, 8, 1317, 9, 1039, 340, 822, 8, 1317, 13032, 6335, 26, 221, 1675, 1564, 275, 1564, 1491, 1401, 61, 435, 399, 2, 11500, 1039, 372, 2649, 8, 79, 14, 25116, 9, 435, 399, 17030, 2, 435, 1564, 14, 1814, 4582, 78, 401, 1867, 78, 263, 6099, 435, 399, 1743, 2, 2958, 347, 636, 495, 721, 79, 304, 1039, 340, 440, 312, 14, 1317, 26, 1675, 372, 312, 14, 25116, 1039, 1564, 275, 312, 14, 1317, 1039, 340, 440, 1228, 8, 1317, 12, 620, 304, 1675, 1564, 275, 620, 8, 1317, 9, 327, 1443, 7978, 3752, 1125, 21512, 1039, 340, 822, 8, 1317, 13032, 6335, 26, 221, 1675, 1564, 275, 1564, 1491, 1401, 61, 435, 298, 11500, 1039, 372, 312, 14, 25116, 435, 3886, 2, 435, 1564, 14, 1814, 4582, 78, 401, 1867, 78, 263, 6099, 435, 28192, 1128, 636, 2722, 363, 275, 636, 495, 363, 18801, 347, 636, 1250, 721, 79, 304, 1039, 372, 312, 14, 1317, 2999, 199, 533, 31986, 1716, 26, 1128, 408, 13063, 83, 282, 1031, 402, 314, 9006, 6302, 3123, 1128, 3414, 365, 282, 769, 402, 314, 4978, 14, 22940, 2974, 1128, 883, 506, 8767, 83, 436, 31986, 6300, 12, 13667, 316, 365, 4370, 14, 1128, 18146, 10296, 26, 282, 2849, 8767, 909, 365, 282, 1686, 3123, 3480, 1128, 710, 3123, 5523, 911, 1336, 314, 1627, 12528, 14, 1128, 408, 1128, 302, 466, 275, 3087, 1128, 485, 3223, 275, 488, 1128, 347, 636, 826, 721, 79, 12, 302, 466, 12, 4978, 304, 1039, 312, 14, 25116, 275, 302, 466, 1039, 312, 423, 3223, 275, 4978, 1128, 347, 636, 495, 721, 79, 304, 1039, 308, 275, 312, 14, 25116, 1039, 367, 286, 315, 312, 423, 3223, 26, 1675, 308, 275, 308, 435, 1867, 78, 2, 435, 620, 8, 67, 680, 1814, 4582, 78, 401, 1867, 78, 259, 6099, 1039, 372, 308, 1128, 347, 636, 2975, 721, 79, 304, 1039, 308, 275, 2649, 8, 79, 14, 25116, 9, 1039, 367, 286, 315, 312, 423, 3223, 26, 1675, 308, 275, 308, 435, 399, 3212, 78, 2, 435, 2649, 8, 67, 680, 1814, 4582, 78, 401, 1867, 78, 259, 6099, 1039, 372, 308, 1128, 347, 636, 5675, 721, 79, 12, 302, 466, 304, 1039, 408, 24894, 314, 1982, 1031, 8, 83, 9, 9445, 314, 1627, 302, 466, 14, 30199, 1803, 769, 402, 4978, 626, 4450, 1041, 1039, 754, 275, 942, 1039, 367, 286, 315, 312, 423, 3223, 26, 1675, 340, 286, 14, 25116, 508, 302, 466, 26, 2628, 754, 14, 740, 8, 67, 9, 1039, 372, 754, 1128, 347, 636, 1661, 721, 79, 304, 1039, 408, 1661, 2335, 1806, 314, 4978, 402, 642, 1031, 1041, 1039, 372, 312, 423, 3223, 855, 1661, 4533, 1128, 347, 636, 1250, 721, 79, 304, 1039, 408, 1107, 1526, 1564, 402, 642, 26897, 14, 1039, 710, 26897, 1471, 1395, 378, 503, 413, 1526, 12, 3663, 4645, 7675, 376, 2186, 14, 1039, 1803, 1526, 14, 1317, 334, 403, 340, 949, 1526, 365, 2337, 10477, 1039, 754, 275, 359, 67, 342, 367, 286, 315, 312, 423, 3223, 61, 1039, 754, 275, 359, 88, 367, 671, 315, 754, 340, 671, 365, 440, 488, 61, 1039, 340, 822, 8, 1099, 13032, 17, 26, 1675, 746, 1722, 480, 11053, 2419, 1373, 1526, 315, 26897, 1543, 83, 4065, 5, 79, 14, 25116, 9, 4341, 340, 822, 8, 1099, 12694, 16, 26, 372, 488, 1039, 372, 754, 59, 16, 61, 1128, 347, 636, 6095, 721, 79, 12, 790, 304, 1039, 340, 1228, 8, 498, 12, 7116, 304, 1675, 634, 275, 312, 855, 5675, 721, 498, 9, 1675, 340, 822, 8, 76, 9, 690, 413, 26, 746, 1722, 480, 6878, 2419, 1373, 450, 83, 1982, 6808, 498, 9, 1675, 340, 822, 8, 76, 12694, 16, 26, 372, 488, 1675, 372, 634, 59, 16, 61, 1039, 587, 26, 1675, 372, 312, 423, 3223, 59, 498, 61, 18801, 1564, 275, 3324, 3460, 1250, 3368, 1223, 8065, 199, 533, 10191, 2998, 26, 1128, 347, 636, 826, 721, 79, 12, 4645, 12, 2332, 409, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
beiko-lab/gengis
bin/Lib/site-packages/scipy/sparse/csgraph/_validation.py
1
2475
from __future__ import division, print_function, absolute_import import numpy as np from scipy.sparse import csr_matrix, isspmatrix, isspmatrix_csc, isspmatrix_csr from ._tools import csgraph_to_dense, csgraph_from_dense,\ csgraph_masked_from_dense, csgraph_from_masked DTYPE = np.float64 def validate_graph(csgraph, directed, dtype=DTYPE, csr_output=True, dense_output=True, copy_if_dense=False, copy_if_sparse=False, null_value_in=0, null_value_out=np.inf, infinity_null=True, nan_null=True): """Routine for validation and conversion of csgraph inputs""" if not (csr_output or dense_output): raise ValueError("Internal: dense or csr output must be true") # if undirected and csc storage, then transposing in-place # is quicker than later converting to csr. if (not directed) and isspmatrix_csc(csgraph): csgraph = csgraph.T if isspmatrix(csgraph): if csr_output: csgraph = csr_matrix(csgraph, dtype=DTYPE, copy=copy_if_sparse) else: csgraph = csgraph_to_dense(csgraph, null_value=null_value_out) elif np.ma.is_masked(csgraph): if dense_output: mask = csgraph.mask csgraph = np.array(csgraph.data, dtype=DTYPE, copy=copy_if_dense) csgraph[mask] = null_value_out else: csgraph = csgraph_from_masked(csgraph) else: if dense_output: csgraph = csgraph_masked_from_dense(csgraph, copy=copy_if_dense, null_value=null_value_in, nan_null=nan_null, infinity_null=infinity_null) mask = csgraph.mask csgraph = np.asarray(csgraph.data, dtype=DTYPE) csgraph[mask] = null_value_out else: csgraph = csgraph_from_dense(csgraph, null_value=null_value_in, infinity_null=infinity_null, nan_null=nan_null) if csgraph.ndim != 2: raise ValueError("compressed-sparse graph must be two dimensional") if csgraph.shape[0] != csgraph.shape[1]: raise ValueError("compressed-sparse graph must be shape (N, N)") return csgraph
gpl-3.0
[ 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 2999, 199, 646, 2680, 465, 980, 202, 199, 504, 7026, 14, 4421, 492, 22258, 63, 3642, 12, 365, 27349, 12, 365, 27349, 63, 17000, 12, 365, 27349, 63, 10101, 202, 199, 504, 13653, 2537, 492, 7117, 2180, 63, 475, 63, 7253, 12, 7117, 2180, 63, 504, 63, 7253, 4202, 1128, 7117, 2180, 63, 11018, 63, 504, 63, 7253, 12, 7117, 2180, 63, 504, 63, 11018, 2999, 199, 36, 2711, 275, 980, 14, 1609, 772, 8065, 199, 318, 4107, 63, 2180, 8, 1259, 2180, 12, 23667, 12, 2152, 29, 36, 2711, 12, 202, 673, 22258, 63, 1199, 29, 549, 12, 9363, 63, 1199, 29, 549, 12, 202, 673, 1331, 63, 692, 63, 7253, 29, 797, 12, 1331, 63, 692, 63, 4421, 29, 797, 12, 202, 673, 2973, 63, 585, 63, 262, 29, 16, 12, 2973, 63, 585, 63, 548, 29, 1590, 14, 4904, 12, 202, 673, 23573, 63, 2307, 29, 549, 12, 12055, 63, 2307, 29, 549, 304, 1128, 408, 32599, 367, 6411, 436, 8603, 402, 7117, 2180, 4153, 624, 1128, 340, 440, 334, 10101, 63, 1199, 503, 9363, 63, 1199, 304, 1039, 746, 1722, 480, 8405, 26, 9363, 503, 22258, 1072, 1471, 506, 2549, 531, 2958, 327, 340, 625, 12080, 436, 28308, 4887, 12, 2066, 1752, 555, 1044, 315, 13, 2778, 1128, 327, 365, 12530, 281, 2419, 2945, 13806, 370, 22258, 14, 1128, 340, 334, 1397, 23667, 9, 436, 365, 27349, 63, 17000, 8, 1259, 2180, 304, 1039, 7117, 2180, 275, 7117, 2180, 14, 52, 2958, 340, 365, 27349, 8, 1259, 2180, 304, 1039, 340, 22258, 63, 1199, 26, 1675, 7117, 2180, 275, 22258, 63, 3642, 8, 1259, 2180, 12, 2152, 29, 36, 2711, 12, 1331, 29, 1574, 63, 692, 63, 4421, 9, 1039, 587, 26, 1675, 7117, 2180, 275, 7117, 2180, 63, 475, 63, 7253, 8, 1259, 2180, 12, 2973, 63, 585, 29, 2307, 63, 585, 63, 548, 9, 1128, 916, 980, 14, 391, 14, 374, 63, 11018, 8, 1259, 2180, 304, 1039, 340, 9363, 63, 1199, 26, 1675, 3656, 275, 7117, 2180, 14, 2629, 1675, 7117, 2180, 275, 980, 14, 1144, 8, 1259, 2180, 14, 576, 12, 2152, 29, 36, 2711, 12, 1331, 29, 1574, 63, 692, 63, 7253, 9, 1675, 7117, 2180, 59, 2629, 61, 275, 2973, 63, 585, 63, 548, 1039, 587, 26, 1675, 7117, 2180, 275, 7117, 2180, 63, 504, 63, 11018, 8, 1259, 2180, 9, 1128, 587, 26, 1039, 340, 9363, 63, 1199, 26, 1675, 7117, 2180, 275, 7117, 2180, 63, 11018, 63, 504, 63, 7253, 8, 1259, 2180, 12, 202, 6059, 1331, 29, 1574, 63, 692, 63, 7253, 12, 202, 6059, 2973, 63, 585, 29, 2307, 63, 585, 63, 262, 12, 202, 6059, 12055, 63, 2307, 29, 4304, 63, 2307, 12, 202, 6059, 23573, 63, 2307, 29, 262, 9693, 63, 2307, 9, 1675, 3656, 275, 7117, 2180, 14, 2629, 1675, 7117, 2180, 275, 980, 14, 8748, 8, 1259, 2180, 14, 576, 12, 2152, 29, 36, 2711, 9, 1675, 7117, 2180, 59, 2629, 61, 275, 2973, 63, 585, 63, 548, 1039, 587, 26, 1675, 7117, 2180, 275, 7117, 2180, 63, 504, 63, 7253, 8, 1259, 2180, 12, 2973, 63, 585, 29, 2307, 63, 585, 63, 262, 12, 202, 1460, 23573, 63, 2307, 29, 262, 9693, 63, 2307, 12, 202, 1460, 12055, 63, 2307, 29, 4304, 63, 2307, 9, 2958, 340, 7117, 2180, 14, 8322, 1137, 499, 26, 1039, 746, 1722, 480, 10895, 13, 4421, 3343, 1471, 506, 2877, 28341, 531, 2958, 340, 7117, 2180, 14, 1392, 59, 16, 61, 1137, 7117, 2180, 14, 1392, 59, 17, 2189, 1039, 746, 1722, 480, 10895, 13, 4421, 3343, 1471, 506, 2215, 334, 46, 12, 653, 6320, 2958, 372, 7117, 2180, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 2999, 199, 646, 2680, 465, 980, 202, 199, 504, 7026, 14, 4421, 492, 22258, 63, 3642, 12, 365, 27349, 12, 365, 27349, 63, 17000, 12, 365, 27349, 63, 10101, 202, 199, 504, 13653, 2537, 492, 7117, 2180, 63, 475, 63, 7253, 12, 7117, 2180, 63, 504, 63, 7253, 4202, 1128, 7117, 2180, 63, 11018, 63, 504, 63, 7253, 12, 7117, 2180, 63, 504, 63, 11018, 2999, 199, 36, 2711, 275, 980, 14, 1609, 772, 8065, 199, 318, 4107, 63, 2180, 8, 1259, 2180, 12, 23667, 12, 2152, 29, 36, 2711, 12, 202, 673, 22258, 63, 1199, 29, 549, 12, 9363, 63, 1199, 29, 549, 12, 202, 673, 1331, 63, 692, 63, 7253, 29, 797, 12, 1331, 63, 692, 63, 4421, 29, 797, 12, 202, 673, 2973, 63, 585, 63, 262, 29, 16, 12, 2973, 63, 585, 63, 548, 29, 1590, 14, 4904, 12, 202, 673, 23573, 63, 2307, 29, 549, 12, 12055, 63, 2307, 29, 549, 304, 1128, 408, 32599, 367, 6411, 436, 8603, 402, 7117, 2180, 4153, 624, 1128, 340, 440, 334, 10101, 63, 1199, 503, 9363, 63, 1199, 304, 1039, 746, 1722, 480, 8405, 26, 9363, 503, 22258, 1072, 1471, 506, 2549, 531, 2958, 327, 340, 625, 12080, 436, 28308, 4887, 12, 2066, 1752, 555, 1044, 315, 13, 2778, 1128, 327, 365, 12530, 281, 2419, 2945, 13806, 370, 22258, 14, 1128, 340, 334, 1397, 23667, 9, 436, 365, 27349, 63, 17000, 8, 1259, 2180, 304, 1039, 7117, 2180, 275, 7117, 2180, 14, 52, 2958, 340, 365, 27349, 8, 1259, 2180, 304, 1039, 340, 22258, 63, 1199, 26, 1675, 7117, 2180, 275, 22258, 63, 3642, 8, 1259, 2180, 12, 2152, 29, 36, 2711, 12, 1331, 29, 1574, 63, 692, 63, 4421, 9, 1039, 587, 26, 1675, 7117, 2180, 275, 7117, 2180, 63, 475, 63, 7253, 8, 1259, 2180, 12, 2973, 63, 585, 29, 2307, 63, 585, 63, 548, 9, 1128, 916, 980, 14, 391, 14, 374, 63, 11018, 8, 1259, 2180, 304, 1039, 340, 9363, 63, 1199, 26, 1675, 3656, 275, 7117, 2180, 14, 2629, 1675, 7117, 2180, 275, 980, 14, 1144, 8, 1259, 2180, 14, 576, 12, 2152, 29, 36, 2711, 12, 1331, 29, 1574, 63, 692, 63, 7253, 9, 1675, 7117, 2180, 59, 2629, 61, 275, 2973, 63, 585, 63, 548, 1039, 587, 26, 1675, 7117, 2180, 275, 7117, 2180, 63, 504, 63, 11018, 8, 1259, 2180, 9, 1128, 587, 26, 1039, 340, 9363, 63, 1199, 26, 1675, 7117, 2180, 275, 7117, 2180, 63, 11018, 63, 504, 63, 7253, 8, 1259, 2180, 12, 202, 6059, 1331, 29, 1574, 63, 692, 63, 7253, 12, 202, 6059, 2973, 63, 585, 29, 2307, 63, 585, 63, 262, 12, 202, 6059, 12055, 63, 2307, 29, 4304, 63, 2307, 12, 202, 6059, 23573, 63, 2307, 29, 262, 9693, 63, 2307, 9, 1675, 3656, 275, 7117, 2180, 14, 2629, 1675, 7117, 2180, 275, 980, 14, 8748, 8, 1259, 2180, 14, 576, 12, 2152, 29, 36, 2711, 9, 1675, 7117, 2180, 59, 2629, 61, 275, 2973, 63, 585, 63, 548, 1039, 587, 26, 1675, 7117, 2180, 275, 7117, 2180, 63, 504, 63, 7253, 8, 1259, 2180, 12, 2973, 63, 585, 29, 2307, 63, 585, 63, 262, 12, 202, 1460, 23573, 63, 2307, 29, 262, 9693, 63, 2307, 12, 202, 1460, 12055, 63, 2307, 29, 4304, 63, 2307, 9, 2958, 340, 7117, 2180, 14, 8322, 1137, 499, 26, 1039, 746, 1722, 480, 10895, 13, 4421, 3343, 1471, 506, 2877, 28341, 531, 2958, 340, 7117, 2180, 14, 1392, 59, 16, 61, 1137, 7117, 2180, 14, 1392, 59, 17, 2189, 1039, 746, 1722, 480, 10895, 13, 4421, 3343, 1471, 506, 2215, 334, 46, 12, 653, 6320, 2958, 372, 7117, 2180, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
liangjiaxing/sympy
examples/galgebra/products_latex.py
72
2650
#!/usr/bin/env python from __future__ import print_function from sympy import symbols from sympy.galgebra import MV, Format from sympy.galgebra import xdvi def main(): Format() coords = (x, y, z) = symbols('x y z') (ex, ey, ez, grad) = MV.setup('e*x|y|z', '[1,1,1]', coords=coords) s = MV('s', 'scalar') v = MV('v', 'vector') b = MV('b', 'bivector') print(r'#3D Orthogonal Metric\newline') print('#Multvectors:') print('s =', s) print('v =', v) print('b =', b) print('#Products:') X = ((s, 's'), (v, 'v'), (b, 'b')) for xi in X: print('') for yi in X: print(xi[1] + '*' + yi[1] + ' =', xi[0]*yi[0]) print(xi[1] + '^' + yi[1] + ' =', xi[0] ^ yi[0]) print(xi[1] + '|' + yi[1] + ' =', xi[0] | yi[0]) print(xi[1] + '<' + yi[1] + ' =', xi[0] < yi[0]) print(xi[1] + '>' + yi[1] + ' =', xi[0] > yi[0]) fs = MV('s', 'scalar', fct=True) fv = MV('v', 'vector', fct=True) fb = MV('b', 'bivector', fct=True) print('#Multivector Functions:') print('s(X) =', fs) print('v(X) =', fv) print('b(X) =', fb) print('#Products:') fX = ((grad, 'grad'), (fs, 's'), (fv, 'v'), (fb, 'b')) for xi in fX: print('') for yi in fX: if xi[1] == 'grad' and yi[1] == 'grad': pass else: print(xi[1] + '*' + yi[1] + ' =', xi[0]*yi[0]) print(xi[1] + '^' + yi[1] + ' =', xi[0] ^ yi[0]) print(xi[1] + '|' + yi[1] + ' =', xi[0] | yi[0]) print(xi[1] + '<' + yi[1] + ' =', xi[0] < yi[0]) print(xi[1] + '>' + yi[1] + ' =', xi[0] > yi[0]) (ex, ey, grad) = MV.setup('e', coords=(x, y)) print(r'#General 2D Metric\newline') print('#Multivector Functions:') s = MV('s', 'scalar', fct=True) v = MV('v', 'vector', fct=True) b = MV('v', 'bivector', fct=True) print('s(X) =', s) print('v(X) =', v) print('b(X) =', b) X = ((grad, 'grad'), (s, 's'), (v, 'v')) print('#Products:') for xi in X: print('') for yi in X: if xi[1] == 'grad' and yi[1] == 'grad': pass else: print(xi[1] + '*' + yi[1] + ' =', xi[0]*yi[0]) print(xi[1] + '^' + yi[1] + ' =', xi[0] ^ yi[0]) print(xi[1] + '|' + yi[1] + ' =', xi[0] | yi[0]) print(xi[1] + '<' + yi[1] + ' =', xi[0] < yi[0]) print(xi[1] + '>' + yi[1] + ' =', xi[0] > yi[0]) xdvi(paper='letter') return if __name__ == "__main__": main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 5840, 492, 6698, 199, 504, 5840, 14, 27074, 19355, 492, 603, 54, 12, 9701, 199, 504, 5840, 14, 27074, 19355, 492, 671, 68, 433, 199, 199, 318, 2446, 837, 272, 9701, 342, 339, 13259, 275, 334, 88, 12, 612, 12, 1315, 9, 275, 6698, 360, 88, 612, 1315, 358, 339, 334, 476, 12, 325, 89, 12, 325, 90, 12, 7659, 9, 275, 603, 54, 14, 2758, 360, 69, 10, 88, 92, 89, 92, 90, 297, 6730, 17, 12, 17, 12, 17, 4300, 13259, 29, 8032, 9, 339, 308, 275, 603, 54, 360, 83, 297, 283, 7033, 358, 272, 373, 275, 603, 54, 360, 86, 297, 283, 4106, 358, 272, 330, 275, 603, 54, 360, 66, 297, 283, 66, 1912, 630, 358, 339, 870, 8, 82, 11525, 19, 36, 4236, 273, 19133, 22465, 60, 12210, 358, 339, 870, 7863, 30233, 12280, 10993, 272, 870, 360, 83, 28414, 308, 9, 272, 870, 360, 86, 28414, 373, 9, 272, 870, 360, 66, 28414, 330, 9, 339, 870, 7863, 29631, 10993, 339, 1323, 275, 3666, 83, 12, 283, 83, 659, 334, 86, 12, 283, 86, 659, 334, 66, 12, 283, 66, 1333, 339, 367, 19905, 315, 1323, 26, 267, 870, 8355, 267, 367, 28008, 315, 1323, 26, 288, 870, 8, 6865, 59, 17, 61, 435, 13626, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 3672, 21643, 59, 16, 566, 288, 870, 8, 6865, 59, 17, 61, 435, 14452, 7, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 7167, 28008, 59, 16, 566, 288, 870, 8, 6865, 59, 17, 61, 435, 24628, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 1204, 28008, 59, 16, 566, 288, 870, 8, 6865, 59, 17, 61, 435, 24958, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 665, 28008, 59, 16, 566, 288, 870, 8, 6865, 59, 17, 61, 435, 21770, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 690, 28008, 59, 16, 566, 339, 7449, 275, 603, 54, 360, 83, 297, 283, 7033, 297, 289, 319, 29, 549, 9, 272, 289, 86, 275, 603, 54, 360, 86, 297, 283, 4106, 297, 289, 319, 29, 549, 9, 272, 24209, 275, 603, 54, 360, 66, 297, 283, 66, 1912, 630, 297, 289, 319, 29, 549, 9, 339, 870, 7863, 16867, 857, 630, 17471, 10993, 339, 870, 360, 83, 8, 56, 9, 28414, 7449, 9, 272, 870, 360, 86, 8, 56, 9, 28414, 289, 86, 9, 272, 870, 360, 66, 8, 56, 9, 28414, 24209, 9, 339, 870, 7863, 29631, 10993, 339, 289, 56, 275, 3666, 6017, 12, 283, 6017, 659, 334, 2319, 12, 283, 83, 659, 334, 13692, 12, 283, 86, 659, 334, 4675, 12, 283, 66, 1333, 339, 367, 19905, 315, 289, 56, 26, 267, 870, 8355, 267, 367, 28008, 315, 289, 56, 26, 288, 340, 19905, 59, 17, 61, 508, 283, 6017, 7, 436, 28008, 59, 17, 61, 508, 283, 6017, 356, 355, 986, 288, 587, 26, 355, 870, 8, 6865, 59, 17, 61, 435, 13626, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 3672, 21643, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 14452, 7, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 7167, 28008, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 24628, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 1204, 28008, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 24958, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 665, 28008, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 21770, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 690, 28008, 59, 16, 566, 339, 334, 476, 12, 325, 89, 12, 7659, 9, 275, 603, 54, 14, 2758, 360, 69, 297, 13259, 2687, 88, 12, 612, 430, 339, 870, 8, 82, 11525, 14109, 499, 36, 22465, 60, 12210, 358, 272, 870, 7863, 16867, 857, 630, 17471, 10993, 339, 308, 275, 603, 54, 360, 83, 297, 283, 7033, 297, 289, 319, 29, 549, 9, 272, 373, 275, 603, 54, 360, 86, 297, 283, 4106, 297, 289, 319, 29, 549, 9, 272, 330, 275, 603, 54, 360, 86, 297, 283, 66, 1912, 630, 297, 289, 319, 29, 549, 9, 339, 870, 360, 83, 8, 56, 9, 28414, 308, 9, 272, 870, 360, 86, 8, 56, 9, 28414, 373, 9, 272, 870, 360, 66, 8, 56, 9, 28414, 330, 9, 339, 1323, 275, 3666, 6017, 12, 283, 6017, 659, 334, 83, 12, 283, 83, 659, 334, 86, 12, 283, 86, 1333, 339, 870, 7863, 29631, 10993, 339, 367, 19905, 315, 1323, 26, 267, 870, 8355, 267, 367, 28008, 315, 1323, 26, 288, 340, 19905, 59, 17, 61, 508, 283, 6017, 7, 436, 28008, 59, 17, 61, 508, 283, 6017, 356, 355, 986, 288, 587, 26, 355, 870, 8, 6865, 59, 17, 61, 435, 13626, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 3672, 21643, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 14452, 7, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 7167, 28008, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 24628, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 1204, 28008, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 24958, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 665, 28008, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 21770, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 690, 28008, 59, 16, 566, 339, 671, 68, 433, 8, 10443, 534, 9269, 358, 272, 372, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 5840, 492, 6698, 199, 504, 5840, 14, 27074, 19355, 492, 603, 54, 12, 9701, 199, 504, 5840, 14, 27074, 19355, 492, 671, 68, 433, 199, 199, 318, 2446, 837, 272, 9701, 342, 339, 13259, 275, 334, 88, 12, 612, 12, 1315, 9, 275, 6698, 360, 88, 612, 1315, 358, 339, 334, 476, 12, 325, 89, 12, 325, 90, 12, 7659, 9, 275, 603, 54, 14, 2758, 360, 69, 10, 88, 92, 89, 92, 90, 297, 6730, 17, 12, 17, 12, 17, 4300, 13259, 29, 8032, 9, 339, 308, 275, 603, 54, 360, 83, 297, 283, 7033, 358, 272, 373, 275, 603, 54, 360, 86, 297, 283, 4106, 358, 272, 330, 275, 603, 54, 360, 66, 297, 283, 66, 1912, 630, 358, 339, 870, 8, 82, 11525, 19, 36, 4236, 273, 19133, 22465, 60, 12210, 358, 339, 870, 7863, 30233, 12280, 10993, 272, 870, 360, 83, 28414, 308, 9, 272, 870, 360, 86, 28414, 373, 9, 272, 870, 360, 66, 28414, 330, 9, 339, 870, 7863, 29631, 10993, 339, 1323, 275, 3666, 83, 12, 283, 83, 659, 334, 86, 12, 283, 86, 659, 334, 66, 12, 283, 66, 1333, 339, 367, 19905, 315, 1323, 26, 267, 870, 8355, 267, 367, 28008, 315, 1323, 26, 288, 870, 8, 6865, 59, 17, 61, 435, 13626, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 3672, 21643, 59, 16, 566, 288, 870, 8, 6865, 59, 17, 61, 435, 14452, 7, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 7167, 28008, 59, 16, 566, 288, 870, 8, 6865, 59, 17, 61, 435, 24628, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 1204, 28008, 59, 16, 566, 288, 870, 8, 6865, 59, 17, 61, 435, 24958, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 665, 28008, 59, 16, 566, 288, 870, 8, 6865, 59, 17, 61, 435, 21770, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 690, 28008, 59, 16, 566, 339, 7449, 275, 603, 54, 360, 83, 297, 283, 7033, 297, 289, 319, 29, 549, 9, 272, 289, 86, 275, 603, 54, 360, 86, 297, 283, 4106, 297, 289, 319, 29, 549, 9, 272, 24209, 275, 603, 54, 360, 66, 297, 283, 66, 1912, 630, 297, 289, 319, 29, 549, 9, 339, 870, 7863, 16867, 857, 630, 17471, 10993, 339, 870, 360, 83, 8, 56, 9, 28414, 7449, 9, 272, 870, 360, 86, 8, 56, 9, 28414, 289, 86, 9, 272, 870, 360, 66, 8, 56, 9, 28414, 24209, 9, 339, 870, 7863, 29631, 10993, 339, 289, 56, 275, 3666, 6017, 12, 283, 6017, 659, 334, 2319, 12, 283, 83, 659, 334, 13692, 12, 283, 86, 659, 334, 4675, 12, 283, 66, 1333, 339, 367, 19905, 315, 289, 56, 26, 267, 870, 8355, 267, 367, 28008, 315, 289, 56, 26, 288, 340, 19905, 59, 17, 61, 508, 283, 6017, 7, 436, 28008, 59, 17, 61, 508, 283, 6017, 356, 355, 986, 288, 587, 26, 355, 870, 8, 6865, 59, 17, 61, 435, 13626, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 3672, 21643, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 14452, 7, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 7167, 28008, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 24628, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 1204, 28008, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 24958, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 665, 28008, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 21770, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 690, 28008, 59, 16, 566, 339, 334, 476, 12, 325, 89, 12, 7659, 9, 275, 603, 54, 14, 2758, 360, 69, 297, 13259, 2687, 88, 12, 612, 430, 339, 870, 8, 82, 11525, 14109, 499, 36, 22465, 60, 12210, 358, 272, 870, 7863, 16867, 857, 630, 17471, 10993, 339, 308, 275, 603, 54, 360, 83, 297, 283, 7033, 297, 289, 319, 29, 549, 9, 272, 373, 275, 603, 54, 360, 86, 297, 283, 4106, 297, 289, 319, 29, 549, 9, 272, 330, 275, 603, 54, 360, 86, 297, 283, 66, 1912, 630, 297, 289, 319, 29, 549, 9, 339, 870, 360, 83, 8, 56, 9, 28414, 308, 9, 272, 870, 360, 86, 8, 56, 9, 28414, 373, 9, 272, 870, 360, 66, 8, 56, 9, 28414, 330, 9, 339, 1323, 275, 3666, 6017, 12, 283, 6017, 659, 334, 83, 12, 283, 83, 659, 334, 86, 12, 283, 86, 1333, 339, 870, 7863, 29631, 10993, 339, 367, 19905, 315, 1323, 26, 267, 870, 8355, 267, 367, 28008, 315, 1323, 26, 288, 340, 19905, 59, 17, 61, 508, 283, 6017, 7, 436, 28008, 59, 17, 61, 508, 283, 6017, 356, 355, 986, 288, 587, 26, 355, 870, 8, 6865, 59, 17, 61, 435, 13626, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 3672, 21643, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 14452, 7, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 7167, 28008, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 24628, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 1204, 28008, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 24958, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 665, 28008, 59, 16, 566, 355, 870, 8, 6865, 59, 17, 61, 435, 21770, 435, 28008, 59, 17, 61, 435, 283, 28414, 19905, 59, 16, 61, 690, 28008, 59, 16, 566, 339, 671, 68, 433, 8, 10443, 534, 9269, 358, 272, 372, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
LordDamionDevil/Lony
lib/discord/embeds.py
17
13379
# -*- coding: utf-8 -*- """ The MIT License (MIT) Copyright (c) 2015-2016 Rapptz 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 datetime from .colour import Colour from . import utils class _EmptyEmbed: def __bool__(self): return False def __repr__(self): return 'Embed.Empty' EmptyEmbed = _EmptyEmbed() class EmbedProxy: def __init__(self, layer): self.__dict__.update(layer) def __repr__(self): return 'EmbedProxy(%s)' % ', '.join(('%s=%r' % (k, v) for k, v in self.__dict__.items() if not k.startswith('_'))) def __getattr__(self, attr): return EmptyEmbed class Embed: """Represents a Discord embed. The following attributes can be set during creation of the object: Certain properties return an ``EmbedProxy``. Which is a type that acts similar to a regular `dict` except access the attributes via dotted access, e.g. ``embed.author.icon_url``. If the attribute is invalid or empty, then a special sentinel value is returned, :attr:`Embed.Empty`. For ease of use, all parameters that expect a ``str`` are implicitly casted to ``str`` for you. Attributes ----------- title: str The title of the embed. type: str The type of embed. Usually "rich". description: str The description of the embed. url: str The URL of the embed. timestamp: `datetime.datetime` The timestamp of the embed content. colour: :class:`Colour` or int The colour code of the embed. Aliased to ``color`` as well. Empty A special sentinel value used by ``EmbedProxy`` and this class to denote that the value or attribute is empty. """ __slots__ = ('title', 'url', 'type', '_timestamp', '_colour', '_footer', '_image', '_thumbnail', '_video', '_provider', '_author', '_fields', 'description') Empty = EmptyEmbed def __init__(self, **kwargs): # swap the colour/color aliases try: colour = kwargs['colour'] except KeyError: colour = kwargs.get('color', EmptyEmbed) self.colour = colour self.title = kwargs.get('title', EmptyEmbed) self.type = kwargs.get('type', 'rich') self.url = kwargs.get('url', EmptyEmbed) self.description = kwargs.get('description', EmptyEmbed) try: timestamp = kwargs['timestamp'] except KeyError: pass else: self.timestamp = timestamp @classmethod def from_data(cls, data): # we are bypassing __init__ here since it doesn't apply here self = cls.__new__(cls) # fill in the basic fields self.title = data.get('title', EmptyEmbed) self.type = data.get('type', EmptyEmbed) self.description = data.get('description', EmptyEmbed) self.url = data.get('url', EmptyEmbed) # try to fill in the more rich fields try: self._colour = Colour(value=data['color']) except KeyError: pass try: self._timestamp = utils.parse_time(data['timestamp']) except KeyError: pass for attr in ('thumbnail', 'video', 'provider', 'author', 'fields'): try: value = data[attr] except KeyError: continue else: setattr(self, '_' + attr, value) return self @property def colour(self): return getattr(self, '_colour', EmptyEmbed) @colour.setter def colour(self, value): if isinstance(value, (Colour, _EmptyEmbed)): self._colour = value elif isinstance(value, int): self._colour = Colour(value=value) else: raise TypeError('Expected discord.Colour, int, or Embed.Empty but received %s instead.' % value.__class__.__name__) color = colour @property def timestamp(self): return getattr(self, '_timestamp', EmptyEmbed) @timestamp.setter def timestamp(self, value): if isinstance(value, (datetime.datetime, _EmptyEmbed)): self._timestamp = value else: raise TypeError("Expected datetime.datetime or Embed.Empty received %s instead" % value.__class__.__name__) @property def footer(self): """Returns a ``EmbedProxy`` denoting the footer contents. See :meth:`set_footer` for possible values you can access. If the attribute has no value then :attr:`Empty` is returned. """ return EmbedProxy(getattr(self, '_footer', {})) def set_footer(self, *, text=EmptyEmbed, icon_url=EmptyEmbed): """Sets the footer for the embed content. This function returns the class instance to allow for fluent-style chaining. Parameters ----------- text: str The footer text. icon_url: str The URL of the footer icon. Only HTTP(S) is supported. """ self._footer = {} if text is not EmptyEmbed: self._footer['text'] = str(text) if icon_url is not EmptyEmbed: self._footer['icon_url'] = str(icon_url) return self @property def image(self): """Returns a ``EmbedProxy`` denoting the image contents. Possible attributes you can access are: - ``url`` - ``proxy_url`` - ``width`` - ``height`` If the attribute has no value then :attr:`Empty` is returned. """ return EmbedProxy(getattr(self, '_image', {})) def set_image(self, *, url): """Sets the image for the embed content. This function returns the class instance to allow for fluent-style chaining. Parameters ----------- url: str The source URL for the image. Only HTTP(S) is supported. """ self._image = { 'url': str(url) } return self @property def thumbnail(self): """Returns a ``EmbedProxy`` denoting the thumbnail contents. Possible attributes you can access are: - ``url`` - ``proxy_url`` - ``width`` - ``height`` If the attribute has no value then :attr:`Empty` is returned. """ return EmbedProxy(getattr(self, '_thumbnail', {})) def set_thumbnail(self, *, url): """Sets the thumbnail for the embed content. This function returns the class instance to allow for fluent-style chaining. Parameters ----------- url: str The source URL for the thumbnail. Only HTTP(S) is supported. """ self._thumbnail = { 'url': str(url) } return self @property def video(self): """Returns a ``EmbedProxy`` denoting the video contents. Possible attributes include: - ``url`` for the video URL. - ``height`` for the video height. - ``width`` for the video width. If the attribute has no value then :attr:`Empty` is returned. """ return EmbedProxy(getattr(self, '_video', {})) @property def provider(self): """Returns a ``EmbedProxy`` denoting the provider contents. The only attributes that might be accessed are ``name`` and ``url``. If the attribute has no value then :attr:`Empty` is returned. """ return EmbedProxy(getattr(self, '_provider', {})) @property def author(self): """Returns a ``EmbedProxy`` denoting the author contents. See :meth:`set_author` for possible values you can access. If the attribute has no value then :attr:`Empty` is returned. """ return EmbedProxy(getattr(self, '_author', {})) def set_author(self, *, name, url=EmptyEmbed, icon_url=EmptyEmbed): """Sets the author for the embed content. This function returns the class instance to allow for fluent-style chaining. Parameters ----------- name: str The name of the author. url: str The URL for the author. icon_url: str The URL of the author icon. Only HTTP(S) is supported. """ self._author = { 'name': str(name) } if url is not EmptyEmbed: self._author['url'] = str(url) if icon_url is not EmptyEmbed: self._author['icon_url'] = str(icon_url) return self @property def fields(self): """Returns a list of ``EmbedProxy`` denoting the field contents. See :meth:`add_field` for possible values you can access. If the attribute has no value then :attr:`Empty` is returned. """ return [EmbedProxy(d) for d in getattr(self, '_fields', [])] def add_field(self, *, name, value, inline=True): """Adds a field to the embed object. This function returns the class instance to allow for fluent-style chaining. Parameters ----------- name: str The name of the field. value: str The value of the field. inline: bool Whether the field should be displayed inline. """ field = { 'inline': inline, 'name': str(name), 'value': str(value) } try: self._fields.append(field) except AttributeError: self._fields = [field] return self def clear_fields(self): """Removes all fields from this embed.""" try: self._fields.clear() except AttributeError: self._fields = [] def remove_field(self, index): """Removes a field at a specified index. If the index is invalid or out of bounds then the error is silently swallowed. .. note:: When deleting a field by index, the index of the other fields shift to fill the gap just like a regular list. Parameters ----------- index: int The index of the field to remove. """ try: del self._fields[index] except (AttributeError, IndexError): pass def set_field_at(self, index, *, name, value, inline=True): """Modifies a field to the embed object. The index must point to a valid pre-existing field. This function returns the class instance to allow for fluent-style chaining. Parameters ----------- index: int The index of the field to modify. name: str The name of the field. value: str The value of the field. inline: bool Whether the field should be displayed inline. Raises ------- IndexError An invalid index was provided. """ try: field = self._fields[index] except (TypeError, IndexError, AttributeError): raise IndexError('field index out of range') field['name'] = str(name) field['value'] = str(value) field['inline'] = inline return self def to_dict(self): """Converts this embed object into a dict.""" # add in the raw data into the dict result = { key[1:]: getattr(self, key) for key in self.__slots__ if key[0] == '_' and hasattr(self, key) } # deal with basic convenience wrappers try: colour = result.pop('colour') except KeyError: pass else: if colour: result['color'] = colour.value try: timestamp = result.pop('timestamp') except KeyError: pass else: if timestamp: result['timestamp'] = timestamp.isoformat() # add in the non raw attribute ones if self.type: result['type'] = self.type if self.description: result['description'] = self.description if self.url: result['url'] = self.url if self.title: result['title'] = self.title return result
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 7384, 334, 67, 9, 6900, 13, 9261, 820, 439, 541, 90, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 1574, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 199, 475, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 199, 1589, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 199, 460, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 199, 10337, 365, 13985, 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, 199, 726, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 199, 12491, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 199, 1093, 13157, 1621, 2334, 4141, 14, 199, 624, 199, 199, 646, 2197, 199, 199, 504, 1275, 14476, 492, 1849, 7632, 199, 504, 1275, 492, 3778, 199, 199, 533, 485, 4699, 13200, 26, 272, 347, 636, 2245, 721, 277, 304, 267, 372, 756, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 13200, 14, 4699, 7, 199, 199, 4699, 13200, 275, 485, 4699, 13200, 342, 199, 199, 533, 24297, 4936, 26, 272, 347, 636, 826, 721, 277, 12, 4045, 304, 267, 291, 855, 807, 4343, 873, 8, 1897, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 13200, 4936, 4042, 83, 3171, 450, 1656, 1987, 904, 8, 3508, 83, 2458, 82, 7, 450, 334, 75, 12, 373, 9, 367, 1022, 12, 373, 315, 291, 855, 807, 4343, 1744, 342, 340, 440, 1022, 14, 2460, 6412, 7058, 339, 347, 636, 5675, 721, 277, 12, 1921, 304, 267, 372, 9630, 13200, 199, 199, 533, 24297, 26, 272, 408, 18089, 282, 5289, 1577, 6441, 14, 339, 710, 2569, 3004, 883, 506, 663, 5309, 7143, 272, 402, 314, 909, 26, 339, 11002, 877, 4382, 372, 376, 1124, 13200, 4936, 4345, 26058, 365, 282, 730, 272, 626, 17795, 8545, 370, 282, 5578, 658, 807, 64, 871, 2879, 314, 3004, 272, 4799, 18947, 2879, 12, 325, 14, 71, 14, 1124, 6427, 14, 2502, 14, 4677, 63, 633, 4345, 982, 314, 2225, 272, 365, 3866, 503, 2701, 12, 2066, 282, 4539, 13792, 574, 365, 2138, 12, 272, 520, 962, 1705, 13200, 14, 4699, 2313, 339, 2104, 325, 482, 402, 675, 12, 1006, 2633, 626, 4282, 282, 1124, 495, 1040, 787, 19796, 272, 14984, 471, 370, 1124, 495, 1040, 367, 1265, 14, 339, 9382, 272, 3001, 2595, 272, 2538, 26, 620, 267, 710, 2538, 402, 314, 6441, 14, 272, 730, 26, 620, 267, 710, 730, 402, 6441, 14, 24612, 298, 10399, 1674, 272, 1369, 26, 620, 267, 710, 1369, 402, 314, 6441, 14, 272, 1166, 26, 620, 267, 710, 2851, 402, 314, 6441, 14, 272, 4913, 26, 658, 2083, 14, 2083, 64, 267, 710, 4913, 402, 314, 6441, 1564, 14, 272, 15706, 26, 520, 533, 1705, 15758, 64, 503, 1109, 267, 710, 15706, 1233, 402, 314, 6441, 14, 15170, 11185, 370, 1124, 2326, 1040, 465, 5521, 14, 272, 9630, 267, 437, 4539, 13792, 574, 1202, 701, 1124, 13200, 4936, 1040, 436, 642, 1021, 267, 370, 477, 4610, 626, 314, 574, 503, 2225, 365, 2701, 14, 272, 408, 339, 636, 7257, 363, 275, 661, 1213, 297, 283, 633, 297, 283, 466, 297, 2513, 3954, 297, 2513, 14476, 297, 2513, 12781, 297, 326, 2513, 1569, 297, 2513, 8311, 297, 2513, 3722, 297, 2513, 3780, 297, 2513, 2502, 297, 326, 2513, 955, 297, 283, 1802, 358, 339, 9630, 275, 9630, 13200, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 327, 11413, 314, 15706, 15, 2326, 5481, 267, 862, 26, 288, 15706, 275, 2074, 459, 14476, 418, 267, 871, 4067, 26, 288, 15706, 275, 2074, 14, 362, 360, 2326, 297, 9630, 13200, 9, 398, 291, 14, 14476, 275, 15706, 267, 291, 14, 1213, 275, 2074, 14, 362, 360, 1213, 297, 9630, 13200, 9, 267, 291, 14, 466, 275, 2074, 14, 362, 360, 466, 297, 283, 10399, 358, 267, 291, 14, 633, 275, 2074, 14, 362, 360, 633, 297, 9630, 13200, 9, 267, 291, 14, 1802, 275, 2074, 14, 362, 360, 1802, 297, 9630, 13200, 9, 398, 862, 26, 288, 4913, 275, 2074, 459, 3954, 418, 267, 871, 4067, 26, 288, 986, 267, 587, 26, 288, 291, 14, 3954, 275, 4913, 339, 768, 3744, 272, 347, 687, 63, 576, 8, 1886, 12, 666, 304, 267, 327, 781, 787, 21115, 316, 636, 826, 363, 2348, 3967, 652, 3181, 1133, 4838, 2348, 267, 291, 275, 843, 855, 1222, 721, 1886, 9, 398, 327, 5554, 315, 314, 5678, 1504, 398, 291, 14, 1213, 275, 666, 14, 362, 360, 1213, 297, 9630, 13200, 9, 267, 291, 14, 466, 221, 275, 666, 14, 362, 360, 466, 297, 9630, 13200, 9, 267, 291, 14, 1802, 275, 666, 14, 362, 360, 1802, 297, 9630, 13200, 9, 267, 291, 14, 633, 275, 666, 14, 362, 360, 633, 297, 9630, 13200, 9, 398, 327, 862, 370, 5554, 315, 314, 1655, 30162, 1504, 398, 862, 26, 288, 291, 423, 14476, 275, 1849, 7632, 8, 585, 29, 576, 459, 2326, 1105, 267, 871, 4067, 26, 288, 986, 398, 862, 26, 288, 291, 423, 3954, 275, 3778, 14, 1122, 63, 521, 8, 576, 459, 3954, 1105, 267, 871, 4067, 26, 288, 986, 398, 367, 1921, 315, 661, 8311, 297, 283, 3722, 297, 283, 3780, 297, 283, 2502, 297, 283, 955, 735, 288, 862, 26, 355, 574, 275, 666, 59, 962, 61, 288, 871, 4067, 26, 355, 1980, 288, 587, 26, 355, 5371, 8, 277 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 7384, 334, 67, 9, 6900, 13, 9261, 820, 439, 541, 90, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 1574, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 199, 475, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 199, 1589, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 199, 460, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 199, 10337, 365, 13985, 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, 199, 726, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 199, 12491, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 199, 1093, 13157, 1621, 2334, 4141, 14, 199, 624, 199, 199, 646, 2197, 199, 199, 504, 1275, 14476, 492, 1849, 7632, 199, 504, 1275, 492, 3778, 199, 199, 533, 485, 4699, 13200, 26, 272, 347, 636, 2245, 721, 277, 304, 267, 372, 756, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 13200, 14, 4699, 7, 199, 199, 4699, 13200, 275, 485, 4699, 13200, 342, 199, 199, 533, 24297, 4936, 26, 272, 347, 636, 826, 721, 277, 12, 4045, 304, 267, 291, 855, 807, 4343, 873, 8, 1897, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 13200, 4936, 4042, 83, 3171, 450, 1656, 1987, 904, 8, 3508, 83, 2458, 82, 7, 450, 334, 75, 12, 373, 9, 367, 1022, 12, 373, 315, 291, 855, 807, 4343, 1744, 342, 340, 440, 1022, 14, 2460, 6412, 7058, 339, 347, 636, 5675, 721, 277, 12, 1921, 304, 267, 372, 9630, 13200, 199, 199, 533, 24297, 26, 272, 408, 18089, 282, 5289, 1577, 6441, 14, 339, 710, 2569, 3004, 883, 506, 663, 5309, 7143, 272, 402, 314, 909, 26, 339, 11002, 877, 4382, 372, 376, 1124, 13200, 4936, 4345, 26058, 365, 282, 730, 272, 626, 17795, 8545, 370, 282, 5578, 658, 807, 64, 871, 2879, 314, 3004, 272, 4799, 18947, 2879, 12, 325, 14, 71, 14, 1124, 6427, 14, 2502, 14, 4677, 63, 633, 4345, 982, 314, 2225, 272, 365, 3866, 503, 2701, 12, 2066, 282, 4539, 13792, 574, 365, 2138, 12, 272, 520, 962, 1705, 13200, 14, 4699, 2313, 339, 2104, 325, 482, 402, 675, 12, 1006, 2633, 626, 4282, 282, 1124, 495, 1040, 787, 19796, 272, 14984, 471, 370, 1124, 495, 1040, 367, 1265, 14, 339, 9382, 272, 3001, 2595, 272, 2538, 26, 620, 267, 710, 2538, 402, 314, 6441, 14, 272, 730, 26, 620, 267, 710, 730, 402, 6441, 14, 24612, 298, 10399, 1674, 272, 1369, 26, 620, 267, 710, 1369, 402, 314, 6441, 14, 272, 1166, 26, 620, 267, 710, 2851, 402, 314, 6441, 14, 272, 4913, 26, 658, 2083, 14, 2083, 64, 267, 710, 4913, 402, 314, 6441, 1564, 14, 272, 15706, 26, 520, 533, 1705, 15758, 64, 503, 1109, 267, 710, 15706, 1233, 402, 314, 6441, 14, 15170, 11185, 370, 1124, 2326, 1040, 465, 5521, 14, 272, 9630, 267, 437, 4539, 13792, 574, 1202, 701, 1124, 13200, 4936, 1040, 436, 642, 1021, 267, 370, 477, 4610, 626, 314, 574, 503, 2225, 365, 2701, 14, 272, 408, 339, 636, 7257, 363, 275, 661, 1213, 297, 283, 633, 297, 283, 466, 297, 2513, 3954, 297, 2513, 14476, 297, 2513, 12781, 297, 326, 2513, 1569, 297, 2513, 8311, 297, 2513, 3722, 297, 2513, 3780, 297, 2513, 2502, 297, 326, 2513, 955, 297, 283, 1802, 358, 339, 9630, 275, 9630, 13200, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 327, 11413, 314, 15706, 15, 2326, 5481, 267, 862, 26, 288, 15706, 275, 2074, 459, 14476, 418, 267, 871, 4067, 26, 288, 15706, 275, 2074, 14, 362, 360, 2326, 297, 9630, 13200, 9, 398, 291, 14, 14476, 275, 15706, 267, 291, 14, 1213, 275, 2074, 14, 362, 360, 1213, 297, 9630, 13200, 9, 267, 291, 14, 466, 275, 2074, 14, 362, 360, 466, 297, 283, 10399, 358, 267, 291, 14, 633, 275, 2074, 14, 362, 360, 633, 297, 9630, 13200, 9, 267, 291, 14, 1802, 275, 2074, 14, 362, 360, 1802, 297, 9630, 13200, 9, 398, 862, 26, 288, 4913, 275, 2074, 459, 3954, 418, 267, 871, 4067, 26, 288, 986, 267, 587, 26, 288, 291, 14, 3954, 275, 4913, 339, 768, 3744, 272, 347, 687, 63, 576, 8, 1886, 12, 666, 304, 267, 327, 781, 787, 21115, 316, 636, 826, 363, 2348, 3967, 652, 3181, 1133, 4838, 2348, 267, 291, 275, 843, 855, 1222, 721, 1886, 9, 398, 327, 5554, 315, 314, 5678, 1504, 398, 291, 14, 1213, 275, 666, 14, 362, 360, 1213, 297, 9630, 13200, 9, 267, 291, 14, 466, 221, 275, 666, 14, 362, 360, 466, 297, 9630, 13200, 9, 267, 291, 14, 1802, 275, 666, 14, 362, 360, 1802, 297, 9630, 13200, 9, 267, 291, 14, 633, 275, 666, 14, 362, 360, 633, 297, 9630, 13200, 9, 398, 327, 862, 370, 5554, 315, 314, 1655, 30162, 1504, 398, 862, 26, 288, 291, 423, 14476, 275, 1849, 7632, 8, 585, 29, 576, 459, 2326, 1105, 267, 871, 4067, 26, 288, 986, 398, 862, 26, 288, 291, 423, 3954, 275, 3778, 14, 1122, 63, 521, 8, 576, 459, 3954, 1105, 267, 871, 4067, 26, 288, 986, 398, 367, 1921, 315, 661, 8311, 297, 283, 3722, 297, 283, 3780, 297, 283, 2502, 297, 283, 955, 735, 288, 862, 26, 355, 574, 275, 666, 59,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
MikkCZ/kitsune
kitsune/wiki/views.py
2
62318
import json import logging import time import re from datetime import datetime from functools import wraps from django.conf import settings from django.contrib import messages from django.contrib.auth.models import User from django.core.cache import cache from django.core.exceptions import PermissionDenied from django.db import connection from django.forms.util import ErrorList from django.http import (HttpResponse, HttpResponseRedirect, Http404, HttpResponseBadRequest) from django.shortcuts import get_object_or_404, render from django.template.loader import render_to_string from django.utils.translation import ugettext_lazy as _lazy, ugettext as _ from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import (require_GET, require_POST, require_http_methods) from mobility.decorators import mobile_template from django_statsd.clients import statsd from kitsune.access.decorators import login_required from kitsune.lib.sumo_locales import LOCALES from kitsune.products.models import Product, Topic from kitsune.sumo.decorators import ratelimit from kitsune.sumo.templatetags.jinja_helpers import urlparams from kitsune.sumo.redis_utils import redis_client, RedisError from kitsune.sumo.urlresolvers import reverse from kitsune.sumo.utils import paginate, smart_int, get_next_url, truncated_json_dumps, get_browser from kitsune.wiki.config import ( CATEGORIES, MAJOR_SIGNIFICANCE, TEMPLATES_CATEGORY, DOCUMENTS_PER_PAGE, COLLAPSIBLE_DOCUMENTS, FALLBACK_LOCALES) from kitsune.wiki.events import ( EditDocumentEvent, ReviewableRevisionInLocaleEvent, ApproveRevisionInLocaleEvent, ApprovedOrReadyUnion, ReadyRevisionEvent) from kitsune.wiki.forms import ( AddContributorForm, DocumentForm, RevisionForm, RevisionFilterForm, ReviewForm, DraftRevisionForm) from kitsune.wiki.models import ( Document, Revision, DraftRevision, HelpfulVote, ImportantDate, doc_html_cache_key, TitleCollision, SlugCollision) from kitsune.wiki.parser import wiki_to_html from kitsune.wiki.tasks import ( send_reviewed_notification, schedule_rebuild_kb, send_contributor_notification, render_document_cascade) log = logging.getLogger('k.wiki') def doc_page_cache(view): """Decorator that caches the document page HTML.""" @wraps(view) def _doc_page_cache_view(request, document_slug, *args, **kwargs): # We skip caching for authed users or if redirect=no # is in the query string. if (request.user.is_authenticated() or request.GET.get('redirect') == 'no'): statsd.incr('wiki.document_view.cache.skip') return view(request, document_slug, *args, **kwargs) cache_key = doc_html_cache_key( mobile=request.MOBILE, locale=request.LANGUAGE_CODE, slug=document_slug, minimal=request.GET.get('minimal', '0')) html, headers = cache.get(cache_key, (None, None)) if html is not None: statsd.incr('wiki.document_view.cache.hit') res = HttpResponse(html) for key, val in headers.items(): res[key] = val return res statsd.incr('wiki.document_view.cache.miss') response = view(request, document_slug, *args, **kwargs) # We only cache if the response returns HTTP 200. if response.status_code == 200: cache.set(cache_key, (response.content, dict(response._headers.values()))) return response return _doc_page_cache_view @require_GET @doc_page_cache @mobile_template('wiki/{mobile/}') def document(request, document_slug, template=None, document=None): """View a wiki document.""" fallback_reason = None full_locale_name = None # If a slug isn't available in the requested locale, fall back to en-US: try: doc = Document.objects.get(locale=request.LANGUAGE_CODE, slug=document_slug) if (not doc.current_revision and doc.parent and doc.parent.current_revision): # This is a translation but its current_revision is None # and OK to fall back to parent (parent is approved). fallback_reason = 'translation_not_approved' elif not doc.current_revision: # No current_revision, no parent with current revision, so # nothing to show. fallback_reason = 'no_content' except Document.DoesNotExist: # Look in default language: doc = get_object_or_404(Document, locale=settings.WIKI_DEFAULT_LANGUAGE, slug=document_slug) # If there's a translation to the requested locale, take it: translation = doc.translated_to(request.LANGUAGE_CODE) if translation: url = translation.get_absolute_url() url = urlparams(url, query_dict=request.GET) return HttpResponseRedirect(url) elif doc.current_revision: # There is no translation # and OK to fall back to parent (parent is approved). fallback_reason = 'no_translation' # Find and show the defined fallback locale rather than the English version of the document # The fallback locale is defined based on the ACCEPT_LANGUAGE header, # site-wide locale mapping and custom fallback locale # The custom fallback locale is defined in the FALLBACK_LOCALES array in # kitsune/wiki/config.py. See bug 800880 for more details if fallback_reason == 'no_translation': fallback_locale = get_fallback_locale(doc, request) # If a fallback locale is defined, show the document in that locale. if fallback_locale is not None: # Get the fallback Locale and show doc in the locale translation = doc.translated_to(fallback_locale) doc = translation # For showing the fallback locale explanation message to the user fallback_reason = 'fallback_locale' full_locale_name = {request.LANGUAGE_CODE: LOCALES[request.LANGUAGE_CODE].native, fallback_locale: LOCALES[fallback_locale].native} # If there is no defined fallback locale, show the document in English else: doc = get_object_or_404(Document, locale=settings.WIKI_DEFAULT_LANGUAGE, slug=document_slug) any_localizable_revision = doc.revisions.filter(is_approved=True, is_ready_for_localization=True).exists() # Obey explicit redirect pages: # Don't redirect on redirect=no (like Wikipedia), so we can link from a # redirected-to-page back to a "Redirected from..." link, so you can edit # the redirect. redirect_url = (None if request.GET.get('redirect') == 'no' else doc.redirect_url(request.LANGUAGE_CODE)) if redirect_url: url = urlparams(redirect_url, query_dict=request.GET, redirectslug=doc.slug, redirectlocale=doc.locale) return HttpResponseRedirect(url) # Get "redirected from" doc if we were redirected: redirect_slug = request.GET.get('redirectslug') redirect_locale = request.GET.get('redirectlocale') redirected_from = None if redirect_slug and redirect_locale: try: redirected_from = Document.objects.get(locale=redirect_locale, slug=redirect_slug) except Document.DoesNotExist: pass contributors = doc.contributors.all() products = doc.get_products() if len(products) < 1: product = Product.objects.filter(visible=True)[0] else: product = products[0] product_topics = Topic.objects.filter(product=product, visible=True, parent=None) if document_slug in COLLAPSIBLE_DOCUMENTS.get(request.LANGUAGE_CODE, []): document_css_class = 'collapsible' else: document_css_class = '' if request.MOBILE and 'minimal' in request.GET: template = '%sdocument-minimal.html' % template minimal = True else: template = '%sdocument.html' % template minimal = False # Build a set of breadcrumbs, ending with the document's title, and # starting with the product, with the topic(s) in between. # The breadcrumbs are built backwards, and then reversed. # Get document title. If it is like "Title - Subtitle", strip off the subtitle. trimmed_title = doc.title.split(' - ')[0].strip() breadcrumbs = [(None, trimmed_title)] # Get the dominant topic, and all parent topics. Save the topic chosen for # picking a product later. document_topics = doc.topics.order_by('display_order') if len(document_topics) > 0: topic = document_topics[0] first_topic = topic while topic is not None: breadcrumbs.append((topic.get_absolute_url(), topic.title)) topic = topic.parent # Get the product breadcrumbs.append((first_topic.product.get_absolute_url(), first_topic.product.title)) else: breadcrumbs.append((product.get_absolute_url(), product.title)) # The list above was built backwards, so flip this. breadcrumbs.reverse() user_agent = request.META.get('HTTP_USER_AGENT', '') browser = get_browser(user_agent) show_fx_download = (product.slug == 'thunderbird' and browser != 'Firefox') data = { 'document': doc, 'redirected_from': redirected_from, 'contributors': contributors, 'fallback_reason': fallback_reason, 'is_aoa_referral': request.GET.get('ref') == 'aoa', 'product_topics': product_topics, 'product': product, 'products': products, 'related_products': doc.related_products.exclude(pk=product.pk), 'breadcrumb_items': breadcrumbs, 'document_css_class': document_css_class, 'any_localizable_revision': any_localizable_revision, 'show_fx_download': show_fx_download, 'full_locale_name': full_locale_name } response = render(request, template, data) if minimal: response['X-Frame-Options'] = 'ALLOW' return response def revision(request, document_slug, revision_id): """View a wiki document revision.""" rev = get_object_or_404(Revision, pk=revision_id, document__slug=document_slug) data = {'document': rev.document, 'revision': rev} return render(request, 'wiki/revision.html', data) @require_GET def list_documents(request, category=None): """List wiki documents.""" docs = (Document.objects.filter(locale=request.LANGUAGE_CODE) .order_by('title')) if category: docs = docs.filter(category=category) try: category_id = int(category) except ValueError: raise Http404 try: category = unicode(dict(CATEGORIES)[category_id]) except KeyError: raise Http404 docs = paginate(request, docs, per_page=DOCUMENTS_PER_PAGE) return render(request, 'wiki/list_documents.html', { 'documents': docs, 'category': category}) @login_required def new_document(request): """Create a new wiki document.""" if request.method == 'GET': doc_form = DocumentForm(initial_title=request.GET.get('title')) rev_form = RevisionForm() return render(request, 'wiki/new_document.html', { 'document_form': doc_form, 'revision_form': rev_form, 'products': Product.objects.filter(visible=True)}) post_data = request.POST.copy() post_data.update({'locale': request.LANGUAGE_CODE}) doc_form = DocumentForm(post_data) rev_form = RevisionForm(post_data) if doc_form.is_valid() and rev_form.is_valid(): doc = doc_form.save(None) _save_rev_and_notify(rev_form, request.user, doc) return HttpResponseRedirect(reverse('wiki.document_revisions', args=[doc.slug])) return render(request, 'wiki/new_document.html', { 'document_form': doc_form, 'revision_form': rev_form, 'products': Product.objects.filter(visible=True)}) _document_lock_key = 'sumo::wiki::document::{id}::lock' def _document_lock_check(document_id): """Check for a lock on a document. Returns the username of the user that has the page locked, or ``None`` if no user has a lock. """ try: redis = redis_client(name='default') key = _document_lock_key.format(id=document_id) return redis.get(key) except RedisError as e: statsd.incr('redis.errror') log.error('Redis error: %s' % e) return None def _document_lock_steal(document_id, user_name, expire_time=60 * 15): """Lock a document for a user. Note that this does not check if the page is already locked, and simply sets the lock on the page. """ try: redis = redis_client(name='default') key = _document_lock_key.format(id=document_id) it_worked = redis.set(key, user_name) redis.expire(key, expire_time) return it_worked except RedisError as e: statsd.incr('redis.errror') log.error('Redis error: %s' % e) return False def _document_lock_clear(document_id, user_name): """Remove a lock from a document. This would be used to indicate the given user no longer wants the page locked, so the lock should be cleared. If the `user` parameter does not match the current lock, the lock remains in place. Returns true if the lock was removed, false otherwise. """ try: redis = redis_client(name='default') key = _document_lock_key.format(id=document_id) locked_by = redis.get(key) if locked_by == user_name: return redis.delete(key) else: return False except RedisError as e: statsd.incr('redis.errror') log.error('Redis error: %s' % e) return False def _document_lock(doc_id, username): """If there is no lock, take one. Return the current state of the lock.""" locked_by = _document_lock_check(doc_id) if locked_by == username: locked = False if locked_by: try: locked = not (locked_by == username) locked_by = User.objects.get(username=locked_by) except User.DoesNotExist: # If the user doesn't exist, they can't take a lock. locked = False locked_by = None else: locked_by = username locked = False _document_lock_steal(doc_id, username) return locked, locked_by @login_required def steal_lock(request, document_slug, revision_id=None): doc = get_object_or_404( Document, locale=request.LANGUAGE_CODE, slug=document_slug) user = request.user ok = _document_lock_steal(doc.id, user.username) return HttpResponse("", status=200 if ok else 400) @require_http_methods(['GET', 'POST']) @login_required def edit_document(request, document_slug, revision_id=None): """Create a new revision of a wiki document, or edit document metadata.""" try: doc = Document.objects.get(locale=request.LANGUAGE_CODE, slug=document_slug) except Document.DoesNotExist: # Check if the document slug is available in default language. parent_doc = get_object_or_404(Document, locale=settings.WIKI_DEFAULT_LANGUAGE, slug=document_slug) # If the document is available in default language, show the user the translation page # of the requested locale translation = parent_doc.translated_to(request.LANGUAGE_CODE) # If the document is translated into the requested locale, show them the edit article # page of that translated document if translation: doc = translation # If the document is not translated into the requested locale, redirect them to translate # the article page. else: url = reverse('wiki.translate', locale=request.LANGUAGE_CODE, args=[document_slug]) return HttpResponseRedirect(url) user = request.user can_edit_needs_change = doc.allows(user, 'edit_needs_change') can_archive = doc.allows(user, 'archive') # If this document has a parent, then the edit is handled by the # translate view. Pass it on. if doc.parent: return translate(request, doc.parent.slug, revision_id) if revision_id: rev = get_object_or_404(Revision, pk=revision_id, document=doc) else: rev = doc.current_revision or doc.revisions.order_by('-created', '-id')[0] disclose_description = bool(request.GET.get('opendescription')) doc_form = rev_form = None if doc.allows(user, 'create_revision'): rev_form = RevisionForm( instance=rev, initial={'based_on': rev.id, 'comment': ''}) if doc.allows(user, 'edit'): doc_form = DocumentForm( initial=_document_form_initial(doc), can_archive=can_archive, can_edit_needs_change=can_edit_needs_change) if request.method == 'GET': if not (rev_form or doc_form): # You can't do anything on this page, so get lost. raise PermissionDenied else: # POST # Comparing against localized names for the Save button bothers me, so # I embedded a hidden input: which_form = request.POST.get('form') _document_lock_clear(doc.id, user.username) if which_form == 'doc': if doc.allows(user, 'edit'): post_data = request.POST.copy() post_data.update({'locale': request.LANGUAGE_CODE}) topics = [] for t in post_data.getlist('topics'): topics.append(long(t)) post_data.setlist('topics', topics) doc_form = DocumentForm( post_data, instance=doc, can_archive=can_archive, can_edit_needs_change=can_edit_needs_change) if doc_form.is_valid(): # Get the possibly new slug for the imminent redirection: try: doc = doc_form.save(None) except (TitleCollision, SlugCollision) as e: # TODO: .add_error() when we upgrade to Django 1.7 errors = doc_form._errors.setdefault('title', ErrorList()) message = 'The {type} you selected is already in use.' message = message.format( type='title' if isinstance(e, TitleCollision) else 'slug') errors.append(_(message)) else: # Do we need to rebuild the KB? _maybe_schedule_rebuild(doc_form) return HttpResponseRedirect( urlparams(reverse('wiki.edit_document', args=[doc.slug]), opendescription=1)) disclose_description = True else: raise PermissionDenied elif which_form == 'rev': if doc.allows(user, 'create_revision'): rev_form = RevisionForm(request.POST) rev_form.instance.document = doc # for rev_form.clean() if rev_form.is_valid(): _save_rev_and_notify(rev_form, user, doc, base_rev=rev) if 'notify-future-changes' in request.POST: EditDocumentEvent.notify(request.user, doc) return HttpResponseRedirect( reverse('wiki.document_revisions', args=[document_slug])) else: raise PermissionDenied show_revision_warning = _show_revision_warning(doc, rev) locked, locked_by = _document_lock(doc.id, user.username) return render(request, 'wiki/edit.html', { 'revision_form': rev_form, 'document_form': doc_form, 'disclose_description': disclose_description, 'document': doc, 'show_revision_warning': show_revision_warning, 'locked': locked, 'locked_by': locked_by}) @csrf_exempt @login_required @require_POST def draft_revision(request): """Create a Draft Revision. User can have only one draft revision for a translated document. Store the draft with parent document, user and locale. Get the parent document from the based on revision""" draft_form = DraftRevisionForm(request.POST) if draft_form.is_valid(): draft_form.save(request=request) return HttpResponse(status=201) return HttpResponseBadRequest() @login_required @require_POST def preview_revision(request): """Create an HTML fragment preview of the posted wiki syntax.""" wiki_content = request.POST.get('content', '') slug = request.POST.get('slug') locale = request.POST.get('locale') statsd.incr('wiki.preview') if slug and locale: doc = get_object_or_404(Document, slug=slug, locale=locale) products = doc.get_products() else: products = Product.objects.all() data = { 'content': wiki_to_html(wiki_content, request.LANGUAGE_CODE), 'products': products } return render(request, 'wiki/preview.html', data) @require_GET def document_revisions(request, document_slug, contributor_form=None): """List all the revisions of a given document.""" locale = request.GET.get('locale', request.LANGUAGE_CODE) try: doc = Document.objects.get(locale=locale, slug=document_slug) except Document.DoesNotExist: # Check if the document slug is available in default language. parent_doc = get_object_or_404(Document, locale=settings.WIKI_DEFAULT_LANGUAGE, slug=document_slug) # If the document is available in default language, show the user the history page # of the requested locale translation = parent_doc.translated_to(locale) if translation: url = reverse('wiki.document_revisions', args=[translation.slug], locale=locale) return HttpResponseRedirect(url) else: raise Http404 revs = Revision.objects.filter(document=doc).order_by('-created', '-id') if request.is_ajax(): template = 'wiki/includes/revision_list.html' else: template = 'wiki/history.html' form = contributor_form or AddContributorForm() return render(request, template, { 'revisions': revs, 'document': doc, 'contributor_form': form}) @login_required def review_revision(request, document_slug, revision_id): """Review a revision of a wiki document.""" rev = get_object_or_404(Revision, pk=revision_id, document__slug=document_slug) doc = rev.document if not doc.allows(request.user, 'review_revision'): raise PermissionDenied form = ReviewForm( initial={'needs_change': doc.needs_change, 'needs_change_comment': doc.needs_change_comment}) # Don't ask significance if this doc is a translation or if it has no # former approved versions: should_ask_significance = not doc.parent and doc.current_revision based_on_revs = doc.revisions.all() last_approved_date = getattr(doc.current_revision, 'created', datetime.fromordinal(1)) based_on_revs = based_on_revs.filter(created__gt=last_approved_date) revision_contributors = list(set( based_on_revs.values_list('creator__username', flat=True))) # Get Unreviewed Revisions unreviewed_revisions = Revision.objects.filter(document=doc, is_approved=False, reviewed=None).order_by('-id') # Get latest revision which is still not approved. Use **latest_revision_id** to get the id. try: latest_unapproved_revision = unreviewed_revisions[0] latest_unapproved_revision_id = latest_unapproved_revision.id except IndexError: latest_unapproved_revision_id = None # Get Current Revision id only if there is any approved revision. # Return None if there is no current revision if doc.current_revision is not None: current_revision_id = doc.current_revision.id unreviewed_revisions = unreviewed_revisions.exclude(id__lt=current_revision_id) else: current_revision_id = None # Get latest 5 unapproved revisions and exclude the revision which is being reviewed unreviewed_revisions = unreviewed_revisions.exclude(id=rev.id)[:5] # Don't include the reviewer in the recent contributors list. if request.user.username in revision_contributors: revision_contributors.remove(request.user.username) if request.method == 'POST': form = ReviewForm(request.POST) if form.is_valid() and not rev.reviewed: # Don't allow revisions to be reviewed twice rev.is_approved = 'approve' in request.POST rev.reviewer = request.user rev.reviewed = datetime.now() if should_ask_significance and form.cleaned_data['significance']: rev.significance = form.cleaned_data['significance'] elif not should_ask_significance and not doc.parent: # This is a new document without approved revisions. # Significance is MAJOR. rev.significance = MAJOR_SIGNIFICANCE # If document is localizable and revision was approved and # user has permission, set the is_ready_for_localization value. if (doc.allows(request.user, 'mark_ready_for_l10n') and rev.is_approved and rev.can_be_readied_for_localization()): rev.is_ready_for_localization = form.cleaned_data[ 'is_ready_for_localization'] # If the revision is ready for l10n, store the date # and the user. if rev.is_ready_for_localization: rev.readied_for_localization = rev.reviewed rev.readied_for_localization_by = rev.reviewer rev.save() # Update the needs change bit (if approved, default language and # user has permission). if (doc.locale == settings.WIKI_DEFAULT_LANGUAGE and doc.allows(request.user, 'edit_needs_change') and rev.is_approved): doc.needs_change = form.cleaned_data['needs_change'] # Remove comment if no changes are needed. if doc.needs_change: doc.needs_change_comment = \ form.cleaned_data['needs_change_comment'] else: doc.needs_change_comment = '' doc.save() # Send notifications of approvedness and readiness: if rev.is_ready_for_localization or rev.is_approved: events = [ApproveRevisionInLocaleEvent(rev)] if rev.is_ready_for_localization: events.append(ReadyRevisionEvent(rev)) ApprovedOrReadyUnion(*events).fire(exclude=[rev.creator, request.user]) # Send an email (not really a "notification" in the sense that # there's a Watch table entry) to revision creator. msg = form.cleaned_data['comment'] send_reviewed_notification.delay(rev, doc, msg) send_contributor_notification(based_on_revs, rev, doc, msg) statsd.incr('wiki.review') render_document_cascade.delay(doc) return HttpResponseRedirect(reverse('wiki.document_revisions', args=[document_slug])) if doc.parent: # A translation # For diffing the based_on revision against, to help the user see if he # translated all the recent changes: parent_revision = (rev.based_on or doc.parent.localizable_or_latest_revision()) template = 'wiki/review_translation.html' else: parent_revision = None template = 'wiki/review_revision.html' data = {'revision': rev, 'document': doc, 'form': form, 'parent_revision': parent_revision, 'revision_contributors': list(revision_contributors), 'should_ask_significance': should_ask_significance, 'latest_unapproved_revision_id': latest_unapproved_revision_id, 'current_revision_id': current_revision_id, 'unreviewed_revisions': unreviewed_revisions} return render(request, template, data) @require_GET def compare_revisions(request, document_slug): """Compare two wiki document revisions. The ids are passed as query string parameters (to and from). """ locale = request.GET.get('locale', request.LANGUAGE_CODE) doc = get_object_or_404( Document, locale=locale, slug=document_slug) if 'from' not in request.GET or 'to' not in request.GET: raise Http404 from_id = smart_int(request.GET.get('from')) to_id = smart_int(request.GET.get('to')) revision_from = get_object_or_404(Revision, document=doc, id=from_id) revision_to = get_object_or_404(Revision, document=doc, id=to_id) if request.is_ajax(): template = 'wiki/includes/revision_diff.html' else: template = 'wiki/compare_revisions.html' return render(request, template, { 'document': doc, 'revision_from': revision_from, 'revision_to': revision_to}) @login_required def select_locale(request, document_slug): """Select a locale to translate the document to.""" doc = get_object_or_404( Document, locale=settings.WIKI_DEFAULT_LANGUAGE, slug=document_slug) translated_locales_code = [] # Translated Locales list with Locale Code only translated_locales = [] untranslated_locales = [] translated_locales_code.append(doc.locale) translated_locales_code.extend(doc.translations.all().values_list('locale', flat=True)) # Finding out the Translated and Untranslated locales with Locale Name and Locale Code for locale in settings.LANGUAGE_CHOICES: if locale[0] in translated_locales_code: translated_locales.append(locale) else: untranslated_locales.append(locale) return render(request, 'wiki/select_locale.html', { 'document': doc, 'translated_locales': translated_locales, 'untranslated_locales': untranslated_locales}) @require_http_methods(['GET', 'POST']) @login_required def translate(request, document_slug, revision_id=None): """Create a new translation of a wiki document. * document_slug is for the default locale * translation is to the request.LANGUAGE_CODE """ # TODO: Refactor this view into two views? (new, edit) # That might help reduce the headache-inducing branchiness. parent_doc = get_object_or_404( Document, locale=settings.WIKI_DEFAULT_LANGUAGE, slug=document_slug) user = request.user if settings.WIKI_DEFAULT_LANGUAGE == request.LANGUAGE_CODE: # Don't translate to the default language. return HttpResponseRedirect(reverse( 'wiki.edit_document', locale=settings.WIKI_DEFAULT_LANGUAGE, args=[parent_doc.slug])) if not parent_doc.is_localizable: message = _lazy(u'You cannot translate this document.') return render(request, 'handlers/400.html', { 'message': message}, status=400) based_on_rev = parent_doc.localizable_or_latest_revision( include_rejected=True) disclose_description = bool(request.GET.get('opendescription')) try: doc = parent_doc.translations.get(locale=request.LANGUAGE_CODE) except Document.DoesNotExist: doc = None disclose_description = True user_has_doc_perm = not doc or doc.allows(user, 'edit') user_has_rev_perm = not doc or doc.allows(user, 'create_revision') if not user_has_doc_perm and not user_has_rev_perm: # User has no perms, bye. raise PermissionDenied # Check if the user has draft resision saved for the parent document with requeted locale draft = DraftRevision.objects.filter(creator=user, document=parent_doc, locale=request.LANGUAGE_CODE) doc_form = rev_form = None base_rev = None restore_draft = None # Check if the user has requested to restore or discard draft draft_request = request.GET.get('restore') or request.GET.get('discard') draft_revision = None # If Draft is available and the user has requested with draft parameters if draft_request and draft.exists(): restore_draft = request.GET.get('restore') discard_draft = request.GET.get('discard') # Discard draft if user requsted. And not requested to restore draft at the same time. # Thuough from the UI its not possible, but maybe a hacky request with both parameters if discard_draft and not restore_draft: draft[0].delete() elif draft.exists(): draft_revision = draft[0] if user_has_doc_perm: # Restore draft if draft is available and user requested to restore if restore_draft: doc_initial = _draft_initial_doc(draft_revision=draft[0]) else: doc_initial = _document_form_initial(doc) if doc else None doc_form = DocumentForm(initial=doc_initial) if user_has_rev_perm: if restore_draft: initial = _draft_initial_rev(draft_revision=draft[0]) based_on_rev = draft[0].based_on else: initial = {'based_on': based_on_rev.id, 'comment': ''} if revision_id: base_rev = Revision.objects.get(pk=revision_id) initial.update(content=base_rev.content, summary=base_rev.summary, keywords=base_rev.keywords) elif not doc: initial.update(content=based_on_rev.content, summary=based_on_rev.summary, keywords=based_on_rev.keywords) # Get a revision of the translation to plonk into the page as a # starting point. Since translations are never "ready for # localization", this will first try to find an approved revision, then # an unrejected one, then give up. instance = doc and doc.localizable_or_latest_revision() rev_form = RevisionForm(instance=instance, initial=initial) base_rev = base_rev or instance if request.method == 'POST': which_form = request.POST.get('form', 'both') doc_form_invalid = False if doc is not None: _document_lock_clear(doc.id, user.username) if user_has_doc_perm and which_form in ['doc', 'both']: disclose_description = True post_data = request.POST.copy() post_data.update({'locale': request.LANGUAGE_CODE}) doc_form = DocumentForm(post_data, instance=doc) doc_form.instance.locale = request.LANGUAGE_CODE doc_form.instance.parent = parent_doc if which_form == 'both': rev_form = RevisionForm(request.POST) # If we are submitting the whole form, we need to check that # the Revision is valid before saving the Document. if doc_form.is_valid() and (which_form == 'doc' or rev_form.is_valid()): doc = doc_form.save(parent_doc) # Possibly schedule a rebuild. _maybe_schedule_rebuild(doc_form) if which_form == 'doc': url = urlparams(reverse('wiki.edit_document', args=[doc.slug]), opendescription=1) return HttpResponseRedirect(url) doc_slug = doc_form.cleaned_data['slug'] else: doc_form_invalid = True else: doc_slug = doc.slug if doc and user_has_rev_perm and which_form in ['rev', 'both']: rev_form = RevisionForm(request.POST) rev_form.instance.document = doc # for rev_form.clean() if rev_form.is_valid() and not doc_form_invalid: if 'no-update' in request.POST: # Keep the old based_on. based_on_id = base_rev.based_on_id else: # Keep what was in the form. based_on_id = None if draft_revision: draft_revision.delete() _save_rev_and_notify(rev_form, request.user, doc, based_on_id, base_rev=base_rev) if 'notify-future-changes' in request.POST: EditDocumentEvent.notify(request.user, doc) url = reverse('wiki.document_revisions', args=[doc_slug]) return HttpResponseRedirect(url) show_revision_warning = _show_revision_warning(doc, base_rev) # A list of the revisions that have been approved since the last # translation. recent_approved_revs = parent_doc.revisions.filter( is_approved=True, id__lte=based_on_rev.id) if doc and doc.current_revision and doc.current_revision.based_on_id: recent_approved_revs = recent_approved_revs.filter( id__gt=doc.current_revision.based_on_id) if doc: locked, locked_by = _document_lock(doc.id, user.username) # Most updated rev according to based on revision more_updated_rev = doc.revisions.filter( based_on__id__gt=based_on_rev.id).order_by('based_on__id').last() else: locked, locked_by = False, None more_updated_rev = None product_slugs = [p.slug for p in (doc or parent_doc).products.all()] fxos_l10n_warning = ('firefox-os' in product_slugs and request.LANGUAGE_CODE not in settings.FXOS_LANGUAGES) return render(request, 'wiki/translate.html', { 'parent': parent_doc, 'document': doc, 'document_form': doc_form, 'revision_form': rev_form, 'locale': request.LANGUAGE_CODE, 'based_on': based_on_rev, 'disclose_description': disclose_description, 'show_revision_warning': show_revision_warning, 'recent_approved_revs': recent_approved_revs, 'locked': locked, 'locked_by': locked_by, 'fxos_l10n_warning': fxos_l10n_warning, 'draft_revision': draft_revision, 'more_updated_rev': more_updated_rev}) @require_POST @login_required def watch_document(request, document_slug): """Start watching a document for edits.""" document = get_object_or_404( Document, locale=request.LANGUAGE_CODE, slug=document_slug) EditDocumentEvent.notify(request.user, document) statsd.incr('wiki.watches.document') return HttpResponseRedirect(document.get_absolute_url()) @require_POST @login_required def unwatch_document(request, document_slug): """Stop watching a document for edits.""" document = get_object_or_404( Document, locale=request.LANGUAGE_CODE, slug=document_slug) EditDocumentEvent.stop_notifying(request.user, document) return HttpResponseRedirect(document.get_absolute_url()) @require_POST @login_required def watch_locale(request, product=None): """Start watching a locale for revisions ready for review.""" kwargs = {'locale': request.LANGUAGE_CODE} if product is not None: kwargs['product'] = product ReviewableRevisionInLocaleEvent.notify(request.user, **kwargs) statsd.incr('wiki.watches.locale') return HttpResponse() @require_POST @login_required def unwatch_locale(request, product=None): """Stop watching a locale for revisions ready for review.""" kwargs = {'locale': request.LANGUAGE_CODE} if product is not None: kwargs['product'] = product ReviewableRevisionInLocaleEvent.stop_notifying(request.user, **kwargs) return HttpResponse() @require_POST @login_required def watch_approved(request, product=None): """Start watching approved revisions in a locale for a given product.""" if request.LANGUAGE_CODE not in settings.SUMO_LANGUAGES: raise Http404 kwargs = {'locale': request.LANGUAGE_CODE} if product is not None: kwargs['product'] = product ApproveRevisionInLocaleEvent.notify(request.user, **kwargs) statsd.incr('wiki.watches.approved') return HttpResponse() @require_POST @login_required def unwatch_approved(request, product=None): """Stop watching approved revisions for a given product.""" if request.LANGUAGE_CODE not in settings.SUMO_LANGUAGES: raise Http404 kwargs = {'locale': request.LANGUAGE_CODE} if product is not None: kwargs['product'] = product ApproveRevisionInLocaleEvent.stop_notifying(request.user, **kwargs) return HttpResponse() @require_POST @login_required def watch_ready(request, product=None): """Start watching ready-for-l10n revisions for given product.""" if request.LANGUAGE_CODE != settings.WIKI_DEFAULT_LANGUAGE: raise Http404 kwargs = {} if product is not None: kwargs['product'] = product ReadyRevisionEvent.notify(request.user, **kwargs) statsd.incr('wiki.watches.ready') return HttpResponse() @require_POST @login_required def unwatch_ready(request, product=None): """Stop watching ready-for-l10n revisions for a given product.""" if request.LANGUAGE_CODE != settings.WIKI_DEFAULT_LANGUAGE: raise Http404 kwargs = {} if product is not None: kwargs['product'] = product ReadyRevisionEvent.stop_notifying(request.user, **kwargs) return HttpResponse() @require_GET def json_view(request): """Return some basic document info in a JSON blob.""" kwargs = { 'locale': request.LANGUAGE_CODE, 'current_revision__isnull': False } if 'title' in request.GET: kwargs['title'] = request.GET['title'] elif 'slug' in request.GET: kwargs['slug'] = request.GET['slug'] else: return HttpResponseBadRequest() document = get_object_or_404(Document, **kwargs) data = json.dumps({ 'id': document.id, 'locale': document.locale, 'slug': document.slug, 'title': document.title, 'summary': document.current_revision.summary, 'url': document.get_absolute_url(), }) return HttpResponse(data, content_type='application/json') @require_POST @csrf_exempt @ratelimit('document-vote', '10/d') def helpful_vote(request, document_slug): """Vote for Helpful/Not Helpful document""" if 'revision_id' not in request.POST: return HttpResponseBadRequest() revision = get_object_or_404( Revision, id=smart_int(request.POST['revision_id'])) survey = None if revision.document.category == TEMPLATES_CATEGORY: return HttpResponseBadRequest() if not revision.has_voted(request): ua = request.META.get('HTTP_USER_AGENT', '')[:1000] # 1000 max_length vote = HelpfulVote(revision=revision, user_agent=ua) if 'helpful' in request.POST: vote.helpful = True message = _('Glad to hear it &mdash; thanks for the feedback!') else: message = _('Sorry to hear that.') # If user is over the limit, don't save but pretend everything is ok. if not request.limited: if request.user.is_authenticated(): vote.creator = request.user else: vote.anonymous_id = request.anonymous.anonymous_id vote.save() statsd.incr('wiki.vote') # Send a survey if flag is enabled and vote wasn't helpful. if 'helpful' not in request.POST: survey = render_to_string( 'wiki/includes/unhelpful_survey.html', {'vote_id': vote.id}) # Save vote metadata: referrer and search query (if available) for name in ['referrer', 'query', 'source']: val = request.POST.get(name) if val: vote.add_metadata(name, val) else: message = _('You already voted on this Article.') if request.is_ajax(): r = {'message': message} if survey: r.update(survey=survey) return HttpResponse(json.dumps(r)) return HttpResponseRedirect(revision.document.get_absolute_url()) @require_POST @csrf_exempt def unhelpful_survey(request): """Ajax only view: Unhelpful vote survey processing.""" vote = get_object_or_404( HelpfulVote, id=smart_int(request.POST.get('vote_id'))) # Only save the survey if it was for a not helpful vote and a survey # doesn't exist for it already. if not vote.helpful and not vote.metadata.filter(key='survey').exists(): # The survey is the posted data, minus the vote_id and button value. survey = request.POST.copy() survey.pop('vote_id') survey.pop('button') # Save the survey in JSON format, taking care not to exceed 1000 chars. vote.add_metadata( 'survey', truncated_json_dumps(survey, 1000, 'comment')) return HttpResponse( json.dumps({'message': _('Thanks for making us better!')})) @require_GET def get_helpful_votes_async(request, document_slug): document = get_object_or_404( Document, locale=request.LANGUAGE_CODE, slug=document_slug) datums = [] flag_data = [] rev_data = [] revisions = set() created_list = [] dates_with_data = set() cursor = connection.cursor() cursor.execute('SELECT wiki_helpfulvote.revision_id, ' ' SUM(wiki_helpfulvote.helpful), ' ' SUM(NOT(wiki_helpfulvote.helpful)), ' ' wiki_helpfulvote.created ' 'FROM wiki_helpfulvote ' 'INNER JOIN wiki_revision ON ' ' wiki_helpfulvote.revision_id=wiki_revision.id ' 'WHERE wiki_revision.document_id=%s ' 'GROUP BY DATE(wiki_helpfulvote.created)', [document.id]) results = cursor.fetchall() for res in results: revisions.add(int(res[0])) created_list.append(res[3]) date = int(time.mktime(res[3].timetuple()) / 86400) * 86400 datums.append({ 'yes': int(res[1]), 'no': int(res[2]), 'date': date, }) dates_with_data.add(date) if not created_list: send = {'datums': [], 'annotations': []} return HttpResponse(json.dumps(send), content_type='application/json') min_created = min(created_list) max_created = max(created_list) # Zero fill data timestamp = int(time.mktime(res[3].timetuple()) / 86400) * 86400 end = time.mktime(datetime.now().timetuple()) while timestamp <= end: if timestamp not in dates_with_data: datums.append({ 'yes': 0, 'no': 0, 'date': timestamp, }) dates_with_data.add(timestamp) timestamp += 24 * 60 * 60 for flag in ImportantDate.objects.filter(date__gte=min_created, date__lte=max_created): flag_data.append({ 'x': int(time.mktime(flag.date.timetuple())), 'text': _(flag.text) }) for rev in Revision.objects.filter(pk__in=revisions, created__gte=min_created, created__lte=max_created): rdate = rev.reviewed or rev.created rev_data.append({ 'x': int(time.mktime(rdate.timetuple())), 'text': unicode(_('Revision %s')) % rev.created }) # Rickshaw wants data like # [{'name': 'series1', 'data': [{'x': 1362774285, 'y': 100}, ...]},] send = {'datums': datums, 'annotations': []} if flag_data: send['annotations'].append({ 'name': _('Firefox Releases'), 'slug': 'releases', 'data': flag_data, }) if rev_data: send['annotations'].append({ 'name': _('Article Revisions'), 'slug': 'revisions', 'data': rev_data, }) return HttpResponse(json.dumps(send), content_type='application/json') @login_required def delete_revision(request, document_slug, revision_id): """Delete a revision.""" revision = get_object_or_404(Revision, pk=revision_id, document__slug=document_slug) document = revision.document if not document.allows(request.user, 'delete_revision'): raise PermissionDenied only_revision = document.revisions.count() == 1 helpful_votes = HelpfulVote.objects.filter(revision=revision.id) has_votes = helpful_votes.exists() if request.method == 'GET': # Render the confirmation page return render(request, 'wiki/confirm_revision_delete.html', { 'revision': revision, 'document': document, 'only_revision': only_revision, 'has_votes': has_votes}) # Don't delete the only revision of a document if only_revision: return HttpResponseBadRequest() log.warning('User %s is deleting revision with id=%s' % (request.user, revision.id)) revision.delete() return HttpResponseRedirect(reverse('wiki.document_revisions', args=[document.slug])) @login_required @require_POST def mark_ready_for_l10n_revision(request, document_slug, revision_id): """Mark a revision as ready for l10n.""" revision = get_object_or_404(Revision, pk=revision_id, document__slug=document_slug) if not revision.document.allows(request.user, 'mark_ready_for_l10n'): raise PermissionDenied if revision.can_be_readied_for_localization(): # We don't use update(), because that wouldn't update # Document.latest_localizable_revision. revision.is_ready_for_localization = True revision.readied_for_localization = datetime.now() revision.readied_for_localization_by = request.user revision.save() ReadyRevisionEvent(revision).fire(exclude=request.user) return HttpResponse(json.dumps({'message': revision_id})) return HttpResponseBadRequest() @login_required def delete_document(request, document_slug): """Delete a revision.""" document = get_object_or_404(Document, locale=request.LANGUAGE_CODE, slug=document_slug) # Check permission if not document.allows(request.user, 'delete'): raise PermissionDenied if request.method == 'GET': # Render the confirmation page return render(request, 'wiki/confirm_document_delete.html', { 'document': document}) # Handle confirm delete form POST log.warning('User %s is deleting document: %s (id=%s)' % (request.user, document.title, document.id)) document.delete() return render(request, 'wiki/confirm_document_delete.html', { 'document': document, 'delete_confirmed': True}) @login_required @require_POST def add_contributor(request, document_slug): """Add a contributor to a document.""" document = get_object_or_404(Document, locale=request.LANGUAGE_CODE, slug=document_slug) if not document.allows(request.user, 'edit'): raise PermissionDenied form = AddContributorForm(request.POST) if form.is_valid(): for user in form.cleaned_data['users']: document.contributors.add(user) msg = _('{users} added to the contributors successfully!').format( users=request.POST.get('users')) messages.add_message(request, messages.SUCCESS, msg) return HttpResponseRedirect(reverse('wiki.document_revisions', args=[document_slug])) msg = _('There were errors adding new contributors, see below.') messages.add_message(request, messages.ERROR, msg) return document_revisions(request, document_slug, contributor_form=form) @login_required @require_http_methods(['GET', 'POST']) def remove_contributor(request, document_slug, user_id): """Remove a contributor from a document.""" document = get_object_or_404(Document, locale=request.LANGUAGE_CODE, slug=document_slug) if not document.allows(request.user, 'edit'): raise PermissionDenied user = get_object_or_404(User, id=user_id) if request.method == 'POST': document.contributors.remove(user) msg = (_('{user} removed from the contributors successfully!') .format(user=user.username)) messages.add_message(request, messages.SUCCESS, msg) return HttpResponseRedirect(reverse('wiki.document_revisions', args=[document_slug])) return render(request, 'wiki/confirm_remove_contributor.html', { 'document': document, 'contributor': user}) def show_translations(request, document_slug): document = get_object_or_404( Document, locale=settings.WIKI_DEFAULT_LANGUAGE, slug=document_slug) translated_locales = [] untranslated_locales = [] # Makes Sure "English (en-US)" is always on top translated_locales.append((document.locale, LOCALES[document.locale].native)) # Gets all the translated locale codes translated_locales_code = document.translations.all().values_list( 'locale', flat=True) for locale in settings.LANGUAGE_CHOICES: if locale[0] in translated_locales_code: translated_locales.append(locale) else: untranslated_locales.append(locale) return render(request, 'wiki/show_translations.html', { 'document': document, 'translated_locales': translated_locales, 'untranslated_locales': untranslated_locales}) def _document_form_initial(document): """Return a dict with the document data pertinent for the form.""" return {'title': document.title, 'slug': document.slug, 'category': document.category, 'is_localizable': document.is_localizable, 'is_archived': document.is_archived, 'topics': Topic.objects.filter( document=document).values_list('id', flat=True), 'products': Product.objects.filter( document=document).values_list('id', flat=True), 'related_documents': Document.objects.filter( related_documents=document).values_list('id', flat=True), 'allow_discussion': document.allow_discussion, 'needs_change': document.needs_change, 'needs_change_comment': document.needs_change_comment} def _draft_initial_doc(draft_revision): data = {'title': draft_revision.title, 'slug': draft_revision.slug} return data def _draft_initial_rev(draft_revision): data = {'content': draft_revision.content, 'summary': draft_revision.summary, 'keywords': draft_revision.keywords, 'based_on': draft_revision.based_on.id} return data def _save_rev_and_notify(rev_form, creator, document, based_on_id=None, base_rev=None): """Save the given RevisionForm and send notifications.""" new_rev = rev_form.save(creator, document, based_on_id, base_rev) statsd.incr('wiki.revision') # Enqueue notifications ReviewableRevisionInLocaleEvent(new_rev).fire(exclude=new_rev.creator) EditDocumentEvent(new_rev).fire(exclude=new_rev.creator) def _maybe_schedule_rebuild(form): """Try to schedule a KB rebuild if a title or slug has changed.""" if 'title' in form.changed_data or 'slug' in form.changed_data: schedule_rebuild_kb() def _get_next_url_fallback_localization(request): return get_next_url(request) or reverse('dashboards.localization') def _show_revision_warning(document, revision): if revision: return document.revisions.filter(id__gt=revision.id, reviewed=None).exists() return False def recent_revisions(request): # Make writable request.GET = request.GET.copy() fragment = request.GET.pop('fragment', None) form = RevisionFilterForm(request.GET) revs = Revision.objects.order_by('-created') # We are going to ignore validation errors for the most part, but # this is needed to call the functions that generate `cleaned_data` # This helps in particular when bad user names are typed in. form.is_valid() # If something has gone very wrong, `cleaned_data` won't be there. if hasattr(form, 'cleaned_data'): if form.cleaned_data.get('locale'): revs = revs.filter(document__locale=form.cleaned_data['locale']) if form.cleaned_data.get('users'): revs = revs.filter(creator__in=form.cleaned_data['users']) if form.cleaned_data.get('start'): revs = revs.filter(created__gte=form.cleaned_data['start']) if form.cleaned_data.get('end'): revs = revs.filter(created__lte=form.cleaned_data['end']) revs = paginate(request, revs) c = { 'revisions': revs, 'form': form, } if fragment: template = 'wiki/includes/recent_revisions_fragment.html' else: template = 'wiki/recent_revisions.html' return render(request, template, c) @require_GET def what_links_here(request, document_slug): """List all documents that link to a document.""" locale = request.GET.get('locale', request.LANGUAGE_CODE) doc = get_object_or_404(Document, locale=locale, slug=document_slug) links = {} for l in doc.links_to(): if doc.locale == l.linked_from.locale: if l.kind not in links: links[l.kind] = [] links[l.kind].append(l.linked_from) c = { 'document': doc, 'relations': links } return render(request, 'wiki/what_links_here.html', c) def get_fallback_locale(doc, request): """Get best fallback local based on locale mapping""" # Get locales that the current article is translated into. translated_locales = ( doc.translations .values_list('locale', flat=True) .exclude(current_revision=None)) # Build a list of the request locale and all the ACCEPT_LANGUAGE locales. accept_header = request.META.get('HTTP_ACCEPT_LANGUAGE') or '' header_locales = parse_accept_lang_header(accept_header) all_accepted_locales = [] all_accepted_locales.append(request.LANGUAGE_CODE) all_accepted_locales.extend(header_locales) # For each locale specified in the user's ACCEPT_LANGUAGE header # check for, in order: # * no fallback for "en-US" in accept language header # * translations in that locale # * global overrides for the locale in settings.NON_SUPPORTED_LOCALES # * wiki fallbacks for that locale for locale in all_accepted_locales: if locale == settings.WIKI_DEFAULT_LANGUAGE: return None elif locale in translated_locales: return locale elif settings.NON_SUPPORTED_LOCALES.get(locale) in translated_locales: return settings.NON_SUPPORTED_LOCALES[locale] for fallback in FALLBACK_LOCALES.get(locale, []): if fallback in translated_locales: return fallback # If all fails, return None as fallback Locale return None # Import from django.utils.translation.trans_real and changed as following # * Removed lower() from piece to get the locale name as needed # * As we need only the locale name, added code to get only locale name def parse_accept_lang_header(lang_string): """ Parses the lang_string, which is the body of an HTTP Accept-Language header, and returns a list of lang, ordered by 'q' values. Any format errors in lang_string results in an empty list being returned. """ accept_language_re = re.compile(r''' ([A-Za-z]{1,8}(?:-[A-Za-z0-9]{1,8})*|\*) # "en", "en-au", "x-y-z", "es-419", "*" (?:\s*;\s*q=(0(?:\.\d{,3})?|1(?:.0{,3})?))? # Optional "q=1.00", "q=0.8" (?:\s*,\s*|$) # Multiple accepts per header. ''', re.VERBOSE) result = [] pieces = accept_language_re.split(lang_string) # Changed here. Removed lower() if pieces[-1]: return [] for i in range(0, len(pieces) - 1, 3): first, lang, priority = pieces[i:i + 3] if first: return [] if priority: try: priority = float(priority) except ValueError: return [] if not priority: # if priority is 0.0 at this point make it 1.0 priority = 1.0 result.append((lang, priority)) result.sort(key=lambda k: k[1], reverse=True) # Changed here to get the locale name only result = [k for k, v in result] return result
bsd-3-clause
[ 646, 2022, 199, 646, 2050, 199, 646, 900, 199, 646, 295, 199, 504, 2197, 492, 2197, 199, 504, 9143, 492, 14018, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 492, 3788, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 504, 1639, 14, 1018, 14, 3924, 492, 23724, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 3351, 14, 1974, 492, 4520, 1296, 199, 504, 1639, 14, 1014, 492, 334, 16287, 12, 14935, 12, 586, 4760, 5188, 12, 6183, 12380, 9, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 12, 3795, 199, 504, 1639, 14, 1160, 14, 3422, 492, 3795, 63, 475, 63, 875, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 6395, 12, 10366, 465, 485, 199, 504, 1639, 14, 4196, 14, 11582, 14, 10088, 492, 19213, 63, 25254, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1014, 492, 334, 4365, 63, 2970, 12, 4409, 63, 4030, 12, 5101, 4409, 63, 1014, 63, 2474, 9, 199, 199, 504, 1303, 3195, 14, 11582, 492, 21305, 63, 1160, 199, 504, 1639, 63, 3200, 68, 14, 14555, 492, 5020, 68, 199, 199, 504, 1022, 1405, 11474, 14, 2732, 14, 11582, 492, 4676, 63, 2427, 199, 504, 1022, 1405, 11474, 14, 773, 14, 1838, 79, 63, 24763, 492, 20639, 654, 199, 504, 1022, 1405, 11474, 14, 13336, 14, 992, 492, 12705, 12, 32166, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 11582, 492, 6634, 3097, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 1160, 2969, 14, 12264, 63, 7546, 492, 1166, 1162, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 15369, 63, 1208, 492, 16967, 63, 1258, 12, 25496, 547, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 16522, 492, 3837, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 1208, 492, 9881, 23043, 12, 11179, 63, 442, 12, 664, 63, 2184, 63, 633, 12, 17661, 63, 1001, 63, 4180, 12, 664, 63, 5750, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 888, 492, 334, 272, 445, 12649, 28743, 12, 4828, 27109, 63, 9396, 14456, 7140, 12, 377, 9358, 16601, 63, 22690, 12, 29970, 51, 63, 4227, 63, 12898, 12, 272, 13513, 44, 1282, 51, 7187, 63, 7884, 51, 12, 481, 1761, 7111, 63, 7486, 654, 9, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 4368, 492, 334, 272, 16407, 5564, 2390, 12, 26705, 461, 12714, 607, 20342, 2390, 12, 272, 19615, 432, 12714, 607, 20342, 2390, 12, 26330, 2844, 17960, 15540, 12, 272, 5574, 89, 12714, 2390, 9, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 3351, 492, 334, 272, 2654, 714, 1925, 4139, 2821, 12, 7543, 2821, 12, 27095, 2821, 12, 27095, 4131, 2821, 12, 272, 26705, 2821, 12, 28090, 12714, 2821, 9, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 992, 492, 334, 272, 7543, 12, 27095, 12, 28090, 12714, 12, 15456, 1893, 54, 1583, 12, 3161, 867, 2506, 12, 1382, 63, 1360, 63, 1637, 63, 498, 12, 272, 16881, 2001, 23656, 12, 428, 32047, 2001, 23656, 9, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 2087, 492, 17195, 63, 475, 63, 1360, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 5054, 492, 334, 272, 3222, 63, 8578, 379, 63, 6761, 12, 8732, 63, 19278, 63, 7862, 12, 272, 3222, 63, 16833, 63, 6761, 12, 3795, 63, 3554, 63, 15377, 9, 421, 199, 793, 275, 2050, 14, 5572, 360, 75, 14, 6797, 358, 421, 199, 318, 1382, 63, 1606, 63, 1637, 8, 1345, 304, 272, 408, 14946, 626, 18014, 314, 2213, 2034, 4163, 1041, 272, 768, 13582, 8, 1345, 9, 272, 347, 485, 1301, 63, 1606, 63, 1637, 63, 1345, 8, 1069, 12, 2213, 63, 5464, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 2136, 3372, 13627, 367, 1790, 379, 4390, 503, 340, 4660, 29, 889, 267, 327, 365, 315, 314, 1827, 1059, 14, 267, 340, 334, 1069, 14, 751, 14, 374, 63, 12177, 342, 503, 355, 1056, 14, 2970, 14, 362, 360, 4876, 358, 508, 283, 889, 735, 288, 5020, 68, 14, 19362, 360, 6797, 14, 3554, 63, 1345, 14, 1637, 14, 2759, 358, 288, 372, 2455, 8, 1069, 12, 2213, 63, 5464, 12, 627, 589, 12, 1011, 958, 9, 398, 2581, 63, 498, 275, 1382, 63, 1360, 63, 1637, 63, 498, 8, 288, 21305, 29, 1069, 14, 2679, 34, 8453, 12, 288, 5867, 29, 1069, 14, 13947, 63, 6012, 12, 288, 8889, 29, 3554, 63, 5464, 12, 288, 13460, 29, 1069, 14, 2970, 14, 362, 360, 21508, 297, 283, 16, 1333, 398, 3517, 12, 2323, 275, 2581, 14, 362, 8, 1637, 63, 498, 12, 334, 403, 12, 488, 430, 267, 340, 3517, 365, 440, 488, 26, 288, 5020, 68, 14, 19362, 360, 6797, 14, 3554, 63, 1345, 14, 1637, 14, 12948, 358, 288, 522, 275, 6183, 8, 1360, 9, 288, 367, 790, 12, 1139, 315, 2323, 14, 1744, 837, 355, 522, 59, 498, 61, 275, 1139, 288, 372, 522, 398, 5020, 68, 14, 19362, 360, 6797, 14, 3554, 63, 1345, 14, 1637, 14, 18420, 358, 267, 1177, 275, 2455, 8, 1069, 12, 2213, 63, 5464, 12, 627, 589, 12, 1011, 958, 9, 398, 327, 2136, 1454, 2581, 340, 314, 1177, 2529, 3101, 1926, 14, 267, 340, 1177, 14, 1205, 63, 600, 508, 1926, 26, 288, 2581, 14, 409, 8, 1637, 63, 498, 12, 334, 1310, 14, 1317, 12, 1211, 8, 1310, 423, 2139, 14, 1459, 16890, 398, 372, 1177, 272, 372, 485, 1301, 63, 1606, 63, 1637, 63, 1345, 421, 199, 32, 4365, 63, 2970, 199, 32, 1301, 63, 1606, 63, 1637, 199, 32, 11375, 63, 1160, 360, 6797, 5321, 11375, 15, 12216, 199, 318, 2213, 8, 1069, 12, 2213, 63, 5464, 12, 1978, 29, 403, 12, 2213, 29, 403, 304, 272, 408, 2768, 282, 17195, 2213, 1041, 339, 9567, 63, 5764, 275, 488, 272, 2615, 63, 5508, 63, 354, 275, 488, 272, 327, 982, 282, 8889, 5712, 1133, 2808, 315, 314, 5839, 5867, 12, 11264, 1771, 370, 655, 13, 1668, 26, 272, 862, 26, 267, 1382, 275, 7543, 14, 1462, 14, 362, 8, 5508, 29, 1069, 14 ]
[ 2022, 199, 646, 2050, 199, 646, 900, 199, 646, 295, 199, 504, 2197, 492, 2197, 199, 504, 9143, 492, 14018, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 492, 3788, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 504, 1639, 14, 1018, 14, 3924, 492, 23724, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 3351, 14, 1974, 492, 4520, 1296, 199, 504, 1639, 14, 1014, 492, 334, 16287, 12, 14935, 12, 586, 4760, 5188, 12, 6183, 12380, 9, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 12, 3795, 199, 504, 1639, 14, 1160, 14, 3422, 492, 3795, 63, 475, 63, 875, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 6395, 12, 10366, 465, 485, 199, 504, 1639, 14, 4196, 14, 11582, 14, 10088, 492, 19213, 63, 25254, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1014, 492, 334, 4365, 63, 2970, 12, 4409, 63, 4030, 12, 5101, 4409, 63, 1014, 63, 2474, 9, 199, 199, 504, 1303, 3195, 14, 11582, 492, 21305, 63, 1160, 199, 504, 1639, 63, 3200, 68, 14, 14555, 492, 5020, 68, 199, 199, 504, 1022, 1405, 11474, 14, 2732, 14, 11582, 492, 4676, 63, 2427, 199, 504, 1022, 1405, 11474, 14, 773, 14, 1838, 79, 63, 24763, 492, 20639, 654, 199, 504, 1022, 1405, 11474, 14, 13336, 14, 992, 492, 12705, 12, 32166, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 11582, 492, 6634, 3097, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 1160, 2969, 14, 12264, 63, 7546, 492, 1166, 1162, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 15369, 63, 1208, 492, 16967, 63, 1258, 12, 25496, 547, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 16522, 492, 3837, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 1208, 492, 9881, 23043, 12, 11179, 63, 442, 12, 664, 63, 2184, 63, 633, 12, 17661, 63, 1001, 63, 4180, 12, 664, 63, 5750, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 888, 492, 334, 272, 445, 12649, 28743, 12, 4828, 27109, 63, 9396, 14456, 7140, 12, 377, 9358, 16601, 63, 22690, 12, 29970, 51, 63, 4227, 63, 12898, 12, 272, 13513, 44, 1282, 51, 7187, 63, 7884, 51, 12, 481, 1761, 7111, 63, 7486, 654, 9, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 4368, 492, 334, 272, 16407, 5564, 2390, 12, 26705, 461, 12714, 607, 20342, 2390, 12, 272, 19615, 432, 12714, 607, 20342, 2390, 12, 26330, 2844, 17960, 15540, 12, 272, 5574, 89, 12714, 2390, 9, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 3351, 492, 334, 272, 2654, 714, 1925, 4139, 2821, 12, 7543, 2821, 12, 27095, 2821, 12, 27095, 4131, 2821, 12, 272, 26705, 2821, 12, 28090, 12714, 2821, 9, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 992, 492, 334, 272, 7543, 12, 27095, 12, 28090, 12714, 12, 15456, 1893, 54, 1583, 12, 3161, 867, 2506, 12, 1382, 63, 1360, 63, 1637, 63, 498, 12, 272, 16881, 2001, 23656, 12, 428, 32047, 2001, 23656, 9, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 2087, 492, 17195, 63, 475, 63, 1360, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 5054, 492, 334, 272, 3222, 63, 8578, 379, 63, 6761, 12, 8732, 63, 19278, 63, 7862, 12, 272, 3222, 63, 16833, 63, 6761, 12, 3795, 63, 3554, 63, 15377, 9, 421, 199, 793, 275, 2050, 14, 5572, 360, 75, 14, 6797, 358, 421, 199, 318, 1382, 63, 1606, 63, 1637, 8, 1345, 304, 272, 408, 14946, 626, 18014, 314, 2213, 2034, 4163, 1041, 272, 768, 13582, 8, 1345, 9, 272, 347, 485, 1301, 63, 1606, 63, 1637, 63, 1345, 8, 1069, 12, 2213, 63, 5464, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 2136, 3372, 13627, 367, 1790, 379, 4390, 503, 340, 4660, 29, 889, 267, 327, 365, 315, 314, 1827, 1059, 14, 267, 340, 334, 1069, 14, 751, 14, 374, 63, 12177, 342, 503, 355, 1056, 14, 2970, 14, 362, 360, 4876, 358, 508, 283, 889, 735, 288, 5020, 68, 14, 19362, 360, 6797, 14, 3554, 63, 1345, 14, 1637, 14, 2759, 358, 288, 372, 2455, 8, 1069, 12, 2213, 63, 5464, 12, 627, 589, 12, 1011, 958, 9, 398, 2581, 63, 498, 275, 1382, 63, 1360, 63, 1637, 63, 498, 8, 288, 21305, 29, 1069, 14, 2679, 34, 8453, 12, 288, 5867, 29, 1069, 14, 13947, 63, 6012, 12, 288, 8889, 29, 3554, 63, 5464, 12, 288, 13460, 29, 1069, 14, 2970, 14, 362, 360, 21508, 297, 283, 16, 1333, 398, 3517, 12, 2323, 275, 2581, 14, 362, 8, 1637, 63, 498, 12, 334, 403, 12, 488, 430, 267, 340, 3517, 365, 440, 488, 26, 288, 5020, 68, 14, 19362, 360, 6797, 14, 3554, 63, 1345, 14, 1637, 14, 12948, 358, 288, 522, 275, 6183, 8, 1360, 9, 288, 367, 790, 12, 1139, 315, 2323, 14, 1744, 837, 355, 522, 59, 498, 61, 275, 1139, 288, 372, 522, 398, 5020, 68, 14, 19362, 360, 6797, 14, 3554, 63, 1345, 14, 1637, 14, 18420, 358, 267, 1177, 275, 2455, 8, 1069, 12, 2213, 63, 5464, 12, 627, 589, 12, 1011, 958, 9, 398, 327, 2136, 1454, 2581, 340, 314, 1177, 2529, 3101, 1926, 14, 267, 340, 1177, 14, 1205, 63, 600, 508, 1926, 26, 288, 2581, 14, 409, 8, 1637, 63, 498, 12, 334, 1310, 14, 1317, 12, 1211, 8, 1310, 423, 2139, 14, 1459, 16890, 398, 372, 1177, 272, 372, 485, 1301, 63, 1606, 63, 1637, 63, 1345, 421, 199, 32, 4365, 63, 2970, 199, 32, 1301, 63, 1606, 63, 1637, 199, 32, 11375, 63, 1160, 360, 6797, 5321, 11375, 15, 12216, 199, 318, 2213, 8, 1069, 12, 2213, 63, 5464, 12, 1978, 29, 403, 12, 2213, 29, 403, 304, 272, 408, 2768, 282, 17195, 2213, 1041, 339, 9567, 63, 5764, 275, 488, 272, 2615, 63, 5508, 63, 354, 275, 488, 272, 327, 982, 282, 8889, 5712, 1133, 2808, 315, 314, 5839, 5867, 12, 11264, 1771, 370, 655, 13, 1668, 26, 272, 862, 26, 267, 1382, 275, 7543, 14, 1462, 14, 362, 8, 5508, 29, 1069, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
inmomentsoftware/pledgeservice
lib/mailchimp/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.py
2360
3778
"""The match_hostname() function from Python 3.3.3, essential when using SSL.""" # Note: This file is under the PSF license as the code comes from the python # stdlib. http://docs.python.org/3/license.html import re __version__ = '3.4.0.2' class CertificateError(ValueError): pass def _dnsname_match(dn, hostname, max_wildcards=1): """Matching according to RFC 6125, section 6.4.3 http://tools.ietf.org/html/rfc6125#section-6.4.3 """ pats = [] if not dn: return False # Ported from python3-syntax: # leftmost, *remainder = dn.split(r'.') parts = dn.split(r'.') leftmost = parts[0] remainder = parts[1:] wildcards = leftmost.count('*') if wildcards > max_wildcards: # Issue #17980: avoid denials of service by refusing more # than one wildcard per fragment. A survey of established # policy among SSL implementations showed it to be a # reasonable choice. raise CertificateError( "too many wildcards in certificate DNS name: " + repr(dn)) # speed up common case w/o wildcards if not wildcards: return dn.lower() == hostname.lower() # RFC 6125, section 6.4.3, subitem 1. # The client SHOULD NOT attempt to match a presented identifier in which # the wildcard character comprises a label other than the left-most label. if leftmost == '*': # When '*' is a fragment by itself, it matches a non-empty dotless # fragment. pats.append('[^.]+') elif leftmost.startswith('xn--') or hostname.startswith('xn--'): # RFC 6125, section 6.4.3, subitem 3. # The client SHOULD NOT attempt to match a presented identifier # where the wildcard character is embedded within an A-label or # U-label of an internationalized domain name. pats.append(re.escape(leftmost)) else: # Otherwise, '*' matches any dotless string, e.g. www* pats.append(re.escape(leftmost).replace(r'\*', '[^.]*')) # add the remaining fragments, ignore any wildcards for frag in remainder: pats.append(re.escape(frag)) pat = re.compile(r'\A' + r'\.'.join(pats) + r'\Z', re.IGNORECASE) return pat.match(hostname) def match_hostname(cert, hostname): """Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for *hostname*. CertificateError is raised on failure. On success, the function returns nothing. """ if not cert: raise ValueError("empty or no certificate") dnsnames = [] san = cert.get('subjectAltName', ()) for key, value in san: if key == 'DNS': if _dnsname_match(value, hostname): return dnsnames.append(value) if not dnsnames: # The subject is only checked when there is no dNSName entry # in subjectAltName for sub in cert.get('subject', ()): for key, value in sub: # XXX according to RFC 2818, the most specific Common Name # must be used. if key == 'commonName': if _dnsname_match(value, hostname): return dnsnames.append(value) if len(dnsnames) > 1: raise CertificateError("hostname %r " "doesn't match either of %s" % (hostname, ', '.join(map(repr, dnsnames)))) elif len(dnsnames) == 1: raise CertificateError("hostname %r " "doesn't match %r" % (hostname, dnsnames[0])) else: raise CertificateError("no appropriate commonName or " "subjectAltName fields were found")
agpl-3.0
[ 624, 1918, 1336, 63, 4269, 342, 805, 687, 2018, 650, 14, 19, 14, 19, 12, 22829, 1009, 1380, 1808, 7799, 1041, 199, 199, 3, 3390, 26, 961, 570, 365, 1334, 314, 29770, 4190, 465, 314, 1233, 12477, 687, 314, 2366, 199, 3, 26678, 14, 257, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 19, 15, 1682, 14, 1360, 199, 199, 646, 295, 199, 199, 363, 1023, 363, 275, 283, 19, 14, 20, 14, 16, 14, 18, 7, 199, 199, 533, 31953, 8, 3393, 304, 272, 986, 421, 199, 318, 485, 5797, 354, 63, 1431, 8, 4272, 12, 6246, 12, 1390, 63, 29500, 29, 17, 304, 272, 408, 14215, 7182, 370, 7329, 1227, 6889, 12, 3420, 1227, 14, 20, 14, 19, 339, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 22, 6889, 3, 2792, 13, 22, 14, 20, 14, 19, 272, 408, 272, 30818, 275, 942, 272, 340, 440, 14052, 26, 267, 372, 756, 339, 327, 510, 1376, 687, 2366, 19, 13, 7093, 26, 272, 327, 29971, 12, 627, 23850, 275, 14052, 14, 1294, 8, 82, 1370, 358, 272, 4184, 275, 14052, 14, 1294, 8, 82, 1370, 358, 272, 29971, 275, 4184, 59, 16, 61, 272, 15748, 275, 4184, 59, 17, 2938, 339, 24952, 275, 29971, 14, 835, 360, 13418, 272, 340, 24952, 690, 1390, 63, 29500, 26, 267, 327, 13383, 327, 10699, 1257, 26, 5126, 5376, 2380, 83, 402, 2435, 701, 2984, 4941, 1655, 267, 327, 2419, 1373, 16792, 1126, 7956, 14, 221, 437, 16576, 402, 23594, 267, 327, 4592, 16885, 7799, 12591, 2498, 379, 652, 370, 506, 282, 267, 327, 23255, 7141, 14, 267, 746, 31953, 8, 288, 298, 7354, 5002, 24952, 315, 5897, 10237, 536, 26, 298, 435, 4700, 8, 4272, 430, 339, 327, 8112, 1536, 2863, 1930, 336, 15, 79, 24952, 272, 340, 440, 24952, 26, 267, 372, 14052, 14, 2325, 342, 508, 6246, 14, 2325, 342, 339, 327, 7329, 1227, 6889, 12, 3420, 1227, 14, 20, 14, 19, 12, 1007, 1053, 413, 14, 272, 327, 710, 1890, 428, 31909, 2845, 7427, 370, 1336, 282, 26568, 5148, 315, 1314, 272, 327, 314, 16792, 4528, 1013, 322, 874, 282, 1768, 1163, 2419, 314, 3602, 13, 2786, 1768, 14, 272, 340, 29971, 508, 22969, 267, 327, 3979, 13626, 365, 282, 7956, 701, 6337, 12, 652, 4450, 282, 2222, 13, 1667, 6308, 2003, 267, 327, 7956, 14, 267, 30818, 14, 740, 360, 4735, 32455, 358, 272, 916, 29971, 14, 2460, 360, 5032, 306, 358, 503, 6246, 14, 2460, 360, 5032, 306, 735, 267, 327, 7329, 1227, 6889, 12, 3420, 1227, 14, 20, 14, 19, 12, 1007, 1053, 650, 14, 267, 327, 710, 1890, 428, 31909, 2845, 7427, 370, 1336, 282, 26568, 5148, 267, 327, 2382, 314, 16792, 4528, 365, 12169, 4453, 376, 437, 13, 1302, 503, 267, 327, 738, 13, 1302, 402, 376, 10757, 6279, 1759, 2881, 536, 14, 267, 30818, 14, 740, 8, 264, 14, 3765, 8, 3039, 2786, 430, 272, 587, 26, 267, 327, 6630, 12, 13626, 4450, 1263, 6308, 2003, 1059, 12, 325, 14, 71, 14, 20732, 10, 267, 30818, 14, 740, 8, 264, 14, 3765, 8, 3039, 2786, 680, 1814, 8, 82, 1154, 7693, 283, 4735, 14, 3672, 1333, 339, 327, 1050, 314, 7971, 21495, 12, 3686, 1263, 24952, 272, 367, 11101, 315, 15748, 26, 267, 30818, 14, 740, 8, 264, 14, 3765, 8, 11255, 430, 339, 12713, 275, 295, 14, 2014, 8, 82, 1154, 33, 7, 435, 519, 1154, 17374, 904, 8, 30756, 9, 435, 519, 1154, 58, 297, 295, 14, 15434, 9, 272, 372, 12713, 14, 1431, 8, 4269, 9, 421, 199, 318, 1336, 63, 4269, 8, 4736, 12, 6246, 304, 272, 408, 7496, 626, 627, 4736, 10, 334, 262, 11203, 1475, 465, 2138, 701, 272, 7799, 3869, 14, 362, 7866, 4736, 1012, 4450, 314, 627, 4269, 4856, 221, 7329, 7294, 1085, 436, 7329, 1227, 6889, 272, 4713, 787, 9437, 12, 1325, 3531, 7149, 787, 440, 10226, 367, 627, 4269, 4856, 339, 31953, 365, 4915, 641, 5988, 14, 4068, 3182, 12, 314, 805, 272, 2529, 6548, 14, 272, 408, 272, 340, 440, 6250, 26, 267, 746, 1722, 480, 1667, 503, 949, 5897, 531, 272, 6715, 1247, 275, 942, 272, 28698, 275, 6250, 14, 362, 360, 5875, 29171, 297, 14515, 272, 367, 790, 12, 574, 315, 28698, 26, 267, 340, 790, 508, 283, 12323, 356, 288, 340, 485, 5797, 354, 63, 1431, 8, 585, 12, 6246, 304, 355, 372, 288, 6715, 1247, 14, 740, 8, 585, 9, 272, 340, 440, 6715, 1247, 26, 267, 327, 710, 5420, 365, 1454, 7923, 1380, 2337, 365, 949, 366, 2709, 985, 2397, 267, 327, 315, 5420, 29171, 267, 367, 1007, 315, 6250, 14, 362, 360, 5875, 297, 334, 2298, 288, 367, 790, 12, 574, 315, 1007, 26, 355, 327, 5787, 7182, 370, 7329, 7294, 1085, 12, 314, 4750, 2488, 13964, 2812, 355, 327, 1471, 506, 1202, 14, 355, 340, 790, 508, 283, 2330, 985, 356, 490, 340, 485, 5797, 354, 63, 1431, 8, 585, 12, 6246, 304, 717, 372, 490, 6715, 1247, 14, 740, 8, 585, 9, 272, 340, 822, 8, 5797, 1247, 9, 690, 413, 26, 267, 746, 31953, 480, 4269, 450, 82, 298, 288, 298, 30977, 1133, 1336, 1902, 402, 450, 83, 2, 288, 450, 334, 4269, 12, 1656, 1987, 904, 8, 1130, 8, 2722, 12, 6715, 1247, 7845, 272, 916, 822, 8, 5797, 1247, 9, 508, 413, 26, 267, 746, 31953, 480, 4269, 450, 82, 298, 288, 298, 30977, 1133, 1336, 450, 82, 2, 288, 450, 334, 4269, 12, 6715, 1247, 59, 16, 2459, 272, 587, 26, 267, 746, 31953, 480, 889, 5827, 2863, 985, 503, 298, 288, 298, 5875, 29171, 1504, 4898, 1911, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1918, 1336, 63, 4269, 342, 805, 687, 2018, 650, 14, 19, 14, 19, 12, 22829, 1009, 1380, 1808, 7799, 1041, 199, 199, 3, 3390, 26, 961, 570, 365, 1334, 314, 29770, 4190, 465, 314, 1233, 12477, 687, 314, 2366, 199, 3, 26678, 14, 257, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 19, 15, 1682, 14, 1360, 199, 199, 646, 295, 199, 199, 363, 1023, 363, 275, 283, 19, 14, 20, 14, 16, 14, 18, 7, 199, 199, 533, 31953, 8, 3393, 304, 272, 986, 421, 199, 318, 485, 5797, 354, 63, 1431, 8, 4272, 12, 6246, 12, 1390, 63, 29500, 29, 17, 304, 272, 408, 14215, 7182, 370, 7329, 1227, 6889, 12, 3420, 1227, 14, 20, 14, 19, 339, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 22, 6889, 3, 2792, 13, 22, 14, 20, 14, 19, 272, 408, 272, 30818, 275, 942, 272, 340, 440, 14052, 26, 267, 372, 756, 339, 327, 510, 1376, 687, 2366, 19, 13, 7093, 26, 272, 327, 29971, 12, 627, 23850, 275, 14052, 14, 1294, 8, 82, 1370, 358, 272, 4184, 275, 14052, 14, 1294, 8, 82, 1370, 358, 272, 29971, 275, 4184, 59, 16, 61, 272, 15748, 275, 4184, 59, 17, 2938, 339, 24952, 275, 29971, 14, 835, 360, 13418, 272, 340, 24952, 690, 1390, 63, 29500, 26, 267, 327, 13383, 327, 10699, 1257, 26, 5126, 5376, 2380, 83, 402, 2435, 701, 2984, 4941, 1655, 267, 327, 2419, 1373, 16792, 1126, 7956, 14, 221, 437, 16576, 402, 23594, 267, 327, 4592, 16885, 7799, 12591, 2498, 379, 652, 370, 506, 282, 267, 327, 23255, 7141, 14, 267, 746, 31953, 8, 288, 298, 7354, 5002, 24952, 315, 5897, 10237, 536, 26, 298, 435, 4700, 8, 4272, 430, 339, 327, 8112, 1536, 2863, 1930, 336, 15, 79, 24952, 272, 340, 440, 24952, 26, 267, 372, 14052, 14, 2325, 342, 508, 6246, 14, 2325, 342, 339, 327, 7329, 1227, 6889, 12, 3420, 1227, 14, 20, 14, 19, 12, 1007, 1053, 413, 14, 272, 327, 710, 1890, 428, 31909, 2845, 7427, 370, 1336, 282, 26568, 5148, 315, 1314, 272, 327, 314, 16792, 4528, 1013, 322, 874, 282, 1768, 1163, 2419, 314, 3602, 13, 2786, 1768, 14, 272, 340, 29971, 508, 22969, 267, 327, 3979, 13626, 365, 282, 7956, 701, 6337, 12, 652, 4450, 282, 2222, 13, 1667, 6308, 2003, 267, 327, 7956, 14, 267, 30818, 14, 740, 360, 4735, 32455, 358, 272, 916, 29971, 14, 2460, 360, 5032, 306, 358, 503, 6246, 14, 2460, 360, 5032, 306, 735, 267, 327, 7329, 1227, 6889, 12, 3420, 1227, 14, 20, 14, 19, 12, 1007, 1053, 650, 14, 267, 327, 710, 1890, 428, 31909, 2845, 7427, 370, 1336, 282, 26568, 5148, 267, 327, 2382, 314, 16792, 4528, 365, 12169, 4453, 376, 437, 13, 1302, 503, 267, 327, 738, 13, 1302, 402, 376, 10757, 6279, 1759, 2881, 536, 14, 267, 30818, 14, 740, 8, 264, 14, 3765, 8, 3039, 2786, 430, 272, 587, 26, 267, 327, 6630, 12, 13626, 4450, 1263, 6308, 2003, 1059, 12, 325, 14, 71, 14, 20732, 10, 267, 30818, 14, 740, 8, 264, 14, 3765, 8, 3039, 2786, 680, 1814, 8, 82, 1154, 7693, 283, 4735, 14, 3672, 1333, 339, 327, 1050, 314, 7971, 21495, 12, 3686, 1263, 24952, 272, 367, 11101, 315, 15748, 26, 267, 30818, 14, 740, 8, 264, 14, 3765, 8, 11255, 430, 339, 12713, 275, 295, 14, 2014, 8, 82, 1154, 33, 7, 435, 519, 1154, 17374, 904, 8, 30756, 9, 435, 519, 1154, 58, 297, 295, 14, 15434, 9, 272, 372, 12713, 14, 1431, 8, 4269, 9, 421, 199, 318, 1336, 63, 4269, 8, 4736, 12, 6246, 304, 272, 408, 7496, 626, 627, 4736, 10, 334, 262, 11203, 1475, 465, 2138, 701, 272, 7799, 3869, 14, 362, 7866, 4736, 1012, 4450, 314, 627, 4269, 4856, 221, 7329, 7294, 1085, 436, 7329, 1227, 6889, 272, 4713, 787, 9437, 12, 1325, 3531, 7149, 787, 440, 10226, 367, 627, 4269, 4856, 339, 31953, 365, 4915, 641, 5988, 14, 4068, 3182, 12, 314, 805, 272, 2529, 6548, 14, 272, 408, 272, 340, 440, 6250, 26, 267, 746, 1722, 480, 1667, 503, 949, 5897, 531, 272, 6715, 1247, 275, 942, 272, 28698, 275, 6250, 14, 362, 360, 5875, 29171, 297, 14515, 272, 367, 790, 12, 574, 315, 28698, 26, 267, 340, 790, 508, 283, 12323, 356, 288, 340, 485, 5797, 354, 63, 1431, 8, 585, 12, 6246, 304, 355, 372, 288, 6715, 1247, 14, 740, 8, 585, 9, 272, 340, 440, 6715, 1247, 26, 267, 327, 710, 5420, 365, 1454, 7923, 1380, 2337, 365, 949, 366, 2709, 985, 2397, 267, 327, 315, 5420, 29171, 267, 367, 1007, 315, 6250, 14, 362, 360, 5875, 297, 334, 2298, 288, 367, 790, 12, 574, 315, 1007, 26, 355, 327, 5787, 7182, 370, 7329, 7294, 1085, 12, 314, 4750, 2488, 13964, 2812, 355, 327, 1471, 506, 1202, 14, 355, 340, 790, 508, 283, 2330, 985, 356, 490, 340, 485, 5797, 354, 63, 1431, 8, 585, 12, 6246, 304, 717, 372, 490, 6715, 1247, 14, 740, 8, 585, 9, 272, 340, 822, 8, 5797, 1247, 9, 690, 413, 26, 267, 746, 31953, 480, 4269, 450, 82, 298, 288, 298, 30977, 1133, 1336, 1902, 402, 450, 83, 2, 288, 450, 334, 4269, 12, 1656, 1987, 904, 8, 1130, 8, 2722, 12, 6715, 1247, 7845, 272, 916, 822, 8, 5797, 1247, 9, 508, 413, 26, 267, 746, 31953, 480, 4269, 450, 82, 298, 288, 298, 30977, 1133, 1336, 450, 82, 2, 288, 450, 334, 4269, 12, 6715, 1247, 59, 16, 2459, 272, 587, 26, 267, 746, 31953, 480, 889, 5827, 2863, 985, 503, 298, 288, 298, 5875, 29171, 1504, 4898, 1911, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
perezg/infoxchange
BASE/lib/python2.7/site-packages/django/contrib/sites/models.py
103
2979
from django.db import models from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import python_2_unicode_compatible SITE_CACHE = {} class SiteManager(models.Manager): def get_current(self): """ Returns the current ``Site`` based on the SITE_ID in the project's settings. The ``Site`` object is cached the first time it's retrieved from the database. """ from django.conf import settings try: sid = settings.SITE_ID except AttributeError: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured("You're using the Django \"sites framework\" without having set the SITE_ID setting. Create a site in your database and set the SITE_ID setting to fix this error.") try: current_site = SITE_CACHE[sid] except KeyError: current_site = self.get(pk=sid) SITE_CACHE[sid] = current_site return current_site def clear_cache(self): """Clears the ``Site`` object cache.""" global SITE_CACHE SITE_CACHE = {} @python_2_unicode_compatible class Site(models.Model): domain = models.CharField(_('domain name'), max_length=100) name = models.CharField(_('display name'), max_length=50) objects = SiteManager() class Meta: db_table = 'django_site' verbose_name = _('site') verbose_name_plural = _('sites') ordering = ('domain',) def __str__(self): return self.domain def save(self, *args, **kwargs): super(Site, self).save(*args, **kwargs) # Cached information will likely be incorrect now. if self.id in SITE_CACHE: del SITE_CACHE[self.id] def delete(self): pk = self.pk super(Site, self).delete() try: del SITE_CACHE[pk] except KeyError: pass @python_2_unicode_compatible class RequestSite(object): """ A class that shares the primary interface of Site (i.e., it has ``domain`` and ``name`` attributes) but gets its data from a Django HttpRequest object rather than from a database. The save() and delete() methods raise NotImplementedError. """ def __init__(self, request): self.domain = self.name = request.get_host() def __str__(self): return self.domain def save(self, force_insert=False, force_update=False): raise NotImplementedError('RequestSite cannot be saved.') def delete(self): raise NotImplementedError('RequestSite cannot be deleted.') def get_current_site(request): """ Checks if contrib.sites is installed and returns either the current ``Site`` object or a ``RequestSite`` object based on the request. """ if Site._meta.installed: current_site = Site.objects.get_current() else: current_site = RequestSite(request) return current_site
apache-2.0
[ 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 7917, 63, 8677, 275, 1052, 421, 199, 533, 11666, 2988, 8, 992, 14, 2988, 304, 339, 347, 664, 63, 1818, 8, 277, 304, 267, 408, 267, 1803, 314, 1453, 1124, 8972, 1040, 4079, 641, 314, 428, 4427, 63, 998, 315, 314, 267, 2199, 1159, 2202, 14, 710, 1124, 8972, 1040, 909, 365, 6328, 314, 1642, 267, 900, 652, 1159, 12396, 687, 314, 3050, 14, 267, 408, 267, 687, 1639, 14, 2190, 492, 2202, 267, 862, 26, 288, 15764, 275, 2202, 14, 7917, 63, 998, 267, 871, 4281, 26, 288, 687, 1639, 14, 1018, 14, 3924, 492, 11897, 288, 746, 11897, 480, 5556, 3984, 1808, 314, 5634, 8441, 8619, 10059, 4451, 1928, 9445, 663, 314, 428, 4427, 63, 998, 4260, 14, 2790, 282, 4770, 315, 2195, 3050, 436, 663, 314, 428, 4427, 63, 998, 4260, 370, 5325, 642, 1125, 2685, 267, 862, 26, 288, 1453, 63, 2124, 275, 428, 4427, 63, 8677, 59, 4148, 61, 267, 871, 4067, 26, 288, 1453, 63, 2124, 275, 291, 14, 362, 8, 2051, 29, 4148, 9, 288, 428, 4427, 63, 8677, 59, 4148, 61, 275, 1453, 63, 2124, 267, 372, 1453, 63, 2124, 339, 347, 5436, 63, 1637, 8, 277, 304, 267, 408, 9721, 83, 314, 1124, 8972, 1040, 909, 2581, 1041, 267, 2288, 428, 4427, 63, 8677, 267, 428, 4427, 63, 8677, 275, 1052, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 11666, 8, 992, 14, 1685, 304, 339, 2881, 275, 1709, 14, 2183, 6723, 2261, 536, 659, 1390, 63, 1267, 29, 1960, 9, 272, 536, 275, 1709, 14, 2183, 6723, 2918, 536, 659, 1390, 63, 1267, 29, 1400, 9, 272, 2251, 275, 11666, 2988, 342, 339, 1021, 6288, 26, 267, 1592, 63, 1224, 275, 283, 1176, 63, 2124, 7, 267, 3376, 63, 354, 275, 4018, 2124, 358, 267, 3376, 63, 354, 63, 10019, 275, 4018, 8619, 358, 267, 7794, 275, 661, 2261, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 2261, 339, 347, 3354, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 8972, 12, 291, 680, 2117, 2031, 589, 12, 1011, 958, 9, 267, 327, 445, 4583, 2556, 911, 12060, 506, 8927, 3063, 14, 267, 340, 291, 14, 344, 315, 428, 4427, 63, 8677, 26, 288, 2150, 428, 4427, 63, 8677, 59, 277, 14, 344, 61, 339, 347, 3145, 8, 277, 304, 267, 3803, 275, 291, 14, 2051, 267, 1613, 8, 8972, 12, 291, 680, 1807, 342, 267, 862, 26, 288, 2150, 428, 4427, 63, 8677, 59, 2051, 61, 267, 871, 4067, 26, 288, 986, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 4784, 8972, 8, 785, 304, 272, 408, 272, 437, 1021, 626, 25616, 314, 5062, 3217, 402, 11666, 334, 73, 14, 69, 2020, 652, 965, 272, 1124, 2261, 1040, 436, 1124, 354, 1040, 3004, 9, 1325, 7545, 2399, 666, 687, 282, 5634, 272, 20730, 909, 7830, 2419, 687, 282, 3050, 14, 339, 710, 3354, 342, 436, 3145, 342, 3102, 746, 4279, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 14, 2261, 275, 291, 14, 354, 275, 1056, 14, 362, 63, 1102, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 2261, 339, 347, 3354, 8, 277, 12, 3542, 63, 3176, 29, 797, 12, 3542, 63, 873, 29, 797, 304, 267, 746, 4279, 360, 2017, 8972, 3913, 506, 6290, 2659, 339, 347, 3145, 8, 277, 304, 267, 746, 4279, 360, 2017, 8972, 3913, 506, 5463, 2659, 421, 199, 318, 664, 63, 1818, 63, 2124, 8, 1069, 304, 272, 408, 272, 13813, 340, 5914, 14, 8619, 365, 4903, 436, 2529, 1902, 314, 1453, 272, 1124, 8972, 1040, 909, 503, 282, 1124, 2017, 8972, 1040, 909, 4079, 641, 314, 1056, 14, 272, 408, 272, 340, 11666, 423, 2024, 14, 7657, 26, 267, 1453, 63, 2124, 275, 11666, 14, 1462, 14, 362, 63, 1818, 342, 272, 587, 26, 267, 1453, 63, 2124, 275, 4784, 8972, 8, 1069, 9, 272, 372, 1453, 63, 2124, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 7917, 63, 8677, 275, 1052, 421, 199, 533, 11666, 2988, 8, 992, 14, 2988, 304, 339, 347, 664, 63, 1818, 8, 277, 304, 267, 408, 267, 1803, 314, 1453, 1124, 8972, 1040, 4079, 641, 314, 428, 4427, 63, 998, 315, 314, 267, 2199, 1159, 2202, 14, 710, 1124, 8972, 1040, 909, 365, 6328, 314, 1642, 267, 900, 652, 1159, 12396, 687, 314, 3050, 14, 267, 408, 267, 687, 1639, 14, 2190, 492, 2202, 267, 862, 26, 288, 15764, 275, 2202, 14, 7917, 63, 998, 267, 871, 4281, 26, 288, 687, 1639, 14, 1018, 14, 3924, 492, 11897, 288, 746, 11897, 480, 5556, 3984, 1808, 314, 5634, 8441, 8619, 10059, 4451, 1928, 9445, 663, 314, 428, 4427, 63, 998, 4260, 14, 2790, 282, 4770, 315, 2195, 3050, 436, 663, 314, 428, 4427, 63, 998, 4260, 370, 5325, 642, 1125, 2685, 267, 862, 26, 288, 1453, 63, 2124, 275, 428, 4427, 63, 8677, 59, 4148, 61, 267, 871, 4067, 26, 288, 1453, 63, 2124, 275, 291, 14, 362, 8, 2051, 29, 4148, 9, 288, 428, 4427, 63, 8677, 59, 4148, 61, 275, 1453, 63, 2124, 267, 372, 1453, 63, 2124, 339, 347, 5436, 63, 1637, 8, 277, 304, 267, 408, 9721, 83, 314, 1124, 8972, 1040, 909, 2581, 1041, 267, 2288, 428, 4427, 63, 8677, 267, 428, 4427, 63, 8677, 275, 1052, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 11666, 8, 992, 14, 1685, 304, 339, 2881, 275, 1709, 14, 2183, 6723, 2261, 536, 659, 1390, 63, 1267, 29, 1960, 9, 272, 536, 275, 1709, 14, 2183, 6723, 2918, 536, 659, 1390, 63, 1267, 29, 1400, 9, 272, 2251, 275, 11666, 2988, 342, 339, 1021, 6288, 26, 267, 1592, 63, 1224, 275, 283, 1176, 63, 2124, 7, 267, 3376, 63, 354, 275, 4018, 2124, 358, 267, 3376, 63, 354, 63, 10019, 275, 4018, 8619, 358, 267, 7794, 275, 661, 2261, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 2261, 339, 347, 3354, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 8972, 12, 291, 680, 2117, 2031, 589, 12, 1011, 958, 9, 267, 327, 445, 4583, 2556, 911, 12060, 506, 8927, 3063, 14, 267, 340, 291, 14, 344, 315, 428, 4427, 63, 8677, 26, 288, 2150, 428, 4427, 63, 8677, 59, 277, 14, 344, 61, 339, 347, 3145, 8, 277, 304, 267, 3803, 275, 291, 14, 2051, 267, 1613, 8, 8972, 12, 291, 680, 1807, 342, 267, 862, 26, 288, 2150, 428, 4427, 63, 8677, 59, 2051, 61, 267, 871, 4067, 26, 288, 986, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 4784, 8972, 8, 785, 304, 272, 408, 272, 437, 1021, 626, 25616, 314, 5062, 3217, 402, 11666, 334, 73, 14, 69, 2020, 652, 965, 272, 1124, 2261, 1040, 436, 1124, 354, 1040, 3004, 9, 1325, 7545, 2399, 666, 687, 282, 5634, 272, 20730, 909, 7830, 2419, 687, 282, 3050, 14, 339, 710, 3354, 342, 436, 3145, 342, 3102, 746, 4279, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 14, 2261, 275, 291, 14, 354, 275, 1056, 14, 362, 63, 1102, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 2261, 339, 347, 3354, 8, 277, 12, 3542, 63, 3176, 29, 797, 12, 3542, 63, 873, 29, 797, 304, 267, 746, 4279, 360, 2017, 8972, 3913, 506, 6290, 2659, 339, 347, 3145, 8, 277, 304, 267, 746, 4279, 360, 2017, 8972, 3913, 506, 5463, 2659, 421, 199, 318, 664, 63, 1818, 63, 2124, 8, 1069, 304, 272, 408, 272, 13813, 340, 5914, 14, 8619, 365, 4903, 436, 2529, 1902, 314, 1453, 272, 1124, 8972, 1040, 909, 503, 282, 1124, 2017, 8972, 1040, 909, 4079, 641, 314, 1056, 14, 272, 408, 272, 340, 11666, 423, 2024, 14, 7657, 26, 267, 1453, 63, 2124, 275, 11666, 14, 1462, 14, 362, 63, 1818, 342, 272, 587, 26, 267, 1453, 63, 2124, 275, 4784, 8972, 8, 1069, 9, 272, 372, 1453, 63, 2124, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
MobSF/Mobile-Security-Framework-MobSF
mobsf/StaticAnalyzer/views/ios/db_interaction.py
1
7363
"""Module holding the functions for the db.""" import logging from django.conf import settings from mobsf.MobSF.utils import python_dict, python_list from mobsf.StaticAnalyzer.models import StaticAnalyzerIOS from mobsf.StaticAnalyzer.models import RecentScansDB logger = logging.getLogger(__name__) def get_context_from_db_entry(db_entry): """Return the context for IPA/ZIP from DB.""" try: logger.info('Analysis is already Done. Fetching data from the DB...') context = { 'version': settings.MOBSF_VER, 'title': 'Static Analysis', 'file_name': db_entry[0].FILE_NAME, 'app_name': db_entry[0].APP_NAME, 'app_type': db_entry[0].APP_TYPE, 'size': db_entry[0].SIZE, 'md5': db_entry[0].MD5, 'sha1': db_entry[0].SHA1, 'sha256': db_entry[0].SHA256, 'build': db_entry[0].BUILD, 'app_version': db_entry[0].APP_VERSION, 'sdk_name': db_entry[0].SDK_NAME, 'platform': db_entry[0].PLATFORM, 'min_os_version': db_entry[0].MIN_OS_VERSION, 'bundle_id': db_entry[0].BUNDLE_ID, 'bundle_url_types': python_list(db_entry[0].BUNDLE_URL_TYPES), 'bundle_supported_platforms': python_list(db_entry[0].BUNDLE_SUPPORTED_PLATFORMS), 'icon_found': db_entry[0].ICON_FOUND, 'info_plist': db_entry[0].INFO_PLIST, 'binary_info': python_dict(db_entry[0].BINARY_INFO), 'permissions': python_list(db_entry[0].PERMISSIONS), 'ats_analysis': python_list(db_entry[0].ATS_ANALYSIS), 'binary_analysis': python_list(db_entry[0].BINARY_ANALYSIS), 'macho_analysis': python_dict(db_entry[0].MACHO_ANALYSIS), 'ios_api': python_dict(db_entry[0].IOS_API), 'code_analysis': python_dict(db_entry[0].CODE_ANALYSIS), 'file_analysis': python_list(db_entry[0].FILE_ANALYSIS), 'libraries': python_list(db_entry[0].LIBRARIES), 'files': python_list(db_entry[0].FILES), 'urls': python_list(db_entry[0].URLS), 'domains': python_dict(db_entry[0].DOMAINS), 'emails': python_list(db_entry[0].EMAILS), 'strings': python_list(db_entry[0].STRINGS), 'firebase_urls': python_list(db_entry[0].FIREBASE_URLS), 'appstore_details': python_dict(db_entry[0].APPSTORE_DETAILS), } return context except Exception: logger.exception('Fetching from DB') def get_context_from_analysis(app_dict, info_dict, code_dict, bin_dict, all_files): """Get the context for IPA/ZIP from analysis results.""" try: context = { 'version': settings.MOBSF_VER, 'title': 'Static Analysis', 'file_name': app_dict['file_name'], 'app_name': info_dict['bin_name'], 'app_type': bin_dict['bin_type'], 'size': app_dict['size'], 'md5': app_dict['md5_hash'], 'sha1': app_dict['sha1'], 'sha256': app_dict['sha256'], 'build': info_dict['build'], 'app_version': info_dict['bundle_version_name'], 'sdk_name': info_dict['sdk'], 'platform': info_dict['pltfm'], 'min_os_version': info_dict['min'], 'bundle_id': info_dict['id'], 'bundle_url_types': info_dict['bundle_url_types'], 'bundle_supported_platforms': info_dict['bundle_supported_platforms'], 'icon_found': app_dict['icon_found'], 'info_plist': info_dict['plist_xml'], 'binary_info': bin_dict['bin_info'], 'permissions': info_dict['permissions'], 'ats_analysis': info_dict['inseccon'], 'binary_analysis': bin_dict['bin_code_analysis'], 'macho_analysis': bin_dict['checksec'], 'ios_api': code_dict['api'], 'code_analysis': code_dict['code_anal'], 'file_analysis': all_files['special_files'], 'libraries': bin_dict['libraries'], 'files': all_files['files_short'], 'urls': code_dict['urlnfile'], 'domains': code_dict['domains'], 'emails': code_dict['emailnfile'], 'strings': bin_dict['strings'], 'firebase_urls': code_dict['firebase'], 'appstore_details': app_dict['appstore'], } return context except Exception: logger.exception('Rendering to Template') def save_or_update(update_type, app_dict, info_dict, code_dict, bin_dict, all_files): """Save/Update an IPA/ZIP DB entry.""" try: values = { 'FILE_NAME': app_dict['file_name'], 'APP_NAME': info_dict['bin_name'], 'APP_TYPE': bin_dict['bin_type'], 'SIZE': app_dict['size'], 'MD5': app_dict['md5_hash'], 'SHA1': app_dict['sha1'], 'SHA256': app_dict['sha256'], 'BUILD': info_dict['build'], 'APP_VERSION': info_dict['bundle_version_name'], 'SDK_NAME': info_dict['sdk'], 'PLATFORM': info_dict['pltfm'], 'MIN_OS_VERSION': info_dict['min'], 'BUNDLE_ID': info_dict['id'], 'BUNDLE_URL_TYPES': info_dict['bundle_url_types'], 'BUNDLE_SUPPORTED_PLATFORMS': info_dict['bundle_supported_platforms'], 'ICON_FOUND': app_dict['icon_found'], 'INFO_PLIST': info_dict['plist_xml'], 'BINARY_INFO': bin_dict['bin_info'], 'PERMISSIONS': info_dict['permissions'], 'ATS_ANALYSIS': info_dict['inseccon'], 'BINARY_ANALYSIS': bin_dict['bin_code_analysis'], 'MACHO_ANALYSIS': bin_dict['checksec'], 'IOS_API': code_dict['api'], 'CODE_ANALYSIS': code_dict['code_anal'], 'FILE_ANALYSIS': all_files['special_files'], 'LIBRARIES': bin_dict['libraries'], 'FILES': all_files['files_short'], 'URLS': code_dict['urlnfile'], 'DOMAINS': code_dict['domains'], 'EMAILS': code_dict['emailnfile'], 'STRINGS': bin_dict['strings'], 'FIREBASE_URLS': code_dict['firebase'], 'APPSTORE_DETAILS': app_dict['appstore'], } if update_type == 'save': db_entry = StaticAnalyzerIOS.objects.filter( MD5=app_dict['md5_hash']) if not db_entry.exists(): StaticAnalyzerIOS.objects.create(**values) else: StaticAnalyzerIOS.objects.filter( MD5=app_dict['md5_hash']).update(**values) except Exception: logger.exception('Updating DB') try: values = { 'APP_NAME': info_dict['bin_name'], 'PACKAGE_NAME': info_dict['id'], 'VERSION_NAME': info_dict['bundle_version_name'], } RecentScansDB.objects.filter( MD5=app_dict['md5_hash']).update(**values) except Exception: logger.exception('Updating RecentScansDB')
gpl-3.0
[ 624, 2377, 17573, 314, 3423, 367, 314, 1592, 1041, 199, 646, 2050, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 504, 1303, 1533, 70, 14, 10970, 13107, 14, 1208, 492, 2366, 63, 807, 12, 2366, 63, 513, 199, 504, 1303, 1533, 70, 14, 9278, 17606, 14, 992, 492, 13599, 17606, 13532, 199, 504, 1303, 1533, 70, 14, 9278, 17606, 14, 992, 492, 799, 2946, 7181, 796, 2846, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 664, 63, 1100, 63, 504, 63, 697, 63, 2373, 8, 697, 63, 2373, 304, 272, 408, 1767, 314, 1067, 367, 3531, 33, 15, 16977, 687, 6249, 1041, 272, 862, 26, 267, 2512, 14, 815, 360, 13182, 365, 2575, 23541, 14, 16347, 316, 666, 687, 314, 6249, 15103, 267, 1067, 275, 469, 288, 283, 1023, 356, 2202, 14, 2679, 11087, 38, 63, 2111, 12, 288, 283, 1213, 356, 283, 9278, 21916, 297, 288, 283, 493, 63, 354, 356, 1592, 63, 2373, 59, 16, 1055, 3817, 63, 2339, 12, 288, 283, 571, 63, 354, 356, 1592, 63, 2373, 59, 16, 1055, 7121, 63, 2339, 12, 288, 283, 571, 63, 466, 356, 1592, 63, 2373, 59, 16, 1055, 7121, 63, 2711, 12, 288, 283, 890, 356, 1592, 63, 2373, 59, 16, 1055, 4305, 12, 288, 283, 1064, 21, 356, 1592, 63, 2373, 59, 16, 1055, 5127, 21, 12, 288, 283, 4835, 17, 356, 1592, 63, 2373, 59, 16, 1055, 8461, 17, 12, 288, 283, 4835, 3912, 356, 1592, 63, 2373, 59, 16, 1055, 8461, 3912, 12, 288, 283, 1506, 356, 1592, 63, 2373, 59, 16, 1055, 8248, 12, 288, 283, 571, 63, 1023, 356, 1592, 63, 2373, 59, 16, 1055, 7121, 63, 4612, 12, 288, 283, 9277, 63, 354, 356, 1592, 63, 2373, 59, 16, 1055, 14939, 63, 2339, 12, 288, 283, 3246, 356, 1592, 63, 2373, 59, 16, 1055, 17805, 12, 288, 283, 827, 63, 736, 63, 1023, 356, 1592, 63, 2373, 59, 16, 1055, 4896, 63, 3100, 63, 4612, 12, 288, 283, 6469, 63, 344, 356, 1592, 63, 2373, 59, 16, 1055, 32044, 906, 63, 998, 12, 288, 283, 6469, 63, 633, 63, 1313, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 32044, 906, 63, 2632, 63, 7893, 395, 288, 283, 6469, 63, 4946, 63, 19601, 356, 355, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 32044, 906, 63, 15925, 63, 2749, 619, 11518, 395, 288, 283, 4677, 63, 4214, 356, 1592, 63, 2373, 59, 16, 1055, 15903, 63, 13945, 12, 288, 283, 815, 63, 10265, 356, 1592, 63, 2373, 59, 16, 1055, 4531, 63, 48, 4924, 12, 288, 283, 3008, 63, 815, 356, 2366, 63, 807, 8, 697, 63, 2373, 59, 16, 1055, 13246, 63, 4531, 395, 288, 283, 6060, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 4227, 31978, 395, 288, 283, 1956, 63, 10466, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 619, 51, 63, 31158, 20238, 1311, 395, 288, 283, 3008, 63, 10466, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 13246, 63, 31158, 20238, 1311, 395, 288, 283, 391, 2239, 63, 10466, 356, 2366, 63, 807, 8, 697, 63, 2373, 59, 16, 1055, 2054, 10465, 63, 31158, 20238, 1311, 395, 288, 283, 9207, 63, 1246, 356, 2366, 63, 807, 8, 697, 63, 2373, 59, 16, 1055, 13532, 63, 3735, 395, 288, 283, 600, 63, 10466, 356, 2366, 63, 807, 8, 697, 63, 2373, 59, 16, 1055, 6012, 63, 31158, 20238, 1311, 395, 288, 283, 493, 63, 10466, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 3817, 63, 31158, 20238, 1311, 395, 288, 283, 10159, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 32723, 395, 288, 283, 1725, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 9472, 395, 288, 283, 3603, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 31582, 395, 288, 283, 9756, 356, 2366, 63, 807, 8, 697, 63, 2373, 59, 16, 1055, 7378, 51, 395, 288, 283, 14170, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 10089, 51, 395, 288, 283, 5465, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 31271, 395, 288, 283, 8935, 1095, 63, 3603, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 1976, 907, 5825, 63, 31582, 395, 288, 283, 571, 1617, 63, 5087, 356, 2366, 63, 807, 8, 697, 63, 2373, 59, 16, 1055, 7121, 16169, 63, 25081, 51, 395, 398, 789, 267, 372, 1067, 272, 871, 2186, 26, 267, 2512, 14, 1971, 360, 11135, 316, 687, 6249, 358, 421, 199, 318, 664, 63, 1100, 63, 504, 63, 10466, 8, 571, 63, 807, 12, 2892, 2256, 63, 807, 12, 2892, 1233, 63, 807, 12, 2892, 2517, 63, 807, 12, 2892, 1006, 63, 1725, 304, 272, 408, 1002, 314, 1067, 367, 3531, 33, 15, 16977, 687, 11284, 2058, 1041, 272, 862, 26, 267, 1067, 275, 469, 288, 283, 1023, 356, 2202, 14, 2679, 11087, 38, 63, 2111, 12, 288, 283, 1213, 356, 283, 9278, 21916, 297, 288, 283, 493, 63, 354, 356, 1145, 63, 807, 459, 493, 63, 354, 995, 288, 283, 571, 63, 354, 356, 2256, 63, 807, 459, 1393, 63, 354, 995, 288, 283, 571, 63, 466, 356, 2517, 63, 807, 459, 1393, 63, 466, 995, 288, 283, 890, 356, 1145, 63, 807, 459, 890, 995, 288, 283, 1064, 21, 356, 1145, 63, 807, 459, 1064, 21, 63, 2227, 995, 288, 283, 4835, 17, 356, 1145, 63, 807, 459, 4835, 17, 995, 288, 283, 4835, 3912, 356, 1145, 63, 807, 459, 4835, 3912, 995, 288, 283, 1506, 356, 2256, 63, 807, 459, 1506, 995, 288, 283, 571, 63, 1023, 356, 2256, 63, 807, 459, 6469, 63, 1023, 63, 354, 995, 288, 283, 9277, 63, 354, 356, 2256, 63, 807, 459, 9277, 995, 288, 283, 3246, 356, 2256, 63, 807, 459, 1168, 3249, 77, 995, 288, 283, 827, 63, 736, 63, 1023, 356, 2256, 63, 807, 459, 827, 995, 288, 283, 6469, 63, 344, 356, 2256, 63, 807, 459, 344, 995, 288, 283, 6469, 63, 633, 63, 1313, 356, 2256, 63, 807, 459, 6469, 63, 633 ]
[ 2377, 17573, 314, 3423, 367, 314, 1592, 1041, 199, 646, 2050, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 504, 1303, 1533, 70, 14, 10970, 13107, 14, 1208, 492, 2366, 63, 807, 12, 2366, 63, 513, 199, 504, 1303, 1533, 70, 14, 9278, 17606, 14, 992, 492, 13599, 17606, 13532, 199, 504, 1303, 1533, 70, 14, 9278, 17606, 14, 992, 492, 799, 2946, 7181, 796, 2846, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 664, 63, 1100, 63, 504, 63, 697, 63, 2373, 8, 697, 63, 2373, 304, 272, 408, 1767, 314, 1067, 367, 3531, 33, 15, 16977, 687, 6249, 1041, 272, 862, 26, 267, 2512, 14, 815, 360, 13182, 365, 2575, 23541, 14, 16347, 316, 666, 687, 314, 6249, 15103, 267, 1067, 275, 469, 288, 283, 1023, 356, 2202, 14, 2679, 11087, 38, 63, 2111, 12, 288, 283, 1213, 356, 283, 9278, 21916, 297, 288, 283, 493, 63, 354, 356, 1592, 63, 2373, 59, 16, 1055, 3817, 63, 2339, 12, 288, 283, 571, 63, 354, 356, 1592, 63, 2373, 59, 16, 1055, 7121, 63, 2339, 12, 288, 283, 571, 63, 466, 356, 1592, 63, 2373, 59, 16, 1055, 7121, 63, 2711, 12, 288, 283, 890, 356, 1592, 63, 2373, 59, 16, 1055, 4305, 12, 288, 283, 1064, 21, 356, 1592, 63, 2373, 59, 16, 1055, 5127, 21, 12, 288, 283, 4835, 17, 356, 1592, 63, 2373, 59, 16, 1055, 8461, 17, 12, 288, 283, 4835, 3912, 356, 1592, 63, 2373, 59, 16, 1055, 8461, 3912, 12, 288, 283, 1506, 356, 1592, 63, 2373, 59, 16, 1055, 8248, 12, 288, 283, 571, 63, 1023, 356, 1592, 63, 2373, 59, 16, 1055, 7121, 63, 4612, 12, 288, 283, 9277, 63, 354, 356, 1592, 63, 2373, 59, 16, 1055, 14939, 63, 2339, 12, 288, 283, 3246, 356, 1592, 63, 2373, 59, 16, 1055, 17805, 12, 288, 283, 827, 63, 736, 63, 1023, 356, 1592, 63, 2373, 59, 16, 1055, 4896, 63, 3100, 63, 4612, 12, 288, 283, 6469, 63, 344, 356, 1592, 63, 2373, 59, 16, 1055, 32044, 906, 63, 998, 12, 288, 283, 6469, 63, 633, 63, 1313, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 32044, 906, 63, 2632, 63, 7893, 395, 288, 283, 6469, 63, 4946, 63, 19601, 356, 355, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 32044, 906, 63, 15925, 63, 2749, 619, 11518, 395, 288, 283, 4677, 63, 4214, 356, 1592, 63, 2373, 59, 16, 1055, 15903, 63, 13945, 12, 288, 283, 815, 63, 10265, 356, 1592, 63, 2373, 59, 16, 1055, 4531, 63, 48, 4924, 12, 288, 283, 3008, 63, 815, 356, 2366, 63, 807, 8, 697, 63, 2373, 59, 16, 1055, 13246, 63, 4531, 395, 288, 283, 6060, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 4227, 31978, 395, 288, 283, 1956, 63, 10466, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 619, 51, 63, 31158, 20238, 1311, 395, 288, 283, 3008, 63, 10466, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 13246, 63, 31158, 20238, 1311, 395, 288, 283, 391, 2239, 63, 10466, 356, 2366, 63, 807, 8, 697, 63, 2373, 59, 16, 1055, 2054, 10465, 63, 31158, 20238, 1311, 395, 288, 283, 9207, 63, 1246, 356, 2366, 63, 807, 8, 697, 63, 2373, 59, 16, 1055, 13532, 63, 3735, 395, 288, 283, 600, 63, 10466, 356, 2366, 63, 807, 8, 697, 63, 2373, 59, 16, 1055, 6012, 63, 31158, 20238, 1311, 395, 288, 283, 493, 63, 10466, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 3817, 63, 31158, 20238, 1311, 395, 288, 283, 10159, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 32723, 395, 288, 283, 1725, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 9472, 395, 288, 283, 3603, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 31582, 395, 288, 283, 9756, 356, 2366, 63, 807, 8, 697, 63, 2373, 59, 16, 1055, 7378, 51, 395, 288, 283, 14170, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 10089, 51, 395, 288, 283, 5465, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 31271, 395, 288, 283, 8935, 1095, 63, 3603, 356, 2366, 63, 513, 8, 697, 63, 2373, 59, 16, 1055, 1976, 907, 5825, 63, 31582, 395, 288, 283, 571, 1617, 63, 5087, 356, 2366, 63, 807, 8, 697, 63, 2373, 59, 16, 1055, 7121, 16169, 63, 25081, 51, 395, 398, 789, 267, 372, 1067, 272, 871, 2186, 26, 267, 2512, 14, 1971, 360, 11135, 316, 687, 6249, 358, 421, 199, 318, 664, 63, 1100, 63, 504, 63, 10466, 8, 571, 63, 807, 12, 2892, 2256, 63, 807, 12, 2892, 1233, 63, 807, 12, 2892, 2517, 63, 807, 12, 2892, 1006, 63, 1725, 304, 272, 408, 1002, 314, 1067, 367, 3531, 33, 15, 16977, 687, 11284, 2058, 1041, 272, 862, 26, 267, 1067, 275, 469, 288, 283, 1023, 356, 2202, 14, 2679, 11087, 38, 63, 2111, 12, 288, 283, 1213, 356, 283, 9278, 21916, 297, 288, 283, 493, 63, 354, 356, 1145, 63, 807, 459, 493, 63, 354, 995, 288, 283, 571, 63, 354, 356, 2256, 63, 807, 459, 1393, 63, 354, 995, 288, 283, 571, 63, 466, 356, 2517, 63, 807, 459, 1393, 63, 466, 995, 288, 283, 890, 356, 1145, 63, 807, 459, 890, 995, 288, 283, 1064, 21, 356, 1145, 63, 807, 459, 1064, 21, 63, 2227, 995, 288, 283, 4835, 17, 356, 1145, 63, 807, 459, 4835, 17, 995, 288, 283, 4835, 3912, 356, 1145, 63, 807, 459, 4835, 3912, 995, 288, 283, 1506, 356, 2256, 63, 807, 459, 1506, 995, 288, 283, 571, 63, 1023, 356, 2256, 63, 807, 459, 6469, 63, 1023, 63, 354, 995, 288, 283, 9277, 63, 354, 356, 2256, 63, 807, 459, 9277, 995, 288, 283, 3246, 356, 2256, 63, 807, 459, 1168, 3249, 77, 995, 288, 283, 827, 63, 736, 63, 1023, 356, 2256, 63, 807, 459, 827, 995, 288, 283, 6469, 63, 344, 356, 2256, 63, 807, 459, 344, 995, 288, 283, 6469, 63, 633, 63, 1313, 356, 2256, 63, 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1, 1, 1, 1, 1, 1, 1, 1 ]
ms-iot/samples
AllJoyn/Samples/OICAdapter/iotivity-1.0.0/build_common/iotivityconfig/compiler/default_configuration.py
64
2636
# ------------------------------------------------------------------------ # Copyright 2015 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ------------------------------------------------------------------------ from configuration import Configuration # Default (very simple) compiler configuration class DefaultConfiguration(Configuration): def __init__(self, context): Configuration.__init__(self, context) # ------------------------------------------------------------ # Return test program to be used when checking for basic C++11 # support. # ------------------------------------------------------------ def _c99_test_program(self): return """ // Some headers found in C99. #include <stdbool.h> #include <stdint.h> int main() { struct foo { bool b; // C99 type int i; uint64_t q; // C99 type }; // Designated initializer. struct foo bar = { .b = false, .q = UINT64_MAX }; // Implicitly initialized field. return bar.i != 0; } """ # -------------------------------------------------------------- # Get list of flags that could potentially enable C99 support. # # The default configuration assumes that no flag is needed to # enable C99 support. # -------------------------------------------------------------- def _c99_flags(self): return [] # ------------------------------------------------------------ # Return test program to be used when checking for basic C++11 # support. # ------------------------------------------------------------ def _cxx11_test_program(self): return """ int main() { int x = 3210; auto f = [x](){ return x; }; return f() != x; } """ # -------------------------------------------------------------- # Get list of flags that could potentially enable C++11 support. # # The default configuration assumes that no flag is needed to # enable C++11 support. # -------------------------------------------------------------- def _cxx11_flags(self): return []
mit
[ 3, 5620, 518, 199, 3, 1898, 6900, 20619, 11098, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 5620, 518, 199, 199, 504, 2897, 492, 11595, 199, 199, 3, 3758, 334, 2588, 3486, 9, 6365, 2897, 199, 533, 3758, 5688, 8, 5688, 304, 272, 347, 636, 826, 721, 277, 12, 1067, 304, 267, 11595, 855, 826, 721, 277, 12, 1067, 9, 339, 327, 9527, 4559, 272, 327, 1432, 511, 2240, 370, 506, 1202, 1380, 7907, 367, 5678, 445, 4176, 845, 272, 327, 2291, 14, 272, 327, 9527, 4559, 272, 347, 485, 67, 1020, 63, 396, 63, 6815, 8, 277, 304, 267, 372, 408, 199, 501, 6601, 2323, 1911, 315, 445, 1020, 14, 199, 3, 2613, 665, 1516, 2245, 14, 72, 30, 199, 3, 2613, 665, 1516, 442, 14, 72, 30, 199, 199, 442, 2446, 342, 199, 91, 272, 2702, 3925, 272, 469, 267, 2155, 330, 27, 420, 5001, 445, 1020, 730, 267, 1109, 284, 27, 267, 3152, 772, 63, 84, 1894, 27, 221, 5001, 445, 1020, 730, 272, 16735, 339, 5001, 29410, 972, 11130, 14, 272, 2702, 3925, 4681, 275, 469, 1275, 66, 275, 3055, 12, 1275, 81, 275, 30151, 772, 63, 4283, 16735, 339, 5001, 8362, 3137, 590, 10038, 901, 14, 272, 372, 4681, 14, 73, 1137, 378, 27, 199, 93, 199, 624, 339, 327, 9527, 10965, 272, 327, 2372, 769, 402, 3285, 626, 4293, 18994, 4756, 445, 1020, 2291, 14, 272, 327, 272, 327, 710, 849, 2897, 15194, 626, 949, 3305, 365, 4346, 370, 272, 327, 4756, 445, 1020, 2291, 14, 272, 327, 9527, 10965, 272, 347, 485, 67, 1020, 63, 2469, 8, 277, 304, 267, 372, 942, 339, 327, 9527, 4559, 272, 327, 1432, 511, 2240, 370, 506, 1202, 1380, 7907, 367, 5678, 445, 4176, 845, 272, 327, 2291, 14, 272, 327, 9527, 4559, 272, 347, 485, 9634, 845, 63, 396, 63, 6815, 8, 277, 304, 267, 372, 408, 199, 442, 2446, 342, 199, 91, 272, 1109, 671, 275, 4337, 709, 27, 272, 2599, 289, 275, 359, 88, 61, 29466, 267, 372, 671, 27, 272, 16735, 339, 372, 289, 342, 1137, 671, 27, 199, 93, 199, 624, 339, 327, 9527, 10965, 272, 327, 2372, 769, 402, 3285, 626, 4293, 18994, 4756, 445, 4176, 845, 2291, 14, 272, 327, 272, 327, 710, 849, 2897, 15194, 626, 949, 3305, 365, 4346, 370, 272, 327, 4756, 445, 4176, 845, 2291, 14, 272, 327, 9527, 10965, 272, 347, 485, 9634, 845, 63, 2469, 8, 277, 304, 267, 372, 942, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 5620, 518, 199, 3, 1898, 6900, 20619, 11098, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 5620, 518, 199, 199, 504, 2897, 492, 11595, 199, 199, 3, 3758, 334, 2588, 3486, 9, 6365, 2897, 199, 533, 3758, 5688, 8, 5688, 304, 272, 347, 636, 826, 721, 277, 12, 1067, 304, 267, 11595, 855, 826, 721, 277, 12, 1067, 9, 339, 327, 9527, 4559, 272, 327, 1432, 511, 2240, 370, 506, 1202, 1380, 7907, 367, 5678, 445, 4176, 845, 272, 327, 2291, 14, 272, 327, 9527, 4559, 272, 347, 485, 67, 1020, 63, 396, 63, 6815, 8, 277, 304, 267, 372, 408, 199, 501, 6601, 2323, 1911, 315, 445, 1020, 14, 199, 3, 2613, 665, 1516, 2245, 14, 72, 30, 199, 3, 2613, 665, 1516, 442, 14, 72, 30, 199, 199, 442, 2446, 342, 199, 91, 272, 2702, 3925, 272, 469, 267, 2155, 330, 27, 420, 5001, 445, 1020, 730, 267, 1109, 284, 27, 267, 3152, 772, 63, 84, 1894, 27, 221, 5001, 445, 1020, 730, 272, 16735, 339, 5001, 29410, 972, 11130, 14, 272, 2702, 3925, 4681, 275, 469, 1275, 66, 275, 3055, 12, 1275, 81, 275, 30151, 772, 63, 4283, 16735, 339, 5001, 8362, 3137, 590, 10038, 901, 14, 272, 372, 4681, 14, 73, 1137, 378, 27, 199, 93, 199, 624, 339, 327, 9527, 10965, 272, 327, 2372, 769, 402, 3285, 626, 4293, 18994, 4756, 445, 1020, 2291, 14, 272, 327, 272, 327, 710, 849, 2897, 15194, 626, 949, 3305, 365, 4346, 370, 272, 327, 4756, 445, 1020, 2291, 14, 272, 327, 9527, 10965, 272, 347, 485, 67, 1020, 63, 2469, 8, 277, 304, 267, 372, 942, 339, 327, 9527, 4559, 272, 327, 1432, 511, 2240, 370, 506, 1202, 1380, 7907, 367, 5678, 445, 4176, 845, 272, 327, 2291, 14, 272, 327, 9527, 4559, 272, 347, 485, 9634, 845, 63, 396, 63, 6815, 8, 277, 304, 267, 372, 408, 199, 442, 2446, 342, 199, 91, 272, 1109, 671, 275, 4337, 709, 27, 272, 2599, 289, 275, 359, 88, 61, 29466, 267, 372, 671, 27, 272, 16735, 339, 372, 289, 342, 1137, 671, 27, 199, 93, 199, 624, 339, 327, 9527, 10965, 272, 327, 2372, 769, 402, 3285, 626, 4293, 18994, 4756, 445, 4176, 845, 2291, 14, 272, 327, 272, 327, 710, 849, 2897, 15194, 626, 949, 3305, 365, 4346, 370, 272, 327, 4756, 445, 4176, 845, 2291, 14, 272, 327, 9527, 10965, 272, 347, 485, 9634, 845, 63, 2469, 8, 277, 304, 267, 372, 942, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
pas256/ansible
lib/ansible/template/safe_eval.py
31
4391
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com> # # 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 ast import sys from ansible.compat.six import string_types from ansible.compat.six.moves import builtins from ansible import constants as C from ansible.plugins import filter_loader, test_loader def safe_eval(expr, locals={}, include_exceptions=False): ''' This is intended for allowing things like: with_items: a_list_variable Where Jinja2 would return a string but we do not want to allow it to call functions (outside of Jinja2, where the env is constrained). If the input data to this function came from an untrusted (remote) source, it should first be run through _clean_data_struct() to ensure the data is further sanitized prior to evaluation. Based on: http://stackoverflow.com/questions/12523516/using-ast-and-whitelists-to-make-pythons-eval-safe ''' # this is the whitelist of AST nodes we are going to # allow in the evaluation. Any node type other than # those listed here will raise an exception in our custom # visitor class defined below. SAFE_NODES = set( ( ast.Add, ast.BinOp, ast.Call, ast.Compare, ast.Dict, ast.Div, ast.Expression, ast.List, ast.Load, ast.Mult, ast.Num, ast.Name, ast.Str, ast.Sub, ast.Tuple, ast.UnaryOp, ) ) # AST node types were expanded after 2.6 if sys.version_info[:2] >= (2, 7): SAFE_NODES.update( set( (ast.Set,) ) ) # And in Python 3.4 too if sys.version_info[:2] >= (3, 4): SAFE_NODES.update( set( (ast.NameConstant,) ) ) filter_list = [] for filter in filter_loader.all(): filter_list.extend(filter.filters().keys()) test_list = [] for test in test_loader.all(): test_list.extend(test.tests().keys()) CALL_WHITELIST = C.DEFAULT_CALLABLE_WHITELIST + filter_list + test_list class CleansingNodeVisitor(ast.NodeVisitor): def generic_visit(self, node, inside_call=False): if type(node) not in SAFE_NODES: raise Exception("invalid expression (%s)" % expr) elif isinstance(node, ast.Call): inside_call = True elif isinstance(node, ast.Name) and inside_call: if hasattr(builtins, node.id) and node.id not in CALL_WHITELIST: raise Exception("invalid function: %s" % node.id) # iterate over all child nodes for child_node in ast.iter_child_nodes(node): self.generic_visit(child_node, inside_call) if not isinstance(expr, string_types): # already templated to a datastructure, perhaps? if include_exceptions: return (expr, None) return expr cnv = CleansingNodeVisitor() try: parsed_tree = ast.parse(expr, mode='eval') cnv.visit(parsed_tree) compiled = compile(parsed_tree, expr, 'eval') result = eval(compiled, {}, dict(locals)) if include_exceptions: return (result, None) else: return result except SyntaxError as e: # special handling for syntax errors, we just return # the expression string back as-is if include_exceptions: return (expr, None) return expr except Exception as e: if include_exceptions: return (expr, e) return expr
gpl-3.0
[ 3, 334, 67, 9, 6029, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 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, 6073, 199, 646, 984, 199, 199, 504, 3242, 14, 5819, 14, 4174, 492, 1059, 63, 1313, 199, 504, 3242, 14, 5819, 14, 4174, 14, 4912, 492, 12963, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 5265, 492, 2457, 63, 3422, 12, 511, 63, 3422, 199, 199, 318, 5048, 63, 2579, 8, 3684, 12, 9480, 10324, 2387, 63, 3924, 29, 797, 304, 272, 1449, 272, 961, 365, 11619, 367, 17266, 7645, 2839, 26, 272, 543, 63, 1744, 26, 282, 63, 513, 63, 1975, 339, 17685, 17300, 18, 3955, 372, 282, 1059, 1325, 781, 886, 440, 2934, 370, 2040, 652, 370, 272, 1240, 3423, 334, 22431, 402, 17300, 18, 12, 2382, 314, 2589, 365, 28483, 680, 982, 272, 314, 1324, 666, 370, 642, 805, 20382, 687, 376, 625, 17549, 334, 3846, 9, 1350, 12, 272, 652, 1077, 1642, 506, 1255, 4012, 485, 3118, 63, 576, 63, 1820, 342, 370, 4868, 314, 666, 272, 365, 9848, 31734, 6791, 370, 11735, 14, 339, 21311, 641, 26, 272, 1455, 921, 23153, 14, 957, 15, 16069, 15, 19364, 1276, 975, 15, 4941, 13, 1810, 13, 460, 13, 7510, 6717, 13, 475, 13, 1875, 13, 1548, 83, 13, 2579, 13, 3489, 272, 1449, 339, 327, 642, 365, 314, 22671, 402, 20788, 3380, 781, 787, 9995, 370, 272, 327, 2040, 315, 314, 11735, 14, 6184, 1031, 730, 1163, 2419, 272, 327, 5204, 10532, 2348, 911, 746, 376, 1919, 315, 4154, 3537, 272, 327, 18040, 1021, 3247, 5084, 14, 272, 13950, 5100, 63, 2826, 4448, 275, 663, 8, 267, 334, 288, 6073, 14, 1123, 12, 288, 6073, 14, 13394, 4619, 12, 288, 6073, 14, 2176, 12, 288, 6073, 14, 16051, 12, 288, 6073, 14, 2141, 12, 288, 6073, 14, 24305, 12, 288, 6073, 14, 9093, 12, 288, 6073, 14, 1296, 12, 288, 6073, 14, 6200, 12, 288, 6073, 14, 30233, 12, 288, 6073, 14, 5667, 12, 288, 6073, 14, 985, 12, 288, 6073, 14, 2848, 12, 288, 6073, 14, 2610, 12, 288, 6073, 14, 7075, 12, 288, 6073, 14, 22401, 4619, 12, 267, 776, 272, 776, 339, 327, 20788, 1031, 2943, 4898, 11507, 2410, 499, 14, 22, 272, 340, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 18, 12, 1520, 304, 267, 13950, 5100, 63, 2826, 4448, 14, 873, 8, 288, 663, 8, 355, 334, 1810, 14, 1084, 4258, 288, 776, 267, 776, 339, 327, 6061, 315, 2018, 650, 14, 20, 4634, 272, 340, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 19, 12, 841, 304, 267, 13950, 5100, 63, 2826, 4448, 14, 873, 8, 288, 663, 8, 355, 334, 1810, 14, 985, 9737, 4258, 288, 776, 267, 776, 339, 2457, 63, 513, 275, 942, 272, 367, 2457, 315, 2457, 63, 3422, 14, 452, 837, 267, 2457, 63, 513, 14, 2880, 8, 1541, 14, 4273, 1252, 1612, 1012, 339, 511, 63, 513, 275, 942, 272, 367, 511, 315, 511, 63, 3422, 14, 452, 837, 267, 511, 63, 513, 14, 2880, 8, 396, 14, 2219, 1252, 1612, 1012, 339, 24251, 63, 18817, 4924, 275, 445, 14, 3472, 63, 11978, 2617, 63, 18817, 4924, 435, 2457, 63, 513, 435, 511, 63, 513, 339, 1021, 445, 274, 796, 316, 1716, 18324, 8, 1810, 14, 1716, 18324, 304, 267, 347, 7809, 63, 5427, 8, 277, 12, 1031, 12, 6272, 63, 1250, 29, 797, 304, 288, 340, 730, 8, 932, 9, 440, 315, 13950, 5100, 63, 2826, 4448, 26, 355, 746, 2186, 480, 3197, 3965, 4366, 83, 2924, 450, 5348, 9, 288, 916, 1228, 8, 932, 12, 6073, 14, 2176, 304, 355, 6272, 63, 1250, 275, 715, 288, 916, 1228, 8, 932, 12, 6073, 14, 985, 9, 436, 6272, 63, 1250, 26, 355, 340, 2688, 8, 10372, 12, 1031, 14, 344, 9, 436, 1031, 14, 344, 440, 315, 24251, 63, 18817, 4924, 26, 490, 746, 2186, 480, 3197, 805, 26, 450, 83, 2, 450, 1031, 14, 344, 9, 288, 327, 13974, 1806, 1006, 1982, 3380, 288, 367, 1982, 63, 932, 315, 6073, 14, 1661, 63, 1739, 63, 2415, 8, 932, 304, 355, 291, 14, 6767, 63, 5427, 8, 1739, 63, 932, 12, 6272, 63, 1250, 9, 339, 340, 440, 1228, 8, 3684, 12, 1059, 63, 1313, 304, 267, 327, 2575, 27960, 370, 282, 666, 6976, 12, 25358, 31, 267, 340, 2387, 63, 3924, 26, 288, 372, 334, 3684, 12, 488, 9, 267, 372, 5348, 339, 286, 15969, 275, 445, 274, 796, 316, 1716, 18324, 342, 272, 862, 26, 267, 4565, 63, 2350, 275, 6073, 14, 1122, 8, 3684, 12, 818, 534, 2579, 358, 267, 286, 15969, 14, 5427, 8, 6751, 63, 2350, 9, 267, 10311, 275, 6555, 8, 6751, 63, 2350, 12, 5348, 12, 283, 2579, 358, 267, 754, 275, 3468, 8, 8427, 12, 5479, 1211, 8, 9350, 430, 398, 340, 2387, 63, 3924, 26, 288, 372, 334, 1099, 12, 488, 9, 267, 587, 26, 288, 372, 754, 272, 871, 12053, 465, 325, 26, 267, 327, 4539, 7252, 367, 6302, 2552, 12, 781, 2951, 372, 267, 327, 314, 3965 ]
[ 334, 67, 9, 6029, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 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, 6073, 199, 646, 984, 199, 199, 504, 3242, 14, 5819, 14, 4174, 492, 1059, 63, 1313, 199, 504, 3242, 14, 5819, 14, 4174, 14, 4912, 492, 12963, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 5265, 492, 2457, 63, 3422, 12, 511, 63, 3422, 199, 199, 318, 5048, 63, 2579, 8, 3684, 12, 9480, 10324, 2387, 63, 3924, 29, 797, 304, 272, 1449, 272, 961, 365, 11619, 367, 17266, 7645, 2839, 26, 272, 543, 63, 1744, 26, 282, 63, 513, 63, 1975, 339, 17685, 17300, 18, 3955, 372, 282, 1059, 1325, 781, 886, 440, 2934, 370, 2040, 652, 370, 272, 1240, 3423, 334, 22431, 402, 17300, 18, 12, 2382, 314, 2589, 365, 28483, 680, 982, 272, 314, 1324, 666, 370, 642, 805, 20382, 687, 376, 625, 17549, 334, 3846, 9, 1350, 12, 272, 652, 1077, 1642, 506, 1255, 4012, 485, 3118, 63, 576, 63, 1820, 342, 370, 4868, 314, 666, 272, 365, 9848, 31734, 6791, 370, 11735, 14, 339, 21311, 641, 26, 272, 1455, 921, 23153, 14, 957, 15, 16069, 15, 19364, 1276, 975, 15, 4941, 13, 1810, 13, 460, 13, 7510, 6717, 13, 475, 13, 1875, 13, 1548, 83, 13, 2579, 13, 3489, 272, 1449, 339, 327, 642, 365, 314, 22671, 402, 20788, 3380, 781, 787, 9995, 370, 272, 327, 2040, 315, 314, 11735, 14, 6184, 1031, 730, 1163, 2419, 272, 327, 5204, 10532, 2348, 911, 746, 376, 1919, 315, 4154, 3537, 272, 327, 18040, 1021, 3247, 5084, 14, 272, 13950, 5100, 63, 2826, 4448, 275, 663, 8, 267, 334, 288, 6073, 14, 1123, 12, 288, 6073, 14, 13394, 4619, 12, 288, 6073, 14, 2176, 12, 288, 6073, 14, 16051, 12, 288, 6073, 14, 2141, 12, 288, 6073, 14, 24305, 12, 288, 6073, 14, 9093, 12, 288, 6073, 14, 1296, 12, 288, 6073, 14, 6200, 12, 288, 6073, 14, 30233, 12, 288, 6073, 14, 5667, 12, 288, 6073, 14, 985, 12, 288, 6073, 14, 2848, 12, 288, 6073, 14, 2610, 12, 288, 6073, 14, 7075, 12, 288, 6073, 14, 22401, 4619, 12, 267, 776, 272, 776, 339, 327, 20788, 1031, 2943, 4898, 11507, 2410, 499, 14, 22, 272, 340, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 18, 12, 1520, 304, 267, 13950, 5100, 63, 2826, 4448, 14, 873, 8, 288, 663, 8, 355, 334, 1810, 14, 1084, 4258, 288, 776, 267, 776, 339, 327, 6061, 315, 2018, 650, 14, 20, 4634, 272, 340, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 19, 12, 841, 304, 267, 13950, 5100, 63, 2826, 4448, 14, 873, 8, 288, 663, 8, 355, 334, 1810, 14, 985, 9737, 4258, 288, 776, 267, 776, 339, 2457, 63, 513, 275, 942, 272, 367, 2457, 315, 2457, 63, 3422, 14, 452, 837, 267, 2457, 63, 513, 14, 2880, 8, 1541, 14, 4273, 1252, 1612, 1012, 339, 511, 63, 513, 275, 942, 272, 367, 511, 315, 511, 63, 3422, 14, 452, 837, 267, 511, 63, 513, 14, 2880, 8, 396, 14, 2219, 1252, 1612, 1012, 339, 24251, 63, 18817, 4924, 275, 445, 14, 3472, 63, 11978, 2617, 63, 18817, 4924, 435, 2457, 63, 513, 435, 511, 63, 513, 339, 1021, 445, 274, 796, 316, 1716, 18324, 8, 1810, 14, 1716, 18324, 304, 267, 347, 7809, 63, 5427, 8, 277, 12, 1031, 12, 6272, 63, 1250, 29, 797, 304, 288, 340, 730, 8, 932, 9, 440, 315, 13950, 5100, 63, 2826, 4448, 26, 355, 746, 2186, 480, 3197, 3965, 4366, 83, 2924, 450, 5348, 9, 288, 916, 1228, 8, 932, 12, 6073, 14, 2176, 304, 355, 6272, 63, 1250, 275, 715, 288, 916, 1228, 8, 932, 12, 6073, 14, 985, 9, 436, 6272, 63, 1250, 26, 355, 340, 2688, 8, 10372, 12, 1031, 14, 344, 9, 436, 1031, 14, 344, 440, 315, 24251, 63, 18817, 4924, 26, 490, 746, 2186, 480, 3197, 805, 26, 450, 83, 2, 450, 1031, 14, 344, 9, 288, 327, 13974, 1806, 1006, 1982, 3380, 288, 367, 1982, 63, 932, 315, 6073, 14, 1661, 63, 1739, 63, 2415, 8, 932, 304, 355, 291, 14, 6767, 63, 5427, 8, 1739, 63, 932, 12, 6272, 63, 1250, 9, 339, 340, 440, 1228, 8, 3684, 12, 1059, 63, 1313, 304, 267, 327, 2575, 27960, 370, 282, 666, 6976, 12, 25358, 31, 267, 340, 2387, 63, 3924, 26, 288, 372, 334, 3684, 12, 488, 9, 267, 372, 5348, 339, 286, 15969, 275, 445, 274, 796, 316, 1716, 18324, 342, 272, 862, 26, 267, 4565, 63, 2350, 275, 6073, 14, 1122, 8, 3684, 12, 818, 534, 2579, 358, 267, 286, 15969, 14, 5427, 8, 6751, 63, 2350, 9, 267, 10311, 275, 6555, 8, 6751, 63, 2350, 12, 5348, 12, 283, 2579, 358, 267, 754, 275, 3468, 8, 8427, 12, 5479, 1211, 8, 9350, 430, 398, 340, 2387, 63, 3924, 26, 288, 372, 334, 1099, 12, 488, 9, 267, 587, 26, 288, 372, 754, 272, 871, 12053, 465, 325, 26, 267, 327, 4539, 7252, 367, 6302, 2552, 12, 781, 2951, 372, 267, 327, 314, 3965, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
BeiLuoShiMen/nupic
tests/integration/nupic/algorithms/knn_classifier_test/categories_test.py
35
3887
#!/usr/bin/env python # ---------------------------------------------------------------------- # Numenta Platform for Intelligent Computing (NuPIC) # Copyright (C) 2014, Numenta, Inc. Unless you have purchased from # Numenta, Inc. a separate commercial license for this software code, the # following terms and conditions apply: # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Affero Public License for more details. # # You should have received a copy of the GNU Affero Public License # along with this program. If not, see http://www.gnu.org/licenses. # # http://numenta.org/licenses/ # ---------------------------------------------------------------------- import logging import unittest2 as unittest import numpy from nupic.algorithms.KNNClassifier import KNNClassifier LOGGER = logging.getLogger(__name__) class KNNCategoriesTest(unittest.TestCase): """Tests how k Nearest Neighbor classifier handles categories""" def testCategories(self): # We need determinism! # # "Life is like a game of cards. The hand you are dealt is determinism; the # way you play it is free will." Jawaharlal Nehru # # What the heck, let's just set the random seed numpy.random.seed(42) failures, _knn = simulateCategories() self.assertEqual(len(failures), 0, "Tests failed: \n" + failures) def simulateCategories(numSamples=100, numDimensions=500): """Simulate running KNN classifier on many disjoint categories""" failures = "" LOGGER.info("Testing the sparse KNN Classifier on many disjoint categories") knn = KNNClassifier(k=1, distanceNorm=1.0, useSparseMemory=True) for i in range(0, numSamples): # select category randomly and generate vector c = 2*numpy.random.randint(0, 50) + 50 v = createPattern(c, numDimensions) knn.learn(v, c) # Go through each category and ensure we have at least one from each! for i in range(0, 50): c = 2*i+50 v = createPattern(c, numDimensions) knn.learn(v, c) errors = 0 for i in range(0, numSamples): # select category randomly and generate vector c = 2*numpy.random.randint(0, 50) + 50 v = createPattern(c, numDimensions) inferCat, _kir, _kd, _kcd = knn.infer(v) if inferCat != c: LOGGER.info("Mistake with %s %s %s %s %s", v[v.nonzero()], \ "mapped to category", inferCat, "instead of category", c) LOGGER.info(" %s", v.nonzero()) errors += 1 if errors != 0: failures += "Failure in handling non-consecutive category indices\n" # Test closest methods errors = 0 for i in range(0, 10): # select category randomly and generate vector c = 2*numpy.random.randint(0, 50) + 50 v = createPattern(c, numDimensions) p = knn.closestTrainingPattern(v, c) if not (c in p.nonzero()[0]): LOGGER.info("Mistake %s %s", p.nonzero(), v.nonzero()) LOGGER.info("%s %s", p[p.nonzero()], v[v.nonzero()]) errors += 1 if errors != 0: failures += "Failure in closestTrainingPattern method\n" return failures, knn def createPattern(c, numDimensions): """ Create a sparse pattern from category c with the given number of dimensions. The pattern is created by setting element c to be a high random number. Element c-1 and c+1 are set to low random numbers. numDimensions must be > c. """ v = numpy.zeros(numDimensions) v[c] = 5*numpy.random.random() + 10 v[c+1] = numpy.random.random() if c > 0: v[c-1] = numpy.random.random() return v if __name__ == "__main__": unittest.main()
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6927, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 15932, 68, 687, 199, 3, 22783, 12, 3277, 14, 282, 7396, 2414, 23012, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 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, 4265, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 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, 199, 3, 1666, 314, 1664, 4265, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 646, 2050, 199, 646, 2882, 18, 465, 2882, 199, 199, 646, 2680, 199, 199, 504, 26084, 14, 24365, 14, 43, 7178, 8508, 492, 1804, 7178, 8508, 199, 199, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 4388, 199, 533, 1804, 46, 6389, 2205, 6112, 774, 8, 2796, 14, 1746, 304, 523, 408, 2925, 4212, 1022, 5612, 9540, 5612, 7201, 12429, 10022, 9695, 624, 8410, 523, 347, 511, 28731, 8, 277, 304, 272, 327, 2136, 1929, 4563, 19185, 1, 272, 327, 272, 327, 298, 22637, 365, 2839, 282, 9219, 402, 27181, 14, 710, 4926, 1265, 787, 477, 4478, 365, 4563, 19185, 27, 314, 272, 327, 4340, 1265, 5232, 652, 365, 2867, 911, 2122, 1603, 65, 758, 8210, 76, 279, 5612, 6271, 85, 272, 327, 272, 327, 14791, 314, 946, 346, 12, 4691, 1159, 2951, 663, 314, 2196, 6347, 272, 2680, 14, 2355, 14, 5176, 8, 2260, 9, 339, 9081, 12, 485, 75, 4411, 275, 20577, 28731, 342, 339, 291, 14, 629, 8, 552, 8, 9968, 395, 378, 12, 2151, 298, 2925, 3405, 26, 971, 78, 2, 435, 9081, 9, 4388, 199, 318, 20577, 28731, 8, 1507, 27665, 29, 1960, 12, 1967, 23370, 29, 5783, 304, 523, 408, 7467, 5434, 3879, 1804, 7178, 12429, 641, 5002, 2153, 10153, 9695, 624, 819, 9081, 275, 3087, 523, 20184, 14, 815, 480, 9029, 314, 5178, 1804, 7178, 8465, 5541, 641, 5002, 2153, 10153, 9695, 531, 523, 1022, 4411, 275, 1804, 7178, 8508, 8, 75, 29, 17, 12, 6033, 15548, 29, 17, 14, 16, 12, 675, 8629, 8628, 29, 549, 9, 819, 367, 284, 315, 1425, 8, 16, 12, 1967, 27665, 304, 339, 327, 3504, 4637, 19311, 436, 3550, 5477, 272, 286, 275, 499, 10, 4714, 14, 2355, 14, 8393, 8, 16, 12, 5238, 9, 435, 5238, 272, 373, 275, 1218, 9959, 8, 67, 12, 1967, 23370, 9, 272, 1022, 4411, 14, 4643, 8, 86, 12, 286, 9, 819, 327, 3971, 4012, 1924, 4637, 436, 4868, 781, 1172, 737, 5210, 1373, 687, 1924, 1, 523, 367, 284, 315, 1425, 8, 16, 12, 5238, 304, 272, 286, 275, 499, 10, 73, 11, 1400, 272, 373, 275, 1218, 9959, 8, 67, 12, 1967, 23370, 9, 272, 1022, 4411, 14, 4643, 8, 86, 12, 286, 9, 819, 2552, 275, 378, 523, 367, 284, 315, 1425, 8, 16, 12, 1967, 27665, 304, 339, 327, 3504, 4637, 19311, 436, 3550, 5477, 272, 286, 275, 499, 10, 4714, 14, 2355, 14, 8393, 8, 16, 12, 5238, 9, 435, 5238, 272, 373, 275, 1218, 9959, 8, 67, 12, 1967, 23370, 9, 339, 18538, 21548, 12, 485, 75, 723, 12, 485, 25606, 12, 485, 75, 2866, 275, 1022, 4411, 14, 14578, 8, 86, 9, 272, 340, 18538, 21548, 1137, 286, 26, 489, 20184, 14, 815, 480, 45, 631, 1728, 543, 450, 83, 450, 83, 450, 83, 450, 83, 450, 83, 401, 373, 59, 86, 14, 10262, 15618, 971, 267, 298, 11663, 370, 4637, 401, 18538, 21548, 12, 298, 23145, 402, 4637, 401, 286, 9, 489, 20184, 14, 815, 480, 257, 450, 83, 401, 373, 14, 10262, 1012, 489, 2552, 847, 413, 523, 340, 2552, 1137, 378, 26, 272, 9081, 847, 298, 6782, 315, 7252, 2222, 13, 388, 19068, 4637, 4918, 60, 78, 2, 819, 327, 1379, 18284, 3102, 523, 2552, 275, 378, 523, 367, 284, 315, 1425, 8, 16, 12, 1616, 304, 339, 327, 3504, 4637, 19311, 436, 3550, 5477, 272, 286, 275, 499, 10, 4714, 14, 2355, 14, 8393, 8, 16, 12, 5238, 9, 435, 5238, 272, 373, 275, 1218, 9959, 8, 67, 12, 1967, 23370, 9, 339, 299, 275, 1022, 4411, 14, 22061, 20463, 9959, 8, 86, 12, 286, 9, 272, 340, 440, 334, 67, 315, 299, 14, 10262, 3430, 16, 4682, 489, 20184, 14, 815, 480, 45, 631, 1728, 450, 83, 450, 83, 401, 299, 14, 10262, 1062, 373, 14, 10262, 1012, 489, 20184, 14, 815, 3647, 83, 450, 83, 401, 299, 59, 80, 14, 10262, 15618, 373, 59, 86, 14, 10262, 9383, 489, 2552, 847, 413, 819, 340, 2552, 1137, 378, 26, 272, 9081, 847, 298, 6782, 315, 18284, 20463, 9959, 1083, 60, 78, 2, 819, 372, 9081, 12, 1022, 4411, 421, 199, 318, 1218, 9959, 8, 67, 12, 1967, 23370, 304, 523, 408, 523, 2790, 282, 5178, 3851, 687, 4637, 286, 543, 314, 1627, 1329, 402, 7365, 14, 523, 710, 3851, 365, 2737, 701, 4260, 1819, 286, 370, 506, 282, 4721, 2196, 1329, 14, 523, 6566, 286, 13, 17, 436, 286, 11, 17, 787, 663, 370, 6465, 2196, 5579, 14, 1967, 23370, 1471, 506, 690, 286, 14, 523, 408, 819, 373, 275, 2680, 14, 4250, 8, 1507, 23370, 9, 523, 373, 59, 67, 61, 275, 959, 10, 4714, 14, 2355, 14, 2355, 342, 435, 1616, 523, 373, 59, 67, 11, 17, 61, 275, 2680, 14, 2355, 14, 2355, 342, 523, 340, 286, 690, 378, 26, 272, 373, 59, 67, 13, 17, 61, 275, 2680, 14, 2355, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6927, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 15932, 68, 687, 199, 3, 22783, 12, 3277, 14, 282, 7396, 2414, 23012, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 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, 4265, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 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, 199, 3, 1666, 314, 1664, 4265, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 646, 2050, 199, 646, 2882, 18, 465, 2882, 199, 199, 646, 2680, 199, 199, 504, 26084, 14, 24365, 14, 43, 7178, 8508, 492, 1804, 7178, 8508, 199, 199, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 4388, 199, 533, 1804, 46, 6389, 2205, 6112, 774, 8, 2796, 14, 1746, 304, 523, 408, 2925, 4212, 1022, 5612, 9540, 5612, 7201, 12429, 10022, 9695, 624, 8410, 523, 347, 511, 28731, 8, 277, 304, 272, 327, 2136, 1929, 4563, 19185, 1, 272, 327, 272, 327, 298, 22637, 365, 2839, 282, 9219, 402, 27181, 14, 710, 4926, 1265, 787, 477, 4478, 365, 4563, 19185, 27, 314, 272, 327, 4340, 1265, 5232, 652, 365, 2867, 911, 2122, 1603, 65, 758, 8210, 76, 279, 5612, 6271, 85, 272, 327, 272, 327, 14791, 314, 946, 346, 12, 4691, 1159, 2951, 663, 314, 2196, 6347, 272, 2680, 14, 2355, 14, 5176, 8, 2260, 9, 339, 9081, 12, 485, 75, 4411, 275, 20577, 28731, 342, 339, 291, 14, 629, 8, 552, 8, 9968, 395, 378, 12, 2151, 298, 2925, 3405, 26, 971, 78, 2, 435, 9081, 9, 4388, 199, 318, 20577, 28731, 8, 1507, 27665, 29, 1960, 12, 1967, 23370, 29, 5783, 304, 523, 408, 7467, 5434, 3879, 1804, 7178, 12429, 641, 5002, 2153, 10153, 9695, 624, 819, 9081, 275, 3087, 523, 20184, 14, 815, 480, 9029, 314, 5178, 1804, 7178, 8465, 5541, 641, 5002, 2153, 10153, 9695, 531, 523, 1022, 4411, 275, 1804, 7178, 8508, 8, 75, 29, 17, 12, 6033, 15548, 29, 17, 14, 16, 12, 675, 8629, 8628, 29, 549, 9, 819, 367, 284, 315, 1425, 8, 16, 12, 1967, 27665, 304, 339, 327, 3504, 4637, 19311, 436, 3550, 5477, 272, 286, 275, 499, 10, 4714, 14, 2355, 14, 8393, 8, 16, 12, 5238, 9, 435, 5238, 272, 373, 275, 1218, 9959, 8, 67, 12, 1967, 23370, 9, 272, 1022, 4411, 14, 4643, 8, 86, 12, 286, 9, 819, 327, 3971, 4012, 1924, 4637, 436, 4868, 781, 1172, 737, 5210, 1373, 687, 1924, 1, 523, 367, 284, 315, 1425, 8, 16, 12, 5238, 304, 272, 286, 275, 499, 10, 73, 11, 1400, 272, 373, 275, 1218, 9959, 8, 67, 12, 1967, 23370, 9, 272, 1022, 4411, 14, 4643, 8, 86, 12, 286, 9, 819, 2552, 275, 378, 523, 367, 284, 315, 1425, 8, 16, 12, 1967, 27665, 304, 339, 327, 3504, 4637, 19311, 436, 3550, 5477, 272, 286, 275, 499, 10, 4714, 14, 2355, 14, 8393, 8, 16, 12, 5238, 9, 435, 5238, 272, 373, 275, 1218, 9959, 8, 67, 12, 1967, 23370, 9, 339, 18538, 21548, 12, 485, 75, 723, 12, 485, 25606, 12, 485, 75, 2866, 275, 1022, 4411, 14, 14578, 8, 86, 9, 272, 340, 18538, 21548, 1137, 286, 26, 489, 20184, 14, 815, 480, 45, 631, 1728, 543, 450, 83, 450, 83, 450, 83, 450, 83, 450, 83, 401, 373, 59, 86, 14, 10262, 15618, 971, 267, 298, 11663, 370, 4637, 401, 18538, 21548, 12, 298, 23145, 402, 4637, 401, 286, 9, 489, 20184, 14, 815, 480, 257, 450, 83, 401, 373, 14, 10262, 1012, 489, 2552, 847, 413, 523, 340, 2552, 1137, 378, 26, 272, 9081, 847, 298, 6782, 315, 7252, 2222, 13, 388, 19068, 4637, 4918, 60, 78, 2, 819, 327, 1379, 18284, 3102, 523, 2552, 275, 378, 523, 367, 284, 315, 1425, 8, 16, 12, 1616, 304, 339, 327, 3504, 4637, 19311, 436, 3550, 5477, 272, 286, 275, 499, 10, 4714, 14, 2355, 14, 8393, 8, 16, 12, 5238, 9, 435, 5238, 272, 373, 275, 1218, 9959, 8, 67, 12, 1967, 23370, 9, 339, 299, 275, 1022, 4411, 14, 22061, 20463, 9959, 8, 86, 12, 286, 9, 272, 340, 440, 334, 67, 315, 299, 14, 10262, 3430, 16, 4682, 489, 20184, 14, 815, 480, 45, 631, 1728, 450, 83, 450, 83, 401, 299, 14, 10262, 1062, 373, 14, 10262, 1012, 489, 20184, 14, 815, 3647, 83, 450, 83, 401, 299, 59, 80, 14, 10262, 15618, 373, 59, 86, 14, 10262, 9383, 489, 2552, 847, 413, 819, 340, 2552, 1137, 378, 26, 272, 9081, 847, 298, 6782, 315, 18284, 20463, 9959, 1083, 60, 78, 2, 819, 372, 9081, 12, 1022, 4411, 421, 199, 318, 1218, 9959, 8, 67, 12, 1967, 23370, 304, 523, 408, 523, 2790, 282, 5178, 3851, 687, 4637, 286, 543, 314, 1627, 1329, 402, 7365, 14, 523, 710, 3851, 365, 2737, 701, 4260, 1819, 286, 370, 506, 282, 4721, 2196, 1329, 14, 523, 6566, 286, 13, 17, 436, 286, 11, 17, 787, 663, 370, 6465, 2196, 5579, 14, 1967, 23370, 1471, 506, 690, 286, 14, 523, 408, 819, 373, 275, 2680, 14, 4250, 8, 1507, 23370, 9, 523, 373, 59, 67, 61, 275, 959, 10, 4714, 14, 2355, 14, 2355, 342, 435, 1616, 523, 373, 59, 67, 11, 17, 61, 275, 2680, 14, 2355, 14, 2355, 342, 523, 340, 286, 690, 378, 26, 272, 373, 59, 67, 13, 17, 61, 275, 2680, 14, 2355, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
jerryblakley/libcloud
libcloud/test/compute/test_voxel.py
46
6165
# 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 sys import unittest from libcloud.utils.py3 import httplib from libcloud.compute.base import Node, NodeSize, NodeImage, NodeLocation from libcloud.compute.drivers.voxel import VoxelNodeDriver as Voxel from libcloud.compute.types import InvalidCredsError from libcloud.test import MockHttp from libcloud.test.file_fixtures import ComputeFileFixtures from libcloud.test.secrets import VOXEL_PARAMS class VoxelTest(unittest.TestCase): def setUp(self): Voxel.connectionCls.conn_classes = (None, VoxelMockHttp) VoxelMockHttp.type = None self.driver = Voxel(*VOXEL_PARAMS) def test_auth_failed(self): VoxelMockHttp.type = 'UNAUTHORIZED' try: self.driver.list_nodes() except Exception: e = sys.exc_info()[1] self.assertTrue(isinstance(e, InvalidCredsError)) else: self.fail('test should have thrown') def test_response_failure(self): VoxelMockHttp.type = 'FAILURE' try: self.driver.list_nodes() except Exception: pass else: self.fail('Invalid response, but exception was not thrown') def test_list_nodes(self): VoxelMockHttp.type = 'LIST_NODES' nodes = self.driver.list_nodes() self.assertEqual(len(nodes), 1) self.assertEqual(nodes[0].name, 'www.voxel.net') def test_list_sizes(self): sizes = self.driver.list_sizes() self.assertEqual(len(sizes), 13) def test_list_images(self): VoxelMockHttp.type = 'LIST_IMAGES' images = self.driver.list_images() self.assertEqual(len(images), 1) def test_list_locations(self): VoxelMockHttp.type = 'LIST_LOCATIONS' locations = self.driver.list_locations() self.assertEqual(len(locations), 2) self.assertEqual(locations[0].name, 'Amsterdam') def test_create_node_invalid_disk_size(self): image = NodeImage( id=1, name='Ubuntu 8.10 (intrepid)', driver=self.driver) size = NodeSize( 1, '256 slice', None, None, None, None, driver=self.driver) location = NodeLocation(id=1, name='Europe', country='England', driver=self.driver) try: self.driver.create_node(name='foo', image=image, size=size, location=location) except ValueError: pass else: self.fail('Invalid disk size provided but an exception was not' ' thrown') def test_create_node(self): VoxelMockHttp.type = 'CREATE_NODE' image = NodeImage( id=1, name='Ubuntu 8.10 (intrepid)', driver=self.driver) size = NodeSize( 1, '256 slice', 1024, 500, None, None, driver=self.driver) location = NodeLocation(id=1, name='Europe', country='England', driver=self.driver) node = self.driver.create_node(name='foo', image=image, size=size, location=location) self.assertEqual(node.id, '1234') node = self.driver.create_node(name='foo', image=image, size=size, location=location, voxel_access=True) self.assertEqual(node.id, '1234') def test_reboot_node(self): VoxelMockHttp.type = 'REBOOT_NODE' node = Node( id=72258, name=None, state=None, public_ips=None, private_ips=None, driver=self.driver) self.assertTrue(node.reboot()) def test_destroy_node(self): VoxelMockHttp.type = 'DESTROY_NODE' node = Node( id=72258, name=None, state=None, public_ips=None, private_ips=None, driver=self.driver) self.assertTrue(node.destroy()) class VoxelMockHttp(MockHttp): fixtures = ComputeFileFixtures('voxel') def _UNAUTHORIZED(self, method, url, body, headers): body = self.fixtures.load('unauthorized.xml') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _FAILURE(self, method, url, body, headers): body = self.fixtures.load('failure.xml') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _LIST_NODES(self, method, url, body, headers): body = self.fixtures.load('nodes.xml') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _LIST_IMAGES(self, method, url, body, headers): body = self.fixtures.load('images.xml') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _LIST_LOCATIONS(self, method, url, body, headers): body = self.fixtures.load('locations.xml') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _CREATE_NODE(self, method, url, body, headers): body = self.fixtures.load('create_node.xml') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _REBOOT_NODE(self, method, url, body, headers): body = self.fixtures.load('success.xml') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _DESTROY_NODE(self, method, url, body, headers): body = self.fixtures.load('success.xml') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) if __name__ == '__main__': sys.exit(unittest.main())
apache-2.0
[ 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, 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, 646, 984, 199, 646, 2882, 199, 504, 17069, 14, 1208, 14, 647, 19, 492, 8809, 199, 199, 504, 17069, 14, 3357, 14, 1095, 492, 5013, 12, 5013, 2320, 12, 5013, 3491, 12, 5013, 6592, 199, 504, 17069, 14, 3357, 14, 13337, 14, 2392, 31418, 492, 812, 19131, 352, 1716, 6158, 465, 812, 19131, 352, 199, 504, 17069, 14, 3357, 14, 1313, 492, 6378, 35, 10428, 547, 199, 199, 504, 17069, 14, 396, 492, 4420, 5779, 199, 504, 17069, 14, 396, 14, 493, 63, 8769, 492, 8354, 1173, 9047, 6969, 199, 199, 504, 17069, 14, 396, 14, 16153, 492, 812, 29544, 2901, 63, 17978, 421, 199, 533, 812, 19131, 352, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 398, 812, 19131, 352, 14, 2105, 24342, 14, 1631, 63, 2888, 275, 334, 403, 12, 812, 19131, 352, 3346, 5779, 9, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 488, 267, 291, 14, 3090, 275, 812, 19131, 352, 2031, 10662, 56, 2901, 63, 17978, 9, 339, 347, 511, 63, 1178, 63, 4892, 8, 277, 304, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 283, 1734, 25303, 1149, 7, 267, 862, 26, 288, 291, 14, 3090, 14, 513, 63, 2415, 342, 267, 871, 2186, 26, 288, 325, 275, 984, 14, 2804, 63, 815, 3430, 17, 61, 288, 291, 14, 1815, 8, 6074, 8, 69, 12, 6378, 35, 10428, 547, 430, 267, 587, 26, 288, 291, 14, 1633, 360, 396, 1077, 1172, 14031, 358, 339, 347, 511, 63, 1310, 63, 5328, 8, 277, 304, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 283, 13989, 7, 398, 862, 26, 288, 291, 14, 3090, 14, 513, 63, 2415, 342, 267, 871, 2186, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1633, 360, 3364, 1177, 12, 1325, 1919, 1990, 440, 14031, 358, 339, 347, 511, 63, 513, 63, 2415, 8, 277, 304, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 283, 4924, 63, 2826, 4448, 7, 267, 3380, 275, 291, 14, 3090, 14, 513, 63, 2415, 342, 398, 291, 14, 629, 8, 552, 8, 2415, 395, 413, 9, 267, 291, 14, 629, 8, 2415, 59, 16, 1055, 354, 12, 283, 1544, 14, 2392, 31418, 14, 846, 358, 339, 347, 511, 63, 513, 63, 7723, 8, 277, 304, 267, 10627, 275, 291, 14, 3090, 14, 513, 63, 7723, 342, 398, 291, 14, 629, 8, 552, 8, 7723, 395, 4944, 9, 339, 347, 511, 63, 513, 63, 4782, 8, 277, 304, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 283, 4924, 63, 1469, 5383, 7, 267, 5935, 275, 291, 14, 3090, 14, 513, 63, 4782, 342, 398, 291, 14, 629, 8, 552, 8, 4782, 395, 413, 9, 339, 347, 511, 63, 513, 63, 8022, 8, 277, 304, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 283, 4924, 63, 5752, 12969, 7, 267, 9918, 275, 291, 14, 3090, 14, 513, 63, 8022, 342, 398, 291, 14, 629, 8, 552, 8, 8022, 395, 499, 9, 267, 291, 14, 629, 8, 8022, 59, 16, 1055, 354, 12, 283, 33, 706, 351, 68, 455, 358, 339, 347, 511, 63, 981, 63, 932, 63, 3197, 63, 4032, 63, 890, 8, 277, 304, 267, 1834, 275, 5013, 3491, 8, 288, 1305, 29, 17, 12, 536, 534, 53, 19313, 1695, 14, 709, 334, 442, 1155, 344, 3196, 5253, 29, 277, 14, 3090, 9, 267, 1568, 275, 5013, 2320, 8, 288, 413, 12, 283, 3912, 6014, 297, 488, 12, 488, 12, 488, 12, 488, 12, 5253, 29, 277, 14, 3090, 9, 267, 2909, 275, 5013, 6592, 8, 344, 29, 17, 12, 536, 534, 15201, 297, 9023, 534, 1327, 3528, 460, 297, 1816, 5253, 29, 277, 14, 3090, 9, 398, 862, 26, 288, 291, 14, 3090, 14, 981, 63, 932, 8, 354, 534, 1421, 297, 1834, 29, 1569, 12, 1568, 29, 890, 12, 2511, 2909, 29, 1985, 9, 267, 871, 1722, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1633, 360, 3364, 4543, 1568, 2741, 1325, 376, 1919, 1990, 440, 7, 1993, 283, 14031, 358, 339, 347, 511, 63, 981, 63, 932, 8, 277, 304, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 283, 8366, 63, 8063, 7, 267, 1834, 275, 5013, 3491, 8, 288, 1305, 29, 17, 12, 536, 534, 53, 19313, 1695, 14, 709, 334, 442, 1155, 344, 3196, 5253, 29, 277, 14, 3090, 9, 267, 1568, 275, 5013, 2320, 8, 288, 413, 12, 283, 3912, 6014, 297, 6619, 12, 6891, 12, 488, 12, 488, 12, 5253, 29, 277, 14, 3090, 9, 267, 2909, 275, 5013, 6592, 8, 344, 29, 17, 12, 536, 534, 15201, 297, 9023, 534, 1327, 3528, 460, 297, 1816, 5253, 29, 277, 14, 3090, 9, 398, 1031, 275, 291, 14, 3090, 14, 981, 63, 932, 8, 354, 534, 1421, 297, 1834, 29, 1569, 12, 1568, 29, 890, 12, 4318, 2909, 29, 1985, 9, 267, 291, 14, 629, 8, 932, 14, 344, 12, 283, 4321, 358, 398, 1031, 275, 291, 14, 3090, 14, 981, 63, 932, 8, 354, 534, 1421, 297, 1834, 29, 1569, 12, 1568, 29, 890, 12, 4318, 2909, 29, 1985, 12, 14164, 31418, 63, 2732, 29, 549 ]
[ 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, 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, 646, 984, 199, 646, 2882, 199, 504, 17069, 14, 1208, 14, 647, 19, 492, 8809, 199, 199, 504, 17069, 14, 3357, 14, 1095, 492, 5013, 12, 5013, 2320, 12, 5013, 3491, 12, 5013, 6592, 199, 504, 17069, 14, 3357, 14, 13337, 14, 2392, 31418, 492, 812, 19131, 352, 1716, 6158, 465, 812, 19131, 352, 199, 504, 17069, 14, 3357, 14, 1313, 492, 6378, 35, 10428, 547, 199, 199, 504, 17069, 14, 396, 492, 4420, 5779, 199, 504, 17069, 14, 396, 14, 493, 63, 8769, 492, 8354, 1173, 9047, 6969, 199, 199, 504, 17069, 14, 396, 14, 16153, 492, 812, 29544, 2901, 63, 17978, 421, 199, 533, 812, 19131, 352, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 398, 812, 19131, 352, 14, 2105, 24342, 14, 1631, 63, 2888, 275, 334, 403, 12, 812, 19131, 352, 3346, 5779, 9, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 488, 267, 291, 14, 3090, 275, 812, 19131, 352, 2031, 10662, 56, 2901, 63, 17978, 9, 339, 347, 511, 63, 1178, 63, 4892, 8, 277, 304, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 283, 1734, 25303, 1149, 7, 267, 862, 26, 288, 291, 14, 3090, 14, 513, 63, 2415, 342, 267, 871, 2186, 26, 288, 325, 275, 984, 14, 2804, 63, 815, 3430, 17, 61, 288, 291, 14, 1815, 8, 6074, 8, 69, 12, 6378, 35, 10428, 547, 430, 267, 587, 26, 288, 291, 14, 1633, 360, 396, 1077, 1172, 14031, 358, 339, 347, 511, 63, 1310, 63, 5328, 8, 277, 304, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 283, 13989, 7, 398, 862, 26, 288, 291, 14, 3090, 14, 513, 63, 2415, 342, 267, 871, 2186, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1633, 360, 3364, 1177, 12, 1325, 1919, 1990, 440, 14031, 358, 339, 347, 511, 63, 513, 63, 2415, 8, 277, 304, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 283, 4924, 63, 2826, 4448, 7, 267, 3380, 275, 291, 14, 3090, 14, 513, 63, 2415, 342, 398, 291, 14, 629, 8, 552, 8, 2415, 395, 413, 9, 267, 291, 14, 629, 8, 2415, 59, 16, 1055, 354, 12, 283, 1544, 14, 2392, 31418, 14, 846, 358, 339, 347, 511, 63, 513, 63, 7723, 8, 277, 304, 267, 10627, 275, 291, 14, 3090, 14, 513, 63, 7723, 342, 398, 291, 14, 629, 8, 552, 8, 7723, 395, 4944, 9, 339, 347, 511, 63, 513, 63, 4782, 8, 277, 304, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 283, 4924, 63, 1469, 5383, 7, 267, 5935, 275, 291, 14, 3090, 14, 513, 63, 4782, 342, 398, 291, 14, 629, 8, 552, 8, 4782, 395, 413, 9, 339, 347, 511, 63, 513, 63, 8022, 8, 277, 304, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 283, 4924, 63, 5752, 12969, 7, 267, 9918, 275, 291, 14, 3090, 14, 513, 63, 8022, 342, 398, 291, 14, 629, 8, 552, 8, 8022, 395, 499, 9, 267, 291, 14, 629, 8, 8022, 59, 16, 1055, 354, 12, 283, 33, 706, 351, 68, 455, 358, 339, 347, 511, 63, 981, 63, 932, 63, 3197, 63, 4032, 63, 890, 8, 277, 304, 267, 1834, 275, 5013, 3491, 8, 288, 1305, 29, 17, 12, 536, 534, 53, 19313, 1695, 14, 709, 334, 442, 1155, 344, 3196, 5253, 29, 277, 14, 3090, 9, 267, 1568, 275, 5013, 2320, 8, 288, 413, 12, 283, 3912, 6014, 297, 488, 12, 488, 12, 488, 12, 488, 12, 5253, 29, 277, 14, 3090, 9, 267, 2909, 275, 5013, 6592, 8, 344, 29, 17, 12, 536, 534, 15201, 297, 9023, 534, 1327, 3528, 460, 297, 1816, 5253, 29, 277, 14, 3090, 9, 398, 862, 26, 288, 291, 14, 3090, 14, 981, 63, 932, 8, 354, 534, 1421, 297, 1834, 29, 1569, 12, 1568, 29, 890, 12, 2511, 2909, 29, 1985, 9, 267, 871, 1722, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1633, 360, 3364, 4543, 1568, 2741, 1325, 376, 1919, 1990, 440, 7, 1993, 283, 14031, 358, 339, 347, 511, 63, 981, 63, 932, 8, 277, 304, 267, 812, 19131, 352, 3346, 5779, 14, 466, 275, 283, 8366, 63, 8063, 7, 267, 1834, 275, 5013, 3491, 8, 288, 1305, 29, 17, 12, 536, 534, 53, 19313, 1695, 14, 709, 334, 442, 1155, 344, 3196, 5253, 29, 277, 14, 3090, 9, 267, 1568, 275, 5013, 2320, 8, 288, 413, 12, 283, 3912, 6014, 297, 6619, 12, 6891, 12, 488, 12, 488, 12, 5253, 29, 277, 14, 3090, 9, 267, 2909, 275, 5013, 6592, 8, 344, 29, 17, 12, 536, 534, 15201, 297, 9023, 534, 1327, 3528, 460, 297, 1816, 5253, 29, 277, 14, 3090, 9, 398, 1031, 275, 291, 14, 3090, 14, 981, 63, 932, 8, 354, 534, 1421, 297, 1834, 29, 1569, 12, 1568, 29, 890, 12, 4318, 2909, 29, 1985, 9, 267, 291, 14, 629, 8, 932, 14, 344, 12, 283, 4321, 358, 398, 1031, 275, 291, 14, 3090, 14, 981, 63, 932, 8, 354, 534, 1421, 297, 1834, 29, 1569, 12, 1568, 29, 890, 12, 4318, 2909, 29, 1985, 12, 14164, 31418, 63, 2732, 29, 549, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Shatki/PyIMU
test/magnetosphere.py
1
1580
from mpl_toolkits.mplot3d import axes3d import numpy as np import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation from socket import * import time # Объявляем все глобальные переменные HOST = '192.168.0.76' PORT = 21566 BUFSIZ = 512 ADDR = (HOST, PORT) bad_packet = 0 good_packet = 0 # fig, ax = plt.subplots() fig = plt.figure() ax = fig.add_subplot(111, projection='3d') # Socket # tcpCliSock = socket(AF_INET, SOCK_STREAM) # tcpCliSock.connect(ADDR) # Запрет на ожидание plt.ion() tstart = time.time() # real-time plotting loop X, Y, Z = [], [], [] while True: try: # читаем данные из сети tcpCliSock.c data = tcpCliSock.recv(BUFSIZ) if data: print(len(X), data) data = data.decode().split(',') if len(data) == 9: # print('Data received', data) # tcpCliSock.send(b'Ok') good_packet += 1 else: bad_packet += 1 # читаем данные из сети data = tcpCliSock.recv(BUFSIZ) X.append(data[0]) Y.append(data[1]) Z.append(data[2]) frame = ax.scatter(X, Y, Z, c='b', marker='o') # Remove old line collection before drawing #if oldcol is not None: # ax.collections.remove(oldcol) plt.pause(0.001 / len(X)) except KeyboardInterrupt: tcpCliSock.close() print('FPS: %f' % (len(X) / (time.time() - tstart))) break
gpl-3.0
[ 504, 22513, 63, 3557, 75, 1405, 14, 311, 1653, 19, 68, 492, 7824, 19, 68, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 8027, 14, 22228, 492, 28794, 15957, 199, 504, 2838, 492, 627, 199, 646, 900, 199, 199, 3, 7038, 253, 141, 110, 142, 233, 14978, 19630, 10356, 14978, 15578, 121, 22213, 8474, 6286, 7038, 112, 10356, 8381, 110, 30638, 16961, 7592, 17445, 6286, 19820, 21273, 15578, 121, 18624, 7592, 17445, 6286, 199, 199, 5449, 275, 283, 5756, 14, 6568, 14, 16, 14, 2114, 7, 199, 3657, 275, 28436, 1272, 199, 21323, 2684, 58, 275, 10574, 199, 7803, 275, 334, 5449, 12, 25562, 9, 199, 199, 4087, 63, 6253, 275, 378, 199, 8302, 63, 6253, 275, 378, 199, 3, 6085, 12, 2185, 275, 4488, 14, 21430, 342, 199, 199, 592, 275, 4488, 14, 8941, 342, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 6673, 12, 14777, 534, 19, 68, 358, 199, 199, 3, 17766, 199, 3, 14719, 20653, 51, 766, 275, 2838, 8, 5699, 63, 11367, 12, 26327, 63, 9484, 9, 199, 3, 14719, 20653, 51, 766, 14, 2242, 8, 7803, 9, 199, 3, 7038, 246, 13111, 124, 7753, 30160, 24917, 5657, 221, 8381, 115, 16863, 113, 21674, 6500, 6286, 199, 6003, 14, 1636, 342, 199, 199, 84, 928, 275, 900, 14, 521, 342, 199, 3, 3363, 13, 521, 25174, 4438, 199, 199, 56, 12, 1488, 12, 3107, 275, 990, 990, 942, 199, 199, 6710, 715, 26, 272, 862, 26, 267, 327, 221, 19277, 30019, 5657, 15578, 121, 29562, 21674, 7592, 17445, 6286, 221, 16863, 116, 24071, 30160, 6500, 267, 14719, 20653, 51, 766, 14, 67, 267, 666, 275, 14719, 20653, 51, 766, 14, 7637, 8, 21323, 2684, 58, 9, 267, 340, 666, 26, 288, 870, 8, 552, 8, 56, 395, 666, 9, 288, 666, 275, 666, 14, 2708, 1252, 1294, 11917, 288, 340, 822, 8, 576, 9, 508, 1749, 26, 355, 327, 870, 360, 1451, 3086, 297, 666, 9, 355, 327, 14719, 20653, 51, 766, 14, 2254, 8, 66, 7, 11622, 358, 2234, 6954, 63, 6253, 847, 413, 288, 587, 26, 355, 4875, 63, 6253, 847, 413, 398, 327, 221, 19277, 30019, 5657, 15578, 121, 29562, 21674, 7592, 17445, 6286, 221, 16863, 116, 24071, 30160, 6500, 267, 666, 275, 14719, 20653, 51, 766, 14, 7637, 8, 21323, 2684, 58, 9, 267, 1323, 14, 740, 8, 576, 59, 16, 566, 267, 1488, 14, 740, 8, 576, 59, 17, 566, 267, 3107, 14, 740, 8, 576, 59, 18, 566, 398, 2787, 275, 2185, 14, 13512, 8, 56, 12, 1488, 12, 3107, 12, 286, 534, 66, 297, 3608, 534, 79, 358, 398, 327, 5852, 2269, 1004, 3245, 2544, 17455, 267, 327, 692, 2269, 761, 365, 440, 488, 26, 267, 327, 259, 2185, 14, 7882, 14, 2168, 8, 1753, 761, 9, 398, 4488, 14, 11241, 8, 16, 14, 4587, 1182, 822, 8, 56, 430, 2378, 871, 13483, 26, 267, 14719, 20653, 51, 766, 14, 1600, 342, 267, 870, 360, 38, 5067, 26, 450, 70, 7, 450, 334, 552, 8, 56, 9, 1182, 334, 521, 14, 521, 342, 446, 29921, 1724, 267, 2059, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 22513, 63, 3557, 75, 1405, 14, 311, 1653, 19, 68, 492, 7824, 19, 68, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 8027, 14, 22228, 492, 28794, 15957, 199, 504, 2838, 492, 627, 199, 646, 900, 199, 199, 3, 7038, 253, 141, 110, 142, 233, 14978, 19630, 10356, 14978, 15578, 121, 22213, 8474, 6286, 7038, 112, 10356, 8381, 110, 30638, 16961, 7592, 17445, 6286, 19820, 21273, 15578, 121, 18624, 7592, 17445, 6286, 199, 199, 5449, 275, 283, 5756, 14, 6568, 14, 16, 14, 2114, 7, 199, 3657, 275, 28436, 1272, 199, 21323, 2684, 58, 275, 10574, 199, 7803, 275, 334, 5449, 12, 25562, 9, 199, 199, 4087, 63, 6253, 275, 378, 199, 8302, 63, 6253, 275, 378, 199, 3, 6085, 12, 2185, 275, 4488, 14, 21430, 342, 199, 199, 592, 275, 4488, 14, 8941, 342, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 6673, 12, 14777, 534, 19, 68, 358, 199, 199, 3, 17766, 199, 3, 14719, 20653, 51, 766, 275, 2838, 8, 5699, 63, 11367, 12, 26327, 63, 9484, 9, 199, 3, 14719, 20653, 51, 766, 14, 2242, 8, 7803, 9, 199, 3, 7038, 246, 13111, 124, 7753, 30160, 24917, 5657, 221, 8381, 115, 16863, 113, 21674, 6500, 6286, 199, 6003, 14, 1636, 342, 199, 199, 84, 928, 275, 900, 14, 521, 342, 199, 3, 3363, 13, 521, 25174, 4438, 199, 199, 56, 12, 1488, 12, 3107, 275, 990, 990, 942, 199, 199, 6710, 715, 26, 272, 862, 26, 267, 327, 221, 19277, 30019, 5657, 15578, 121, 29562, 21674, 7592, 17445, 6286, 221, 16863, 116, 24071, 30160, 6500, 267, 14719, 20653, 51, 766, 14, 67, 267, 666, 275, 14719, 20653, 51, 766, 14, 7637, 8, 21323, 2684, 58, 9, 267, 340, 666, 26, 288, 870, 8, 552, 8, 56, 395, 666, 9, 288, 666, 275, 666, 14, 2708, 1252, 1294, 11917, 288, 340, 822, 8, 576, 9, 508, 1749, 26, 355, 327, 870, 360, 1451, 3086, 297, 666, 9, 355, 327, 14719, 20653, 51, 766, 14, 2254, 8, 66, 7, 11622, 358, 2234, 6954, 63, 6253, 847, 413, 288, 587, 26, 355, 4875, 63, 6253, 847, 413, 398, 327, 221, 19277, 30019, 5657, 15578, 121, 29562, 21674, 7592, 17445, 6286, 221, 16863, 116, 24071, 30160, 6500, 267, 666, 275, 14719, 20653, 51, 766, 14, 7637, 8, 21323, 2684, 58, 9, 267, 1323, 14, 740, 8, 576, 59, 16, 566, 267, 1488, 14, 740, 8, 576, 59, 17, 566, 267, 3107, 14, 740, 8, 576, 59, 18, 566, 398, 2787, 275, 2185, 14, 13512, 8, 56, 12, 1488, 12, 3107, 12, 286, 534, 66, 297, 3608, 534, 79, 358, 398, 327, 5852, 2269, 1004, 3245, 2544, 17455, 267, 327, 692, 2269, 761, 365, 440, 488, 26, 267, 327, 259, 2185, 14, 7882, 14, 2168, 8, 1753, 761, 9, 398, 4488, 14, 11241, 8, 16, 14, 4587, 1182, 822, 8, 56, 430, 2378, 871, 13483, 26, 267, 14719, 20653, 51, 766, 14, 1600, 342, 267, 870, 360, 38, 5067, 26, 450, 70, 7, 450, 334, 552, 8, 56, 9, 1182, 334, 521, 14, 521, 342, 446, 29921, 1724, 267, 2059, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
embray/astropy_helpers
setup.py
1
2069
#!/usr/bin/env python # Licensed under a 3-clause BSD style license - see LICENSE.rst import ah_bootstrap import pkg_resources from setuptools import setup from astropy_helpers.setup_helpers import register_commands, get_package_info from astropy_helpers.version_helpers import generate_version_py NAME = 'astropy_helpers' VERSION = '1.1.dev' RELEASE = 'dev' not in VERSION DOWNLOAD_BASE_URL = 'http://pypi.python.org/packages/source/a/astropy-helpers' generate_version_py(NAME, VERSION, RELEASE, False, uses_git=not RELEASE) # Use the updated version including the git rev count from astropy_helpers.version import version as VERSION cmdclass = register_commands(NAME, VERSION, RELEASE) # This package actually doesn't use the Astropy test command del cmdclass['test'] setup( name=pkg_resources.safe_name(NAME), # astropy_helpers -> astropy-helpers version=VERSION, description='Utilities for building and installing Astropy, Astropy ' 'affiliated packages, and their respective documentation.', author='The Astropy Developers', author_email='astropy.team@gmail.com', license='BSD', url='http://astropy.org', long_description=open('README.rst').read(), download_url='{0}/astropy-helpers-{1}.tar.gz'.format(DOWNLOAD_BASE_URL, VERSION), classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Framework :: Setuptools Plugin', 'Framework :: Sphinx :: Extension', 'Framework :: Sphinx :: Theme', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Topic :: Software Development :: Build Tools', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: System :: Archiving :: Packaging' ], cmdclass=cmdclass, zip_safe=False, **get_package_info(exclude=['astropy_helpers.tests']) )
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 3909, 1334, 282, 650, 13, 8501, 6289, 3449, 4190, 446, 1937, 5113, 14, 8332, 199, 199, 646, 282, 72, 63, 11146, 199, 646, 5496, 63, 4435, 199, 504, 9116, 492, 3272, 199, 504, 28753, 63, 7546, 14, 2758, 63, 7546, 492, 2274, 63, 4405, 12, 664, 63, 2491, 63, 815, 199, 504, 28753, 63, 7546, 14, 1023, 63, 7546, 492, 3550, 63, 1023, 63, 647, 199, 199, 2339, 275, 283, 1810, 7537, 63, 7546, 7, 199, 4612, 275, 283, 17, 14, 17, 14, 2374, 7, 199, 19736, 275, 283, 2374, 7, 440, 315, 15945, 199, 24930, 63, 5825, 63, 2632, 275, 283, 1014, 921, 17343, 14, 1548, 14, 1308, 15, 5154, 15, 1365, 15, 65, 15, 1810, 7537, 13, 7546, 7, 199, 199, 4208, 63, 1023, 63, 647, 8, 2339, 12, 15945, 12, 5363, 17177, 12, 756, 12, 4440, 63, 3187, 29, 1397, 5363, 17177, 9, 199, 199, 3, 3645, 314, 4588, 1015, 5893, 314, 6135, 6822, 2338, 199, 504, 28753, 63, 7546, 14, 1023, 492, 1015, 465, 15945, 199, 199, 1760, 533, 275, 2274, 63, 4405, 8, 2339, 12, 15945, 12, 5363, 17177, 9, 199, 3, 961, 2559, 5965, 3181, 1133, 675, 314, 31986, 7537, 511, 1414, 199, 2264, 2088, 533, 459, 396, 418, 199, 199, 2758, 8, 272, 536, 29, 4600, 63, 4435, 14, 3489, 63, 354, 8, 2339, 395, 221, 327, 28753, 63, 7546, 1035, 28753, 13, 7546, 272, 1015, 29, 4612, 12, 272, 1369, 534, 22905, 367, 10015, 436, 22200, 31986, 7537, 12, 31986, 7537, 283, 355, 283, 27054, 317, 972, 6117, 12, 436, 3932, 26820, 3794, 3130, 272, 4132, 534, 1918, 31986, 7537, 23493, 297, 272, 4132, 63, 2123, 534, 1810, 7537, 14, 5969, 32, 6799, 14, 957, 297, 272, 4190, 534, 15400, 297, 272, 1166, 534, 1014, 921, 1810, 7537, 14, 1308, 297, 272, 1846, 63, 1802, 29, 1490, 360, 18195, 14, 8332, 1959, 739, 1062, 272, 5235, 63, 633, 32134, 16, 5995, 1810, 7537, 13, 7546, 24185, 17, 5565, 5369, 14, 6838, 1370, 908, 8, 24930, 63, 5825, 63, 2632, 12, 12740, 15945, 395, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 297, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 16442, 3800, 12439, 2537, 11349, 297, 267, 283, 16442, 3800, 10229, 3800, 13282, 297, 267, 283, 16442, 3800, 10229, 3800, 23978, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 6289, 844, 297, 267, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 267, 283, 11411, 8466, 3800, 2018, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 267, 283, 12157, 3800, 2290, 15290, 3800, 6516, 23228, 297, 267, 283, 12157, 3800, 2290, 15290, 3800, 31454, 3800, 2018, 18167, 297, 267, 283, 12157, 3800, 6187, 3800, 19521, 12616, 3800, 9954, 7407, 7, 272, 2156, 272, 2088, 533, 29, 1760, 533, 12, 272, 3482, 63, 3489, 29, 797, 12, 272, 1011, 362, 63, 2491, 63, 815, 8, 5473, 2968, 1810, 7537, 63, 7546, 14, 2219, 1105, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 3909, 1334, 282, 650, 13, 8501, 6289, 3449, 4190, 446, 1937, 5113, 14, 8332, 199, 199, 646, 282, 72, 63, 11146, 199, 646, 5496, 63, 4435, 199, 504, 9116, 492, 3272, 199, 504, 28753, 63, 7546, 14, 2758, 63, 7546, 492, 2274, 63, 4405, 12, 664, 63, 2491, 63, 815, 199, 504, 28753, 63, 7546, 14, 1023, 63, 7546, 492, 3550, 63, 1023, 63, 647, 199, 199, 2339, 275, 283, 1810, 7537, 63, 7546, 7, 199, 4612, 275, 283, 17, 14, 17, 14, 2374, 7, 199, 19736, 275, 283, 2374, 7, 440, 315, 15945, 199, 24930, 63, 5825, 63, 2632, 275, 283, 1014, 921, 17343, 14, 1548, 14, 1308, 15, 5154, 15, 1365, 15, 65, 15, 1810, 7537, 13, 7546, 7, 199, 199, 4208, 63, 1023, 63, 647, 8, 2339, 12, 15945, 12, 5363, 17177, 12, 756, 12, 4440, 63, 3187, 29, 1397, 5363, 17177, 9, 199, 199, 3, 3645, 314, 4588, 1015, 5893, 314, 6135, 6822, 2338, 199, 504, 28753, 63, 7546, 14, 1023, 492, 1015, 465, 15945, 199, 199, 1760, 533, 275, 2274, 63, 4405, 8, 2339, 12, 15945, 12, 5363, 17177, 9, 199, 3, 961, 2559, 5965, 3181, 1133, 675, 314, 31986, 7537, 511, 1414, 199, 2264, 2088, 533, 459, 396, 418, 199, 199, 2758, 8, 272, 536, 29, 4600, 63, 4435, 14, 3489, 63, 354, 8, 2339, 395, 221, 327, 28753, 63, 7546, 1035, 28753, 13, 7546, 272, 1015, 29, 4612, 12, 272, 1369, 534, 22905, 367, 10015, 436, 22200, 31986, 7537, 12, 31986, 7537, 283, 355, 283, 27054, 317, 972, 6117, 12, 436, 3932, 26820, 3794, 3130, 272, 4132, 534, 1918, 31986, 7537, 23493, 297, 272, 4132, 63, 2123, 534, 1810, 7537, 14, 5969, 32, 6799, 14, 957, 297, 272, 4190, 534, 15400, 297, 272, 1166, 534, 1014, 921, 1810, 7537, 14, 1308, 297, 272, 1846, 63, 1802, 29, 1490, 360, 18195, 14, 8332, 1959, 739, 1062, 272, 5235, 63, 633, 32134, 16, 5995, 1810, 7537, 13, 7546, 24185, 17, 5565, 5369, 14, 6838, 1370, 908, 8, 24930, 63, 5825, 63, 2632, 12, 12740, 15945, 395, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 297, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 16442, 3800, 12439, 2537, 11349, 297, 267, 283, 16442, 3800, 10229, 3800, 13282, 297, 267, 283, 16442, 3800, 10229, 3800, 23978, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 6289, 844, 297, 267, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 267, 283, 11411, 8466, 3800, 2018, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 267, 283, 12157, 3800, 2290, 15290, 3800, 6516, 23228, 297, 267, 283, 12157, 3800, 2290, 15290, 3800, 31454, 3800, 2018, 18167, 297, 267, 283, 12157, 3800, 6187, 3800, 19521, 12616, 3800, 9954, 7407, 7, 272, 2156, 272, 2088, 533, 29, 1760, 533, 12, 272, 3482, 63, 3489, 29, 797, 12, 272, 1011, 362, 63, 2491, 63, 815, 8, 5473, 2968, 1810, 7537, 63, 7546, 14, 2219, 1105, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sfairhur/pycbc
pycbc/noise/gaussian.py
6
5087
# Copyright (C) 2012 Alex Nitz # # # 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, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ============================================================================= # # Preamble # # ============================================================================= # """This module contains functions to generate gaussian noise colored with a noise spectrum. """ from pycbc.types import TimeSeries, zeros from pycbc.types import complex_same_precision_as, FrequencySeries from lalsimulation import SimNoise import lal import numpy.random def frequency_noise_from_psd(psd, seed=None): """ Create noise with a given psd. Return noise coloured with the given psd. The returned noise FrequencySeries has the same length and frequency step as the given psd. Note that if unique noise is desired a unique seed should be provided. Parameters ---------- psd : FrequencySeries The noise weighting to color the noise. seed : {0, int} or None The seed to generate the noise. If None specified, the seed will not be reset. Returns -------- noise : FrequencySeriesSeries A FrequencySeries containing gaussian noise colored by the given psd. """ sigma = 0.5 * (psd / psd.delta_f) ** (0.5) if seed is not None: numpy.random.seed(seed) sigma = sigma.numpy() dtype = complex_same_precision_as(psd) not_zero = (sigma != 0) sigma_red = sigma[not_zero] noise_re = numpy.random.normal(0, sigma_red) noise_co = numpy.random.normal(0, sigma_red) noise_red = noise_re + 1j * noise_co noise = numpy.zeros(len(sigma), dtype=dtype) noise[not_zero] = noise_red return FrequencySeries(noise, delta_f=psd.delta_f, dtype=dtype) def noise_from_psd(length, delta_t, psd, seed=None): """ Create noise with a given psd. Return noise with a given psd. Note that if unique noise is desired a unique seed should be provided. Parameters ---------- length : int The length of noise to generate in samples. delta_t : float The time step of the noise. psd : FrequencySeries The noise weighting to color the noise. seed : {0, int} The seed to generate the noise. Returns -------- noise : TimeSeries A TimeSeries containing gaussian noise colored by the given psd. """ noise_ts = TimeSeries(zeros(length), delta_t=delta_t) if seed is None: seed = numpy.random.randint(2**32) randomness = lal.gsl_rng("ranlux", seed) N = int (1.0 / delta_t / psd.delta_f) n = N//2+1 stride = N//2 if n > len(psd): raise ValueError("PSD not compatible with requested delta_t") psd = (psd[0:n]).lal() psd.data.data[n-1] = 0 segment = TimeSeries(zeros(N), delta_t=delta_t).lal() length_generated = 0 SimNoise(segment, 0, psd, randomness) while (length_generated < length): if (length_generated + stride) < length: noise_ts.data[length_generated:length_generated+stride] = segment.data.data[0:stride] else: noise_ts.data[length_generated:length] = segment.data.data[0:length-length_generated] length_generated += stride SimNoise(segment, stride, psd, randomness) return noise_ts def noise_from_string(psd_name, length, delta_t, seed=None, low_frequency_cutoff=10.0): """ Create noise from an analytic PSD Return noise from the chosen PSD. Note that if unique noise is desired a unique seed should be provided. Parameters ---------- psd_name : str Name of the analytic PSD to use. low_fr length : int The length of noise to generate in samples. delta_t : float The time step of the noise. seed : {None, int} The seed to generate the noise. low_frequency_cutof : {10.0, float} The low frequency cutoff to pass to the PSD generation. Returns -------- noise : TimeSeries A TimeSeries containing gaussian noise colored by the given psd. """ import pycbc.psd # We just need enough resolution to resolve lines delta_f = 1.0 / 8 flen = int(.5 / delta_t / delta_f) + 1 psd = pycbc.psd.from_string(psd_name, flen, delta_f, low_frequency_cutoff) return noise_from_psd(int(length), delta_t, psd, seed=seed)
gpl-3.0
[ 3, 1898, 334, 35, 9, 6029, 221, 22986, 653, 23751, 199, 3, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 314, 199, 3, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 334, 292, 2195, 199, 3, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 199, 3, 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, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 12, 8217, 14, 421, 199, 3, 199, 3, 26237, 199, 3, 199, 3, 15530, 510, 28469, 199, 3, 199, 3, 26237, 199, 3, 199, 624, 2765, 859, 3509, 3423, 370, 3550, 28912, 11145, 32076, 543, 282, 199, 11838, 20645, 14, 199, 624, 199, 504, 1134, 19279, 14, 1313, 492, 4703, 9641, 12, 10136, 199, 504, 1134, 19279, 14, 1313, 492, 6114, 63, 7191, 63, 6833, 63, 305, 12, 481, 6056, 9641, 199, 504, 634, 279, 22930, 492, 10751, 21446, 199, 646, 634, 279, 199, 646, 2680, 14, 2355, 199, 199, 318, 9857, 63, 11838, 63, 504, 63, 31600, 8, 31600, 12, 6347, 29, 403, 304, 272, 408, 2790, 11145, 543, 282, 1627, 299, 3893, 14, 339, 1432, 11145, 512, 320, 3297, 543, 314, 1627, 299, 3893, 14, 710, 2138, 11145, 272, 481, 6056, 9641, 965, 314, 2011, 2582, 436, 9857, 3650, 465, 314, 1627, 299, 3893, 14, 272, 3390, 626, 340, 3747, 11145, 365, 6387, 282, 3747, 6347, 1077, 506, 2741, 14, 339, 3897, 272, 4143, 272, 299, 3893, 520, 481, 6056, 9641, 267, 710, 11145, 5401, 316, 370, 3164, 314, 11145, 14, 272, 6347, 520, 469, 16, 12, 1109, 93, 503, 488, 267, 710, 6347, 370, 3550, 314, 11145, 14, 982, 488, 2013, 12, 267, 314, 6347, 911, 440, 506, 5305, 14, 339, 1803, 272, 3001, 272, 11145, 520, 481, 6056, 9641, 9641, 267, 437, 481, 6056, 9641, 3035, 28912, 11145, 32076, 701, 314, 1627, 299, 3893, 14, 272, 408, 272, 10819, 275, 378, 14, 21, 627, 334, 31600, 1182, 299, 3893, 14, 3136, 63, 70, 9, 1011, 334, 16, 14, 21, 9, 272, 340, 6347, 365, 440, 488, 26, 267, 2680, 14, 2355, 14, 5176, 8, 5176, 9, 272, 10819, 275, 10819, 14, 4714, 342, 272, 2152, 275, 6114, 63, 7191, 63, 6833, 63, 305, 8, 31600, 9, 339, 440, 63, 4262, 275, 334, 9412, 1137, 378, 9, 339, 10819, 63, 581, 275, 10819, 59, 1397, 63, 4262, 61, 272, 11145, 63, 264, 275, 2680, 14, 2355, 14, 3302, 8, 16, 12, 10819, 63, 581, 9, 272, 11145, 63, 331, 275, 2680, 14, 2355, 14, 3302, 8, 16, 12, 10819, 63, 581, 9, 272, 11145, 63, 581, 275, 11145, 63, 264, 435, 413, 74, 627, 11145, 63, 331, 339, 11145, 275, 2680, 14, 4250, 8, 552, 8, 9412, 395, 2152, 29, 2271, 9, 272, 11145, 59, 1397, 63, 4262, 61, 275, 11145, 63, 581, 339, 372, 481, 6056, 9641, 8, 11838, 12, 2574, 5762, 63, 70, 29, 31600, 14, 3136, 63, 70, 12, 2574, 2152, 29, 2271, 9, 199, 199, 318, 11145, 63, 504, 63, 31600, 8, 1267, 12, 5762, 63, 84, 12, 299, 3893, 12, 6347, 29, 403, 304, 272, 408, 2790, 11145, 543, 282, 1627, 299, 3893, 14, 339, 1432, 11145, 543, 282, 1627, 299, 3893, 14, 3390, 626, 340, 3747, 11145, 365, 6387, 272, 282, 3747, 6347, 1077, 506, 2741, 14, 339, 3897, 272, 4143, 272, 2582, 520, 1109, 267, 710, 2582, 402, 11145, 370, 3550, 315, 5845, 14, 272, 5762, 63, 84, 520, 2069, 267, 710, 900, 3650, 402, 314, 11145, 14, 272, 299, 3893, 520, 481, 6056, 9641, 267, 710, 11145, 5401, 316, 370, 3164, 314, 11145, 14, 272, 6347, 520, 469, 16, 12, 1109, 93, 267, 710, 6347, 370, 3550, 314, 11145, 14, 339, 1803, 272, 3001, 272, 11145, 520, 4703, 9641, 267, 437, 4703, 9641, 3035, 28912, 11145, 32076, 701, 314, 1627, 299, 3893, 14, 272, 408, 272, 11145, 63, 1086, 275, 4703, 9641, 8, 4250, 8, 1267, 395, 5762, 63, 84, 29, 3136, 63, 84, 9, 339, 340, 6347, 365, 488, 26, 267, 6347, 275, 2680, 14, 2355, 14, 8393, 8, 18, 538, 708, 9, 339, 2196, 4171, 275, 634, 279, 14, 458, 76, 63, 12686, 480, 1312, 76, 2521, 401, 6347, 9, 339, 653, 275, 1109, 334, 17, 14, 16, 1182, 5762, 63, 84, 1182, 299, 3893, 14, 3136, 63, 70, 9, 272, 302, 275, 653, 501, 18, 11, 17, 272, 7345, 275, 653, 501, 18, 339, 340, 302, 690, 822, 8, 31600, 304, 267, 746, 1722, 480, 48, 3693, 440, 9025, 543, 5839, 5762, 63, 84, 531, 339, 299, 3893, 275, 334, 31600, 59, 16, 26, 78, 6575, 76, 279, 342, 272, 299, 3893, 14, 576, 14, 576, 59, 78, 13, 17, 61, 275, 378, 339, 8135, 275, 4703, 9641, 8, 4250, 8, 46, 395, 5762, 63, 84, 29, 3136, 63, 84, 680, 76, 279, 342, 272, 2582, 63, 10176, 275, 378, 339, 10751, 21446, 8, 9255, 12, 378, 12, 299, 3893, 12, 2196, 4171, 9, 272, 1830, 334, 1267, 63, 10176, 665, 2582, 304, 267, 340, 334, 1267, 63, 10176, 435, 7345, 9, 665, 2582, 26, 288, 11145, 63, 1086, 14, 576, 59, 1267, 63, 10176, 26, 1267, 63, 10176, 11, 12318, 61, 275, 8135, 14, 576, 14, 576, 59, 16, 26, 12318, 61, 267, 587, 26, 288, 11145, 63, 1086, 14, 576, 59, 1267, 63, 10176, 26, 1267, 61, 275, 8135, 14, 576, 14, 576, 59, 16, 26, 1267, 13, 1267, 63, 10176, 61, 398, 2582, 63, 10176, 847, 7345, 267, 10751, 21446, 8, 9255, 12, 7345, 12, 299, 3893, 12, 2196, 4171, 9, 339 ]
[ 1898, 334, 35, 9, 6029, 221, 22986, 653, 23751, 199, 3, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 314, 199, 3, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 334, 292, 2195, 199, 3, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 199, 3, 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, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 12, 8217, 14, 421, 199, 3, 199, 3, 26237, 199, 3, 199, 3, 15530, 510, 28469, 199, 3, 199, 3, 26237, 199, 3, 199, 624, 2765, 859, 3509, 3423, 370, 3550, 28912, 11145, 32076, 543, 282, 199, 11838, 20645, 14, 199, 624, 199, 504, 1134, 19279, 14, 1313, 492, 4703, 9641, 12, 10136, 199, 504, 1134, 19279, 14, 1313, 492, 6114, 63, 7191, 63, 6833, 63, 305, 12, 481, 6056, 9641, 199, 504, 634, 279, 22930, 492, 10751, 21446, 199, 646, 634, 279, 199, 646, 2680, 14, 2355, 199, 199, 318, 9857, 63, 11838, 63, 504, 63, 31600, 8, 31600, 12, 6347, 29, 403, 304, 272, 408, 2790, 11145, 543, 282, 1627, 299, 3893, 14, 339, 1432, 11145, 512, 320, 3297, 543, 314, 1627, 299, 3893, 14, 710, 2138, 11145, 272, 481, 6056, 9641, 965, 314, 2011, 2582, 436, 9857, 3650, 465, 314, 1627, 299, 3893, 14, 272, 3390, 626, 340, 3747, 11145, 365, 6387, 282, 3747, 6347, 1077, 506, 2741, 14, 339, 3897, 272, 4143, 272, 299, 3893, 520, 481, 6056, 9641, 267, 710, 11145, 5401, 316, 370, 3164, 314, 11145, 14, 272, 6347, 520, 469, 16, 12, 1109, 93, 503, 488, 267, 710, 6347, 370, 3550, 314, 11145, 14, 982, 488, 2013, 12, 267, 314, 6347, 911, 440, 506, 5305, 14, 339, 1803, 272, 3001, 272, 11145, 520, 481, 6056, 9641, 9641, 267, 437, 481, 6056, 9641, 3035, 28912, 11145, 32076, 701, 314, 1627, 299, 3893, 14, 272, 408, 272, 10819, 275, 378, 14, 21, 627, 334, 31600, 1182, 299, 3893, 14, 3136, 63, 70, 9, 1011, 334, 16, 14, 21, 9, 272, 340, 6347, 365, 440, 488, 26, 267, 2680, 14, 2355, 14, 5176, 8, 5176, 9, 272, 10819, 275, 10819, 14, 4714, 342, 272, 2152, 275, 6114, 63, 7191, 63, 6833, 63, 305, 8, 31600, 9, 339, 440, 63, 4262, 275, 334, 9412, 1137, 378, 9, 339, 10819, 63, 581, 275, 10819, 59, 1397, 63, 4262, 61, 272, 11145, 63, 264, 275, 2680, 14, 2355, 14, 3302, 8, 16, 12, 10819, 63, 581, 9, 272, 11145, 63, 331, 275, 2680, 14, 2355, 14, 3302, 8, 16, 12, 10819, 63, 581, 9, 272, 11145, 63, 581, 275, 11145, 63, 264, 435, 413, 74, 627, 11145, 63, 331, 339, 11145, 275, 2680, 14, 4250, 8, 552, 8, 9412, 395, 2152, 29, 2271, 9, 272, 11145, 59, 1397, 63, 4262, 61, 275, 11145, 63, 581, 339, 372, 481, 6056, 9641, 8, 11838, 12, 2574, 5762, 63, 70, 29, 31600, 14, 3136, 63, 70, 12, 2574, 2152, 29, 2271, 9, 199, 199, 318, 11145, 63, 504, 63, 31600, 8, 1267, 12, 5762, 63, 84, 12, 299, 3893, 12, 6347, 29, 403, 304, 272, 408, 2790, 11145, 543, 282, 1627, 299, 3893, 14, 339, 1432, 11145, 543, 282, 1627, 299, 3893, 14, 3390, 626, 340, 3747, 11145, 365, 6387, 272, 282, 3747, 6347, 1077, 506, 2741, 14, 339, 3897, 272, 4143, 272, 2582, 520, 1109, 267, 710, 2582, 402, 11145, 370, 3550, 315, 5845, 14, 272, 5762, 63, 84, 520, 2069, 267, 710, 900, 3650, 402, 314, 11145, 14, 272, 299, 3893, 520, 481, 6056, 9641, 267, 710, 11145, 5401, 316, 370, 3164, 314, 11145, 14, 272, 6347, 520, 469, 16, 12, 1109, 93, 267, 710, 6347, 370, 3550, 314, 11145, 14, 339, 1803, 272, 3001, 272, 11145, 520, 4703, 9641, 267, 437, 4703, 9641, 3035, 28912, 11145, 32076, 701, 314, 1627, 299, 3893, 14, 272, 408, 272, 11145, 63, 1086, 275, 4703, 9641, 8, 4250, 8, 1267, 395, 5762, 63, 84, 29, 3136, 63, 84, 9, 339, 340, 6347, 365, 488, 26, 267, 6347, 275, 2680, 14, 2355, 14, 8393, 8, 18, 538, 708, 9, 339, 2196, 4171, 275, 634, 279, 14, 458, 76, 63, 12686, 480, 1312, 76, 2521, 401, 6347, 9, 339, 653, 275, 1109, 334, 17, 14, 16, 1182, 5762, 63, 84, 1182, 299, 3893, 14, 3136, 63, 70, 9, 272, 302, 275, 653, 501, 18, 11, 17, 272, 7345, 275, 653, 501, 18, 339, 340, 302, 690, 822, 8, 31600, 304, 267, 746, 1722, 480, 48, 3693, 440, 9025, 543, 5839, 5762, 63, 84, 531, 339, 299, 3893, 275, 334, 31600, 59, 16, 26, 78, 6575, 76, 279, 342, 272, 299, 3893, 14, 576, 14, 576, 59, 78, 13, 17, 61, 275, 378, 339, 8135, 275, 4703, 9641, 8, 4250, 8, 46, 395, 5762, 63, 84, 29, 3136, 63, 84, 680, 76, 279, 342, 272, 2582, 63, 10176, 275, 378, 339, 10751, 21446, 8, 9255, 12, 378, 12, 299, 3893, 12, 2196, 4171, 9, 272, 1830, 334, 1267, 63, 10176, 665, 2582, 304, 267, 340, 334, 1267, 63, 10176, 435, 7345, 9, 665, 2582, 26, 288, 11145, 63, 1086, 14, 576, 59, 1267, 63, 10176, 26, 1267, 63, 10176, 11, 12318, 61, 275, 8135, 14, 576, 14, 576, 59, 16, 26, 12318, 61, 267, 587, 26, 288, 11145, 63, 1086, 14, 576, 59, 1267, 63, 10176, 26, 1267, 61, 275, 8135, 14, 576, 14, 576, 59, 16, 26, 1267, 13, 1267, 63, 10176, 61, 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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 ]
sidartaoliveira/ansible
lib/ansible/modules/web_infrastructure/ansible_tower/tower_host.py
36
5901
#!/usr/bin/python # coding: utf-8 -*- # (c) 2017, Wayne Witzel III <wayne@riotousliving.com> # # This module 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 software 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 software. If not, see <http://www.gnu.org/licenses/>. ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: tower_host version_added: "2.3" author: "Wayne Witzel III (@wwitzel3)" short_description: create, update, or destroy Ansible Tower host. description: - Create, update, or destroy Ansible Tower hosts. See U(https://www.ansible.com/tower) for an overview. options: name: description: - The name to use for the host. required: True description: description: - The description to use for the host. required: False default: null inventory: description: - Inventory the host should be made a member of. required: True enabled: description: - If the host should be enabled. required: False default: True variables: description: - Variables to use for the host. Use '@' for a file. state: description: - Desired state of the resource. required: False default: "present" choices: ["present", "absent"] tower_host: description: - URL to your Tower instance. required: False default: null tower_username: description: - Username for your Tower instance. required: False default: null tower_password: description: - Password for your Tower instance. required: False default: null tower_verify_ssl: description: - Dis/allow insecure connections to Tower. If C(no), SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. required: False default: True tower_config_file: description: - Path to the Tower config file. See notes. required: False default: null requirements: - "python >= 2.6" - "ansible-tower-cli >= 3.0.3" notes: - If no I(config_file) is provided we will attempt to use the tower-cli library defaults to find your Tower host information. - I(config_file) should contain Tower configuration in the following format host=hostname username=username password=password ''' EXAMPLES = ''' - name: Add tower host tower_host: name: localhost description: "Local Host Group" inventory: "Local Inventory" state: present tower_config_file: "~/tower_cli.cfg" ''' try: import os import tower_cli import tower_cli.utils.exceptions as exc from tower_cli.conf import settings from ansible.module_utils.ansible_tower import tower_auth_config, tower_check_mode HAS_TOWER_CLI = True except ImportError: HAS_TOWER_CLI = False def main(): module = AnsibleModule( argument_spec=dict( name=dict(required=True), description=dict(), inventory=dict(required=True), enabled=dict(type='bool', default=True), variables=dict(), tower_host=dict(), tower_username=dict(), tower_password=dict(no_log=True), tower_verify_ssl=dict(type='bool', default=True), tower_config_file=dict(type='path'), state=dict(choices=['present', 'absent'], default='present'), ), supports_check_mode=True ) if not HAS_TOWER_CLI: module.fail_json(msg='ansible-tower-cli required for this module') name = module.params.get('name') description = module.params.get('description') inventory = module.params.get('inventory') enabled = module.params.get('enabled') state = module.params.get('state') variables = module.params.get('variables') if variables: if variables.startswith('@'): filename = os.path.expanduser(variables[1:]) variables = module.contents_from_file(filename) json_output = {'host': name, 'state': state} tower_auth = tower_auth_config(module) with settings.runtime_values(**tower_auth): tower_check_mode(module) host = tower_cli.get_resource('host') try: inv_res = tower_cli.get_resource('inventory') inv = inv_res.get(name=inventory) if state == 'present': result = host.modify(name=name, inventory=inv['id'], enabled=enabled, variables=variables, description=description, create_on_missing=True) json_output['id'] = result['id'] elif state == 'absent': result = host.delete(name=name, inventory=inv['id']) except (exc.NotFound) as excinfo: module.fail_json(msg='Failed to update host, inventory not found: {0}'.format(excinfo), changed=False) except (exc.ConnectionError, exc.BadRequest) as excinfo: module.fail_json(msg='Failed to update host: {0}'.format(excinfo), changed=False) json_output['changed'] = result['changed'] module.exit_json(**json_output) from ansible.module_utils.basic import AnsibleModule if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 9708, 12, 644, 1187, 685, 644, 23751, 352, 473, 8921, 665, 3316, 685, 32, 322, 357, 1785, 317, 4007, 14, 957, 30, 199, 3, 199, 3, 961, 859, 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, 2032, 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, 2032, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 18915, 63, 1102, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 298, 25544, 685, 644, 23751, 352, 473, 8921, 8593, 978, 23751, 352, 19, 2924, 199, 3612, 63, 1802, 26, 1218, 12, 1678, 12, 503, 11972, 2622, 377, 3891, 1591, 14, 199, 1802, 26, 272, 446, 2790, 12, 1678, 12, 503, 11972, 2622, 377, 3891, 7057, 14, 1666, 489, 738, 8, 2859, 921, 1544, 14, 4853, 14, 957, 15, 21651, 9, 367, 376, 23503, 14, 199, 1419, 26, 272, 536, 26, 489, 1369, 26, 267, 446, 710, 536, 370, 675, 367, 314, 1591, 14, 489, 1415, 26, 715, 272, 1369, 26, 489, 1369, 26, 267, 446, 710, 1369, 370, 675, 367, 314, 1591, 14, 489, 1415, 26, 756, 489, 849, 26, 2973, 272, 8200, 26, 489, 1369, 26, 267, 446, 19337, 314, 1591, 1077, 506, 6326, 282, 3653, 402, 14, 489, 1415, 26, 715, 272, 5223, 26, 489, 1369, 26, 267, 446, 982, 314, 1591, 1077, 506, 5223, 14, 489, 1415, 26, 756, 489, 849, 26, 715, 272, 2860, 26, 489, 1369, 26, 267, 446, 17198, 370, 675, 367, 314, 1591, 14, 3645, 22143, 367, 282, 570, 14, 272, 1174, 26, 489, 1369, 26, 267, 446, 1487, 5381, 1174, 402, 314, 2073, 14, 489, 1415, 26, 756, 489, 849, 26, 298, 1881, 2, 489, 3415, 26, 2097, 1881, 401, 298, 5575, 937, 272, 18915, 63, 1102, 26, 489, 1369, 26, 267, 446, 2851, 370, 2195, 377, 3891, 1256, 14, 489, 1415, 26, 756, 489, 849, 26, 2973, 272, 18915, 63, 2473, 26, 267, 1369, 26, 881, 446, 29739, 367, 2195, 377, 3891, 1256, 14, 267, 1415, 26, 756, 267, 849, 26, 2973, 272, 18915, 63, 2060, 26, 267, 1369, 26, 881, 446, 13635, 367, 2195, 377, 3891, 1256, 14, 267, 1415, 26, 756, 267, 849, 26, 2973, 272, 18915, 63, 4712, 63, 4266, 26, 267, 1369, 26, 881, 446, 5289, 15, 3306, 26097, 6947, 370, 377, 3891, 14, 982, 445, 8, 889, 395, 7799, 14512, 911, 440, 506, 16468, 14, 288, 961, 1077, 1454, 506, 1202, 641, 4954, 1183, 22284, 15424, 1808, 291, 13, 1737, 14512, 14, 267, 1415, 26, 756, 267, 849, 26, 715, 272, 18915, 63, 888, 63, 493, 26, 489, 1369, 26, 267, 446, 6912, 370, 314, 377, 3891, 1101, 570, 14, 1666, 12681, 14, 489, 1415, 26, 756, 489, 849, 26, 2973, 421, 199, 7538, 26, 523, 446, 298, 1548, 2356, 499, 14, 22, 2, 523, 446, 298, 4853, 13, 21651, 13, 2764, 2356, 650, 14, 16, 14, 19, 2, 199, 199, 5983, 26, 523, 446, 982, 949, 473, 8, 888, 63, 493, 9, 365, 2741, 781, 911, 7427, 370, 675, 314, 18915, 13, 2764, 3555, 272, 4243, 370, 2342, 2195, 377, 3891, 1591, 2556, 14, 523, 446, 473, 8, 888, 63, 493, 9, 1077, 1395, 377, 3891, 2897, 315, 314, 2569, 1475, 489, 1591, 29, 4269, 489, 3434, 29, 2473, 489, 2505, 29, 2060, 199, 2344, 421, 199, 8918, 275, 1449, 199, 13, 536, 26, 2654, 18915, 1591, 523, 18915, 63, 1102, 26, 272, 536, 26, 11667, 272, 1369, 26, 298, 5339, 10891, 5611, 2, 272, 8200, 26, 298, 5339, 19337, 2, 272, 1174, 26, 3451, 272, 18915, 63, 888, 63, 493, 26, 26810, 15, 21651, 63, 2764, 14, 4128, 2, 199, 2344, 421, 199, 893, 26, 272, 492, 747, 272, 492, 18915, 63, 2764, 272, 492, 18915, 63, 2764, 14, 1208, 14, 3924, 465, 3178, 339, 687, 18915, 63, 2764, 14, 2190, 492, 2202, 272, 687, 3242, 14, 578, 63, 1208, 14, 4853, 63, 21651, 492, 18915, 63, 1178, 63, 888, 12, 18915, 63, 1074, 63, 632, 339, 7509, 63, 2566, 12018, 63, 7802, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 2566, 12018, 63, 7802, 275, 756, 421, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 536, 29, 807, 8, 2427, 29, 549, 395, 288, 1369, 29, 807, 1062, 288, 8200, 29, 807, 8, 2427, 29, 549, 395, 288, 5223, 29, 807, 8, 466, 534, 2245, 297, 849, 29, 549, 395, 288, 2860, 29, 807, 1062, 288, 18915, 63, 1102, 29, 807, 1062, 288, 18915, 63, 2473, 29, 807, 1062, 288, 18915, 63, 2060, 29, 807, 8, 889, 63, 793, 29, 549, 395, 288, 18915, 63, 4712, 63, 4266, 29, 807, 8, 466, 534, 2245, 297, 849, 29, 549, 395, 288, 18915, 63, 888, 63, 493, 29, 807, 8, 466, 534, 515, 659, 288, 1174, 29, 807, 8, 4577, 2968, 1881, 297, 283, 5575, 995, 849, 534, 1881, 659, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 549, 272, 776, 339, 340, 440, 7509, 63, 2566, 12018, 63, 7802, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 4853, 13, 21651, 13, 2764, 1415, 367 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 9708, 12, 644, 1187, 685, 644, 23751, 352, 473, 8921, 665, 3316, 685, 32, 322, 357, 1785, 317, 4007, 14, 957, 30, 199, 3, 199, 3, 961, 859, 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, 2032, 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, 2032, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 18915, 63, 1102, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 298, 25544, 685, 644, 23751, 352, 473, 8921, 8593, 978, 23751, 352, 19, 2924, 199, 3612, 63, 1802, 26, 1218, 12, 1678, 12, 503, 11972, 2622, 377, 3891, 1591, 14, 199, 1802, 26, 272, 446, 2790, 12, 1678, 12, 503, 11972, 2622, 377, 3891, 7057, 14, 1666, 489, 738, 8, 2859, 921, 1544, 14, 4853, 14, 957, 15, 21651, 9, 367, 376, 23503, 14, 199, 1419, 26, 272, 536, 26, 489, 1369, 26, 267, 446, 710, 536, 370, 675, 367, 314, 1591, 14, 489, 1415, 26, 715, 272, 1369, 26, 489, 1369, 26, 267, 446, 710, 1369, 370, 675, 367, 314, 1591, 14, 489, 1415, 26, 756, 489, 849, 26, 2973, 272, 8200, 26, 489, 1369, 26, 267, 446, 19337, 314, 1591, 1077, 506, 6326, 282, 3653, 402, 14, 489, 1415, 26, 715, 272, 5223, 26, 489, 1369, 26, 267, 446, 982, 314, 1591, 1077, 506, 5223, 14, 489, 1415, 26, 756, 489, 849, 26, 715, 272, 2860, 26, 489, 1369, 26, 267, 446, 17198, 370, 675, 367, 314, 1591, 14, 3645, 22143, 367, 282, 570, 14, 272, 1174, 26, 489, 1369, 26, 267, 446, 1487, 5381, 1174, 402, 314, 2073, 14, 489, 1415, 26, 756, 489, 849, 26, 298, 1881, 2, 489, 3415, 26, 2097, 1881, 401, 298, 5575, 937, 272, 18915, 63, 1102, 26, 489, 1369, 26, 267, 446, 2851, 370, 2195, 377, 3891, 1256, 14, 489, 1415, 26, 756, 489, 849, 26, 2973, 272, 18915, 63, 2473, 26, 267, 1369, 26, 881, 446, 29739, 367, 2195, 377, 3891, 1256, 14, 267, 1415, 26, 756, 267, 849, 26, 2973, 272, 18915, 63, 2060, 26, 267, 1369, 26, 881, 446, 13635, 367, 2195, 377, 3891, 1256, 14, 267, 1415, 26, 756, 267, 849, 26, 2973, 272, 18915, 63, 4712, 63, 4266, 26, 267, 1369, 26, 881, 446, 5289, 15, 3306, 26097, 6947, 370, 377, 3891, 14, 982, 445, 8, 889, 395, 7799, 14512, 911, 440, 506, 16468, 14, 288, 961, 1077, 1454, 506, 1202, 641, 4954, 1183, 22284, 15424, 1808, 291, 13, 1737, 14512, 14, 267, 1415, 26, 756, 267, 849, 26, 715, 272, 18915, 63, 888, 63, 493, 26, 489, 1369, 26, 267, 446, 6912, 370, 314, 377, 3891, 1101, 570, 14, 1666, 12681, 14, 489, 1415, 26, 756, 489, 849, 26, 2973, 421, 199, 7538, 26, 523, 446, 298, 1548, 2356, 499, 14, 22, 2, 523, 446, 298, 4853, 13, 21651, 13, 2764, 2356, 650, 14, 16, 14, 19, 2, 199, 199, 5983, 26, 523, 446, 982, 949, 473, 8, 888, 63, 493, 9, 365, 2741, 781, 911, 7427, 370, 675, 314, 18915, 13, 2764, 3555, 272, 4243, 370, 2342, 2195, 377, 3891, 1591, 2556, 14, 523, 446, 473, 8, 888, 63, 493, 9, 1077, 1395, 377, 3891, 2897, 315, 314, 2569, 1475, 489, 1591, 29, 4269, 489, 3434, 29, 2473, 489, 2505, 29, 2060, 199, 2344, 421, 199, 8918, 275, 1449, 199, 13, 536, 26, 2654, 18915, 1591, 523, 18915, 63, 1102, 26, 272, 536, 26, 11667, 272, 1369, 26, 298, 5339, 10891, 5611, 2, 272, 8200, 26, 298, 5339, 19337, 2, 272, 1174, 26, 3451, 272, 18915, 63, 888, 63, 493, 26, 26810, 15, 21651, 63, 2764, 14, 4128, 2, 199, 2344, 421, 199, 893, 26, 272, 492, 747, 272, 492, 18915, 63, 2764, 272, 492, 18915, 63, 2764, 14, 1208, 14, 3924, 465, 3178, 339, 687, 18915, 63, 2764, 14, 2190, 492, 2202, 272, 687, 3242, 14, 578, 63, 1208, 14, 4853, 63, 21651, 492, 18915, 63, 1178, 63, 888, 12, 18915, 63, 1074, 63, 632, 339, 7509, 63, 2566, 12018, 63, 7802, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 2566, 12018, 63, 7802, 275, 756, 421, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 536, 29, 807, 8, 2427, 29, 549, 395, 288, 1369, 29, 807, 1062, 288, 8200, 29, 807, 8, 2427, 29, 549, 395, 288, 5223, 29, 807, 8, 466, 534, 2245, 297, 849, 29, 549, 395, 288, 2860, 29, 807, 1062, 288, 18915, 63, 1102, 29, 807, 1062, 288, 18915, 63, 2473, 29, 807, 1062, 288, 18915, 63, 2060, 29, 807, 8, 889, 63, 793, 29, 549, 395, 288, 18915, 63, 4712, 63, 4266, 29, 807, 8, 466, 534, 2245, 297, 849, 29, 549, 395, 288, 18915, 63, 888, 63, 493, 29, 807, 8, 466, 534, 515, 659, 288, 1174, 29, 807, 8, 4577, 2968, 1881, 297, 283, 5575, 995, 849, 534, 1881, 659, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 549, 272, 776, 339, 340, 440, 7509, 63, 2566, 12018, 63, 7802, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 4853, 13, 21651, 13, 2764, 1415, 367, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
toontownfunserver/Panda3D-1.9.0
direct/p3d/HostInfo.py
2
28703
from pandac.PandaModules import HashVal, Filename, PandaSystem, DocumentSpec, Ramfile from pandac.PandaModules import HTTPChannel from pandac import PandaModules from libpandaexpress import ConfigVariableInt from direct.p3d.PackageInfo import PackageInfo from direct.p3d.FileSpec import FileSpec from direct.directnotify.DirectNotifyGlobal import directNotify import time class HostInfo: """ This class represents a particular download host serving up Panda3D packages. It is the Python equivalent of the P3DHost class in the core API. """ notify = directNotify.newCategory("HostInfo") def __init__(self, hostUrl, appRunner = None, hostDir = None, rootDir = None, asMirror = False, perPlatform = None): """ You must specify either an appRunner or a hostDir to the HostInfo constructor. If you pass asMirror = True, it means that this HostInfo object is to be used to populate a "mirror" folder, a duplicate (or subset) of the contents hosted by a server. This means when you use this HostInfo to download packages, it will only download the compressed archive file and leave it there. At the moment, mirror folders do not download old patch files from the server. If you pass perPlatform = True, then files are unpacked into a platform-specific directory, which is appropriate when you might be downloading multiple platforms. The default is perPlatform = False, which means all files are unpacked into the host directory directly, without an intervening platform-specific directory name. If asMirror is True, then the default is perPlatform = True. Note that perPlatform is also restricted by the individual package's specification. """ assert appRunner or rootDir or hostDir self.__setHostUrl(hostUrl) self.appRunner = appRunner self.rootDir = rootDir if rootDir is None and appRunner: self.rootDir = appRunner.rootDir if hostDir and not isinstance(hostDir, Filename): hostDir = Filename.fromOsSpecific(hostDir) self.hostDir = hostDir self.asMirror = asMirror self.perPlatform = perPlatform if perPlatform is None: self.perPlatform = asMirror # Initially false, this is set true when the contents file is # successfully read. self.hasContentsFile = False # This is the time value at which the current contents file is # no longer valid. self.contentsExpiration = 0 # Contains the md5 hash of the original contents.xml file. self.contentsSpec = FileSpec() # descriptiveName will be filled in later, when the # contents file is read. self.descriptiveName = None # A list of known mirrors for this host, all URL's guaranteed # to end with a slash. self.mirrors = [] # A map of keyword -> altHost URL's. An altHost is different # than a mirror; an altHost is an alternate URL to download a # different (e.g. testing) version of this host's contents. # It is rarely used. self.altHosts = {} # This is a dictionary of packages by (name, version). It # will be filled in when the contents file is read. self.packages = {} if self.appRunner and self.appRunner.verifyContents != self.appRunner.P3DVCForce: # Attempt to pre-read the existing contents.xml; maybe it # will be current enough for our purposes. self.readContentsFile() def __setHostUrl(self, hostUrl): """ Assigns self.hostUrl, and related values. """ self.hostUrl = hostUrl if not self.hostUrl: # A special case: the URL will be set later. self.hostUrlPrefix = None self.downloadUrlPrefix = None else: # hostUrlPrefix is the host URL, but it is guaranteed to end # with a slash. self.hostUrlPrefix = hostUrl if self.hostUrlPrefix[-1] != '/': self.hostUrlPrefix += '/' # downloadUrlPrefix is the URL prefix that should be used for # everything other than the contents.xml file. It might be # the same as hostUrlPrefix, but in the case of an # https-protected hostUrl, it will be the cleartext channel. self.downloadUrlPrefix = self.hostUrlPrefix def downloadContentsFile(self, http, redownload = False, hashVal = None): """ Downloads the contents.xml file for this particular host, synchronously, and then reads it. Returns true on success, false on failure. If hashVal is not None, it should be a HashVal object, which will be filled with the hash from the new contents.xml file.""" if self.hasCurrentContentsFile(): # We've already got one. return True if self.appRunner and self.appRunner.verifyContents == self.appRunner.P3DVCNever: # Not allowed to. return False rf = None if http: if not redownload and self.appRunner and self.appRunner.superMirrorUrl: # We start with the "super mirror", if it's defined. url = self.appRunner.superMirrorUrl + 'contents.xml' request = DocumentSpec(url) self.notify.info("Downloading contents file %s" % (request)) rf = Ramfile() channel = http.makeChannel(False) channel.getDocument(request) if not channel.downloadToRam(rf): self.notify.warning("Unable to download %s" % (url)) rf = None if not rf: # Then go to the main host, if our super mirror let us # down. url = self.hostUrlPrefix + 'contents.xml' # Append a uniquifying query string to the URL to force the # download to go all the way through any caches. We use the # time in seconds; that's unique enough. url += '?' + str(int(time.time())) # We might as well explicitly request the cache to be disabled # too, since we have an interface for that via HTTPChannel. request = DocumentSpec(url) request.setCacheControl(DocumentSpec.CCNoCache) self.notify.info("Downloading contents file %s" % (request)) statusCode = None statusString = '' for attempt in range(ConfigVariableInt('contents-xml-dl-attempts', 3)): if attempt > 0: self.notify.info("Retrying (%s)..."%(attempt,)) rf = Ramfile() channel = http.makeChannel(False) channel.getDocument(request) if channel.downloadToRam(rf): self.notify.warning("Successfully downloaded %s" % (url,)) break else: rf = None statusCode = channel.getStatusCode() statusString = channel.getStatusString() self.notify.warning("Could not contact download server at %s" % (url,)) self.notify.warning("Status code = %s %s" % (statusCode, statusString)) if not rf: self.notify.warning("Unable to download %s" % (url,)) try: # Something screwed up. if statusCode == HTTPChannel.SCDownloadOpenError or \ statusCode == HTTPChannel.SCDownloadWriteError: launcher.setPandaErrorCode(2) elif statusCode == 404: # 404 not found launcher.setPandaErrorCode(5) elif statusCode < 100: # statusCode < 100 implies the connection attempt itself # failed. This is usually due to firewall software # interfering. Apparently some firewall software might # allow the first connection and disallow subsequent # connections; how strange. launcher.setPandaErrorCode(4) else: # There are other kinds of failures, but these will # generally have been caught already by the first test; so # if we get here there may be some bigger problem. Just # give the generic "big problem" message. launcher.setPandaErrorCode(6) except NameError,e: # no launcher pass except AttributeError, e: self.notify.warning("%s" % (str(e),)) pass return False tempFilename = Filename.temporary('', 'p3d_', '.xml') if rf: f = open(tempFilename.toOsSpecific(), 'wb') f.write(rf.getData()) f.close() if hashVal: hashVal.hashString(rf.getData()) if not self.readContentsFile(tempFilename, freshDownload = True): self.notify.warning("Failure reading %s" % (url)) tempFilename.unlink() return False tempFilename.unlink() return True # Couldn't download the file. Maybe we should look for a # previously-downloaded copy already on disk? return False def redownloadContentsFile(self, http): """ Downloads a new contents.xml file in case it has changed. Returns true if the file has indeed changed, false if it has not. """ assert self.hasContentsFile if self.appRunner and self.appRunner.verifyContents == self.appRunner.P3DVCNever: # Not allowed to. return False url = self.hostUrlPrefix + 'contents.xml' self.notify.info("Redownloading %s" % (url)) # Get the hash of the original file. assert self.hostDir hv1 = HashVal() if self.contentsSpec.hash: hv1.setFromHex(self.contentsSpec.hash) else: filename = Filename(self.hostDir, 'contents.xml') hv1.hashFile(filename) # Now download it again. self.hasContentsFile = False hv2 = HashVal() if not self.downloadContentsFile(http, redownload = True, hashVal = hv2): return False if hv2 == HashVal(): self.notify.info("%s didn't actually redownload." % (url)) return False elif hv1 != hv2: self.notify.info("%s has changed." % (url)) return True else: self.notify.info("%s has not changed." % (url)) return False def hasCurrentContentsFile(self): """ Returns true if a contents.xml file has been successfully read for this host and is still current, false otherwise. """ if not self.appRunner \ or self.appRunner.verifyContents == self.appRunner.P3DVCNone \ or self.appRunner.verifyContents == self.appRunner.P3DVCNever: # If we're not asking to verify contents, then # contents.xml files never expires. return self.hasContentsFile now = int(time.time()) return now < self.contentsExpiration and self.hasContentsFile def readContentsFile(self, tempFilename = None, freshDownload = False): """ Reads the contents.xml file for this particular host, once it has been downloaded into the indicated temporary file. Returns true on success, false if the contents file is not already on disk or is unreadable. If tempFilename is specified, it is the filename read, and it is copied the file into the standard location if it's not there already. If tempFilename is not specified, the standard filename is read if it is known. """ if not hasattr(PandaModules, 'TiXmlDocument'): return False if not tempFilename: if self.hostDir: # If the filename is not specified, we can infer it # if we already know our hostDir hostDir = self.hostDir else: # Otherwise, we have to guess the hostDir. hostDir = self.__determineHostDir(None, self.hostUrl) tempFilename = Filename(hostDir, 'contents.xml') doc = PandaModules.TiXmlDocument(tempFilename.toOsSpecific()) if not doc.LoadFile(): return False xcontents = doc.FirstChildElement('contents') if not xcontents: return False maxAge = xcontents.Attribute('max_age') if maxAge: try: maxAge = int(maxAge) except: maxAge = None if maxAge is None: # Default max_age if unspecified (see p3d_plugin.h). from direct.p3d.AppRunner import AppRunner maxAge = AppRunner.P3D_CONTENTS_DEFAULT_MAX_AGE # Get the latest possible expiration time, based on the max_age # indication. Any expiration time later than this is in error. now = int(time.time()) self.contentsExpiration = now + maxAge if freshDownload: self.contentsSpec.readHash(tempFilename) # Update the XML with the new download information. xorig = xcontents.FirstChildElement('orig') while xorig: xcontents.RemoveChild(xorig) xorig = xcontents.FirstChildElement('orig') xorig = PandaModules.TiXmlElement('orig') self.contentsSpec.storeXml(xorig) xorig.SetAttribute('expiration', str(self.contentsExpiration)) xcontents.InsertEndChild(xorig) else: # Read the download hash and expiration time from the XML. expiration = None xorig = xcontents.FirstChildElement('orig') if xorig: self.contentsSpec.loadXml(xorig) expiration = xorig.Attribute('expiration') if expiration: try: expiration = int(expiration) except: expiration = None if not self.contentsSpec.hash: self.contentsSpec.readHash(tempFilename) if expiration is not None: self.contentsExpiration = min(self.contentsExpiration, expiration) # Look for our own entry in the hosts table. if self.hostUrl: self.__findHostXml(xcontents) else: assert self.hostDir self.__findHostXmlForHostDir(xcontents) if not self.hostDir: self.hostDir = self.__determineHostDir(None, self.hostUrl) # Get the list of packages available for download and/or import. xpackage = xcontents.FirstChildElement('package') while xpackage: name = xpackage.Attribute('name') platform = xpackage.Attribute('platform') version = xpackage.Attribute('version') try: solo = int(xpackage.Attribute('solo') or '') except ValueError: solo = False try: perPlatform = int(xpackage.Attribute('per_platform') or '') except ValueError: perPlatform = False package = self.__makePackage(name, platform, version, solo, perPlatform) package.descFile = FileSpec() package.descFile.loadXml(xpackage) package.setupFilenames() package.importDescFile = None ximport = xpackage.FirstChildElement('import') if ximport: package.importDescFile = FileSpec() package.importDescFile.loadXml(ximport) xpackage = xpackage.NextSiblingElement('package') self.hasContentsFile = True # Now save the contents.xml file into the standard location. if not self.appRunner or self.appRunner.verifyContents != self.appRunner.P3DVCNever: assert self.hostDir filename = Filename(self.hostDir, 'contents.xml') filename.makeDir() if freshDownload: doc.SaveFile(filename.toOsSpecific()) else: if filename != tempFilename: tempFilename.copyTo(filename) return True def __findHostXml(self, xcontents): """ Looks for the <host> or <alt_host> entry in the contents.xml that corresponds to the URL that we actually downloaded from. """ xhost = xcontents.FirstChildElement('host') while xhost: url = xhost.Attribute('url') if url == self.hostUrl: self.readHostXml(xhost) return xalthost = xhost.FirstChildElement('alt_host') while xalthost: url = xalthost.Attribute('url') if url == self.hostUrl: self.readHostXml(xalthost) return xalthost = xalthost.NextSiblingElement('alt_host') xhost = xhost.NextSiblingElement('host') def __findHostXmlForHostDir(self, xcontents): """ Looks for the <host> or <alt_host> entry in the contents.xml that corresponds to the host dir that we read the contents.xml from. This is used when reading a contents.xml file found on disk, as opposed to downloading it from a site. """ xhost = xcontents.FirstChildElement('host') while xhost: url = xhost.Attribute('url') hostDirBasename = xhost.Attribute('host_dir') hostDir = self.__determineHostDir(hostDirBasename, url) if hostDir == self.hostDir: self.__setHostUrl(url) self.readHostXml(xhost) return xalthost = xhost.FirstChildElement('alt_host') while xalthost: url = xalthost.Attribute('url') hostDirBasename = xalthost.Attribute('host_dir') hostDir = self.__determineHostDir(hostDirBasename, url) if hostDir == self.hostDir: self.__setHostUrl(url) self.readHostXml(xalthost) return xalthost = xalthost.NextSiblingElement('alt_host') xhost = xhost.NextSiblingElement('host') def readHostXml(self, xhost): """ Reads a <host> or <alt_host> entry and applies the data to this object. """ descriptiveName = xhost.Attribute('descriptive_name') if descriptiveName and not self.descriptiveName: self.descriptiveName = descriptiveName hostDirBasename = xhost.Attribute('host_dir') if not self.hostDir: self.hostDir = self.__determineHostDir(hostDirBasename, self.hostUrl) # Get the "download" URL, which is the source from which we # download everything other than the contents.xml file. downloadUrl = xhost.Attribute('download_url') if downloadUrl: self.downloadUrlPrefix = downloadUrl if self.downloadUrlPrefix[-1] != '/': self.downloadUrlPrefix += '/' else: self.downloadUrlPrefix = self.hostUrlPrefix xmirror = xhost.FirstChildElement('mirror') while xmirror: url = xmirror.Attribute('url') if url: if url[-1] != '/': url += '/' if url not in self.mirrors: self.mirrors.append(url) xmirror = xmirror.NextSiblingElement('mirror') xalthost = xhost.FirstChildElement('alt_host') while xalthost: keyword = xalthost.Attribute('keyword') url = xalthost.Attribute('url') if url and keyword: self.altHosts[keyword] = url xalthost = xalthost.NextSiblingElement('alt_host') def __makePackage(self, name, platform, version, solo, perPlatform): """ Creates a new PackageInfo entry for the given name, version, and platform. If there is already a matching PackageInfo, returns it. """ if not platform: # Ensure that we're on the same page with non-specified # platforms. We always use None, not empty string. platform = None platforms = self.packages.setdefault((name, version), {}) package = platforms.get(platform, None) if not package: package = PackageInfo(self, name, version, platform = platform, solo = solo, asMirror = self.asMirror, perPlatform = perPlatform) platforms[platform] = package return package def getPackage(self, name, version, platform = None): """ Returns a PackageInfo that matches the indicated name and version and the indicated platform or the current runtime platform, if one is provided by this host, or None if not. """ assert self.hasContentsFile platforms = self.packages.get((name, version or None), {}) if platform is not None: # In this case, we are looking for a specific platform # only. return platforms.get(platform or None, None) # We are looking for one matching the current runtime # platform. First, look for a package matching the current # platform exactly. package = platforms.get(PandaSystem.getPlatform(), None) # If not found, look for one matching no particular platform. if not package: package = platforms.get(None, None) return package def getPackages(self, name = None, platform = None): """ Returns a list of PackageInfo objects that match the indicated name and/or platform, with no particular regards to version. If name is None, all packages are returned. """ assert self.hasContentsFile packages = [] for (pn, version), platforms in self.packages.items(): if name and pn != name: continue if platform is None: for p2 in platforms: package = self.getPackage(pn, version, platform = p2) if package: packages.append(package) else: package = self.getPackage(pn, version, platform = platform) if package: packages.append(package) return packages def getAllPackages(self, includeAllPlatforms = False): """ Returns a list of all available packages provided by this host. """ result = [] items = self.packages.items() items.sort() for key, platforms in items: if self.perPlatform or includeAllPlatforms: # If we maintain a different answer per platform, # return all of them. pitems = platforms.items() pitems.sort() for pkey, package in pitems: result.append(package) else: # If we maintain a host for the current platform # only (e.g. a client copy), then return only the # current platform, or no particular platform. package = platforms.get(PandaSystem.getPlatform(), None) if not package: package = platforms.get(None, None) if package: result.append(package) return result def deletePackages(self, packages): """ Removes all of the indicated packages from the disk, uninstalling them and deleting all of their files. The packages parameter must be a list of one or more PackageInfo objects, for instance as returned by getPackage(). Returns the list of packages that were NOT found. """ packages = packages[:] for key, platforms in self.packages.items(): for platform, package in platforms.items(): if package in packages: self.__deletePackageFiles(package) del platforms[platform] packages.remove(package) if not platforms: # If we've removed all the platforms for a given # package, remove the key from the toplevel map. del self.packages[key] return packages def __deletePackageFiles(self, package): """ Called by deletePackage(), this actually removes the files for the indicated package. """ if self.appRunner: self.notify.info("Deleting package %s: %s" % (package.packageName, package.getPackageDir())) self.appRunner.rmtree(package.getPackageDir()) self.appRunner.sendRequest('forget_package', self.hostUrl, package.packageName, package.packageVersion or '') def __determineHostDir(self, hostDirBasename, hostUrl): """ Hashes the host URL into a (mostly) unique directory string, which will be the root of the host's install tree. Returns the resulting path, as a Filename. This code is duplicated in C++, in P3DHost::determine_host_dir(). """ if hostDirBasename: # If the contents.xml specified a host_dir parameter, use # it. hostDir = self.rootDir.cStr() + '/hosts' for component in hostDirBasename.split('/'): if component: if component[0] == '.': # Forbid ".foo" or "..". component = 'x' + component hostDir += '/' hostDir += component return Filename(hostDir) hostDir = 'hosts/' # Look for a server name in the URL. Including this string in the # directory name makes it friendlier for people browsing the # directory. # We could use URLSpec, but we do it by hand instead, to make # it more likely that our hash code will exactly match the # similar logic in P3DHost. p = hostUrl.find('://') hostname = '' if p != -1: start = p + 3 end = hostUrl.find('/', start) # Now start .. end is something like "username@host:port". at = hostUrl.find('@', start) if at != -1 and at < end: start = at + 1 colon = hostUrl.find(':', start) if colon != -1 and colon < end: end = colon # Now start .. end is just the hostname. hostname = hostUrl[start : end] # Now build a hash string of the whole URL. We'll use MD5 to # get a pretty good hash, with a minimum chance of collision. # Even if there is a hash collision, though, it's not the end # of the world; it just means that both hosts will dump their # packages into the same directory, and they'll fight over the # toplevel contents.xml file. Assuming they use different # version numbers (which should be safe since they have the # same hostname), there will be minimal redownloading. hashSize = 16 keepHash = hashSize if hostname: hostDir += hostname + '_' # If we successfully got a hostname, we don't really need the # full hash. We'll keep half of it. keepHash = keepHash / 2; md = HashVal() md.hashString(hostUrl) hostDir += md.asHex()[:keepHash * 2] hostDir = Filename(self.rootDir, hostDir) return hostDir
bsd-3-clause
[ 504, 299, 460, 645, 14, 48, 18328, 17981, 492, 16101, 7562, 12, 31167, 12, 510, 18328, 3989, 12, 7543, 5307, 12, 820, 455, 493, 199, 504, 299, 460, 645, 14, 48, 18328, 17981, 492, 3101, 5358, 199, 504, 299, 460, 645, 492, 510, 18328, 17981, 199, 504, 1973, 80, 18328, 476, 2915, 492, 4094, 2773, 3241, 199, 504, 4125, 14, 80, 19, 68, 14, 8599, 2354, 492, 15665, 2354, 199, 504, 4125, 14, 80, 19, 68, 14, 1173, 5307, 492, 3814, 5307, 199, 504, 4125, 14, 2275, 6814, 14, 16281, 8645, 7025, 492, 4125, 8645, 199, 646, 900, 199, 199, 533, 10891, 2354, 26, 272, 408, 961, 1021, 8469, 282, 6770, 5235, 1591, 22701, 1536, 272, 510, 18328, 19, 36, 6117, 14, 221, 2779, 365, 314, 2018, 7353, 402, 314, 510, 19, 36, 4965, 272, 1021, 315, 314, 6170, 3261, 14, 408, 339, 11705, 275, 4125, 8645, 14, 1222, 7841, 480, 4965, 2354, 531, 339, 347, 636, 826, 721, 277, 12, 1591, 6417, 12, 1145, 7446, 275, 488, 12, 1591, 3567, 275, 488, 12, 326, 1738, 3567, 275, 488, 12, 465, 28034, 275, 756, 12, 1126, 10397, 275, 488, 304, 398, 408, 2047, 1471, 4165, 1902, 376, 1145, 7446, 503, 282, 1591, 3567, 370, 314, 267, 10891, 2354, 3787, 14, 398, 982, 1265, 986, 465, 28034, 275, 715, 12, 652, 4910, 626, 642, 10891, 2354, 267, 909, 365, 370, 506, 1202, 370, 13904, 282, 298, 12324, 2, 4922, 12, 282, 267, 9250, 334, 269, 10026, 9, 402, 314, 4072, 28311, 701, 282, 1654, 14, 267, 961, 4910, 1380, 1265, 675, 642, 10891, 2354, 370, 5235, 6117, 12, 652, 267, 911, 1454, 5235, 314, 12335, 6359, 570, 436, 10137, 652, 267, 2337, 14, 221, 2854, 314, 12427, 12, 15216, 16533, 886, 440, 5235, 2269, 267, 3371, 1584, 687, 314, 1654, 14, 398, 982, 1265, 986, 1126, 10397, 275, 715, 12, 2066, 1584, 787, 23389, 1901, 282, 267, 4298, 13, 6100, 2082, 12, 1314, 365, 5827, 1380, 1265, 267, 5594, 506, 25937, 3663, 10677, 14, 221, 710, 849, 365, 267, 1126, 10397, 275, 756, 12, 1314, 4910, 1006, 1584, 787, 23389, 1901, 267, 314, 1591, 2082, 5370, 12, 1928, 376, 1640, 1856, 316, 267, 4298, 13, 6100, 2082, 536, 14, 221, 982, 465, 28034, 365, 715, 12, 2066, 267, 314, 849, 365, 1126, 10397, 275, 715, 14, 398, 3390, 626, 1126, 10397, 365, 2597, 15297, 701, 314, 8212, 267, 2559, 1159, 8929, 14, 221, 408, 398, 702, 1145, 7446, 503, 1738, 3567, 503, 1591, 3567, 398, 291, 855, 409, 4965, 6417, 8, 1102, 6417, 9, 267, 291, 14, 571, 7446, 275, 1145, 7446, 267, 291, 14, 1231, 3567, 275, 1738, 3567, 267, 340, 1738, 3567, 365, 488, 436, 1145, 7446, 26, 288, 291, 14, 1231, 3567, 275, 1145, 7446, 14, 1231, 3567, 398, 340, 1591, 3567, 436, 440, 1228, 8, 1102, 3567, 12, 31167, 304, 288, 1591, 3567, 275, 31167, 14, 504, 24351, 16786, 8, 1102, 3567, 9, 10631, 291, 14, 1102, 3567, 275, 1591, 3567, 267, 291, 14, 305, 28034, 275, 465, 28034, 267, 291, 14, 529, 10397, 275, 1126, 10397, 267, 340, 1126, 10397, 365, 488, 26, 288, 291, 14, 529, 10397, 275, 465, 28034, 398, 327, 21412, 1183, 3055, 12, 642, 365, 663, 2549, 1380, 314, 4072, 570, 365, 267, 327, 8792, 1586, 14, 267, 291, 14, 1989, 11383, 1173, 275, 756, 398, 327, 961, 365, 314, 900, 574, 737, 1314, 314, 1453, 4072, 570, 365, 267, 327, 949, 8088, 1686, 14, 267, 291, 14, 4407, 14000, 1754, 275, 378, 398, 327, 22493, 314, 6128, 21, 2631, 402, 314, 3379, 4072, 14, 1652, 570, 14, 267, 291, 14, 4407, 5307, 275, 3814, 5307, 342, 398, 327, 30262, 985, 911, 506, 13457, 315, 2945, 12, 1380, 314, 267, 327, 4072, 570, 365, 1586, 14, 267, 291, 14, 271, 729, 21701, 985, 275, 488, 398, 327, 437, 769, 402, 6040, 15216, 83, 367, 642, 1591, 12, 1006, 2851, 1159, 17334, 267, 327, 370, 1284, 543, 282, 14457, 14, 267, 291, 14, 12324, 83, 275, 942, 398, 327, 437, 2341, 402, 4252, 1035, 8791, 4965, 2851, 1159, 14, 221, 1626, 8791, 4965, 365, 3365, 267, 327, 2419, 282, 15216, 27, 376, 8791, 4965, 365, 376, 18034, 2851, 370, 5235, 282, 267, 327, 3365, 334, 69, 14, 71, 14, 5343, 9, 1015, 402, 642, 1591, 1159, 4072, 14, 267, 327, 2779, 365, 24063, 590, 1202, 14, 267, 291, 14, 4478, 19620, 275, 1052, 398, 327, 961, 365, 282, 2600, 402, 6117, 701, 334, 354, 12, 1015, 680, 221, 2779, 267, 327, 911, 506, 13457, 315, 1380, 314, 4072, 570, 365, 1586, 14, 267, 291, 14, 5154, 275, 1052, 398, 340, 291, 14, 571, 7446, 436, 291, 14, 571, 7446, 14, 4712, 11383, 1137, 291, 14, 571, 7446, 14, 48, 19, 6741, 35, 13606, 26, 288, 327, 23115, 370, 876, 13, 739, 314, 3411, 4072, 14, 1652, 27, 11703, 652, 288, 327, 911, 506, 1453, 8321, 367, 4154, 12901, 14, 288, 291, 14, 739, 11383, 1173, 342, 339, 347, 636, 409, 4965, 6417, 8, 277, 12, 1591, 6417, 304, 267, 408, 3709, 20440, 291, 14, 1102, 6417, 12, 436, 4048, 1338, 14, 408, 267, 291, 14, 1102, 6417, 275, 1591, 6417, 398, 340, 440, 291, 14, 1102, 6417, 26, 288, 327, 437, 4539, 1930, 26, 314, 2851, 911, 506, 663, 2945, 14, 288, 291, 14, 1102, 6417, 4793, 275, 488, 288, 291, 14, 4249, 6417, 4793, 275, 488, 267, 587, 26, 288, 327, 1591, 6417, 4793, 365, 314, 1591, 2851, 12, 1325, 652, 365, 17334, 370, 1284, 288, 327, 543, 282, 14457, 14, 288, 291, 14, 1102, 6417, 4793, 275, 1591, 6417, 288, 340, 291, 14, 1102, 6417, 4793, 1988, 17, 61, 1137, 20549, 355, 291, 14, 1102, 6417, 4793, 847, 7324, 953, 327, 5235, 6417, 4793, 365, 314, 2851, 2403, 626, 1077, 506, 1202, 367, 288, 327, 8137, 1163, 2419, 314, 4072, 14, 1652, 570, 14, 221, 2779, 5594, 506, 288, 327, 314, 2011, 465, 1591, 6417, 4793, 12, 1325, 315, 314, 1930, 402, 376, 288, 327, 4178, 13, 6798, 1591, 6417, 12, 652, 911, 506, 314, 5436, 505, 3623, 14, 288, 291, 14, 4249, 6417, 4793, 275, 291, 14, 1102, 6417, 4793, 339, 347, 5235, 11383 ]
[ 299, 460, 645, 14, 48, 18328, 17981, 492, 16101, 7562, 12, 31167, 12, 510, 18328, 3989, 12, 7543, 5307, 12, 820, 455, 493, 199, 504, 299, 460, 645, 14, 48, 18328, 17981, 492, 3101, 5358, 199, 504, 299, 460, 645, 492, 510, 18328, 17981, 199, 504, 1973, 80, 18328, 476, 2915, 492, 4094, 2773, 3241, 199, 504, 4125, 14, 80, 19, 68, 14, 8599, 2354, 492, 15665, 2354, 199, 504, 4125, 14, 80, 19, 68, 14, 1173, 5307, 492, 3814, 5307, 199, 504, 4125, 14, 2275, 6814, 14, 16281, 8645, 7025, 492, 4125, 8645, 199, 646, 900, 199, 199, 533, 10891, 2354, 26, 272, 408, 961, 1021, 8469, 282, 6770, 5235, 1591, 22701, 1536, 272, 510, 18328, 19, 36, 6117, 14, 221, 2779, 365, 314, 2018, 7353, 402, 314, 510, 19, 36, 4965, 272, 1021, 315, 314, 6170, 3261, 14, 408, 339, 11705, 275, 4125, 8645, 14, 1222, 7841, 480, 4965, 2354, 531, 339, 347, 636, 826, 721, 277, 12, 1591, 6417, 12, 1145, 7446, 275, 488, 12, 1591, 3567, 275, 488, 12, 326, 1738, 3567, 275, 488, 12, 465, 28034, 275, 756, 12, 1126, 10397, 275, 488, 304, 398, 408, 2047, 1471, 4165, 1902, 376, 1145, 7446, 503, 282, 1591, 3567, 370, 314, 267, 10891, 2354, 3787, 14, 398, 982, 1265, 986, 465, 28034, 275, 715, 12, 652, 4910, 626, 642, 10891, 2354, 267, 909, 365, 370, 506, 1202, 370, 13904, 282, 298, 12324, 2, 4922, 12, 282, 267, 9250, 334, 269, 10026, 9, 402, 314, 4072, 28311, 701, 282, 1654, 14, 267, 961, 4910, 1380, 1265, 675, 642, 10891, 2354, 370, 5235, 6117, 12, 652, 267, 911, 1454, 5235, 314, 12335, 6359, 570, 436, 10137, 652, 267, 2337, 14, 221, 2854, 314, 12427, 12, 15216, 16533, 886, 440, 5235, 2269, 267, 3371, 1584, 687, 314, 1654, 14, 398, 982, 1265, 986, 1126, 10397, 275, 715, 12, 2066, 1584, 787, 23389, 1901, 282, 267, 4298, 13, 6100, 2082, 12, 1314, 365, 5827, 1380, 1265, 267, 5594, 506, 25937, 3663, 10677, 14, 221, 710, 849, 365, 267, 1126, 10397, 275, 756, 12, 1314, 4910, 1006, 1584, 787, 23389, 1901, 267, 314, 1591, 2082, 5370, 12, 1928, 376, 1640, 1856, 316, 267, 4298, 13, 6100, 2082, 536, 14, 221, 982, 465, 28034, 365, 715, 12, 2066, 267, 314, 849, 365, 1126, 10397, 275, 715, 14, 398, 3390, 626, 1126, 10397, 365, 2597, 15297, 701, 314, 8212, 267, 2559, 1159, 8929, 14, 221, 408, 398, 702, 1145, 7446, 503, 1738, 3567, 503, 1591, 3567, 398, 291, 855, 409, 4965, 6417, 8, 1102, 6417, 9, 267, 291, 14, 571, 7446, 275, 1145, 7446, 267, 291, 14, 1231, 3567, 275, 1738, 3567, 267, 340, 1738, 3567, 365, 488, 436, 1145, 7446, 26, 288, 291, 14, 1231, 3567, 275, 1145, 7446, 14, 1231, 3567, 398, 340, 1591, 3567, 436, 440, 1228, 8, 1102, 3567, 12, 31167, 304, 288, 1591, 3567, 275, 31167, 14, 504, 24351, 16786, 8, 1102, 3567, 9, 10631, 291, 14, 1102, 3567, 275, 1591, 3567, 267, 291, 14, 305, 28034, 275, 465, 28034, 267, 291, 14, 529, 10397, 275, 1126, 10397, 267, 340, 1126, 10397, 365, 488, 26, 288, 291, 14, 529, 10397, 275, 465, 28034, 398, 327, 21412, 1183, 3055, 12, 642, 365, 663, 2549, 1380, 314, 4072, 570, 365, 267, 327, 8792, 1586, 14, 267, 291, 14, 1989, 11383, 1173, 275, 756, 398, 327, 961, 365, 314, 900, 574, 737, 1314, 314, 1453, 4072, 570, 365, 267, 327, 949, 8088, 1686, 14, 267, 291, 14, 4407, 14000, 1754, 275, 378, 398, 327, 22493, 314, 6128, 21, 2631, 402, 314, 3379, 4072, 14, 1652, 570, 14, 267, 291, 14, 4407, 5307, 275, 3814, 5307, 342, 398, 327, 30262, 985, 911, 506, 13457, 315, 2945, 12, 1380, 314, 267, 327, 4072, 570, 365, 1586, 14, 267, 291, 14, 271, 729, 21701, 985, 275, 488, 398, 327, 437, 769, 402, 6040, 15216, 83, 367, 642, 1591, 12, 1006, 2851, 1159, 17334, 267, 327, 370, 1284, 543, 282, 14457, 14, 267, 291, 14, 12324, 83, 275, 942, 398, 327, 437, 2341, 402, 4252, 1035, 8791, 4965, 2851, 1159, 14, 221, 1626, 8791, 4965, 365, 3365, 267, 327, 2419, 282, 15216, 27, 376, 8791, 4965, 365, 376, 18034, 2851, 370, 5235, 282, 267, 327, 3365, 334, 69, 14, 71, 14, 5343, 9, 1015, 402, 642, 1591, 1159, 4072, 14, 267, 327, 2779, 365, 24063, 590, 1202, 14, 267, 291, 14, 4478, 19620, 275, 1052, 398, 327, 961, 365, 282, 2600, 402, 6117, 701, 334, 354, 12, 1015, 680, 221, 2779, 267, 327, 911, 506, 13457, 315, 1380, 314, 4072, 570, 365, 1586, 14, 267, 291, 14, 5154, 275, 1052, 398, 340, 291, 14, 571, 7446, 436, 291, 14, 571, 7446, 14, 4712, 11383, 1137, 291, 14, 571, 7446, 14, 48, 19, 6741, 35, 13606, 26, 288, 327, 23115, 370, 876, 13, 739, 314, 3411, 4072, 14, 1652, 27, 11703, 652, 288, 327, 911, 506, 1453, 8321, 367, 4154, 12901, 14, 288, 291, 14, 739, 11383, 1173, 342, 339, 347, 636, 409, 4965, 6417, 8, 277, 12, 1591, 6417, 304, 267, 408, 3709, 20440, 291, 14, 1102, 6417, 12, 436, 4048, 1338, 14, 408, 267, 291, 14, 1102, 6417, 275, 1591, 6417, 398, 340, 440, 291, 14, 1102, 6417, 26, 288, 327, 437, 4539, 1930, 26, 314, 2851, 911, 506, 663, 2945, 14, 288, 291, 14, 1102, 6417, 4793, 275, 488, 288, 291, 14, 4249, 6417, 4793, 275, 488, 267, 587, 26, 288, 327, 1591, 6417, 4793, 365, 314, 1591, 2851, 12, 1325, 652, 365, 17334, 370, 1284, 288, 327, 543, 282, 14457, 14, 288, 291, 14, 1102, 6417, 4793, 275, 1591, 6417, 288, 340, 291, 14, 1102, 6417, 4793, 1988, 17, 61, 1137, 20549, 355, 291, 14, 1102, 6417, 4793, 847, 7324, 953, 327, 5235, 6417, 4793, 365, 314, 2851, 2403, 626, 1077, 506, 1202, 367, 288, 327, 8137, 1163, 2419, 314, 4072, 14, 1652, 570, 14, 221, 2779, 5594, 506, 288, 327, 314, 2011, 465, 1591, 6417, 4793, 12, 1325, 315, 314, 1930, 402, 376, 288, 327, 4178, 13, 6798, 1591, 6417, 12, 652, 911, 506, 314, 5436, 505, 3623, 14, 288, 291, 14, 4249, 6417, 4793, 275, 291, 14, 1102, 6417, 4793, 339, 347, 5235, 11383, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kirca/OpenUpgrade
addons/portal_gamification/__openerp__.py
381
1571
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2013 OpenERP SA (<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': 'Portal Gamification', 'version': '1', 'category': 'Tools', 'complexity': 'easy', 'description': """ This module adds security rules for gamification to allow portal users to participate to challenges =================================================================================================== """, 'author': 'OpenERP SA', 'depends': ['gamification','portal'], 'data': [ 'security/ir.model.access.csv', 'security/portal_security.xml', ], 'installable': True, 'auto_install': True, 'category': 'Hidden', }
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, 6171, 7653, 13950, 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, 26708, 598, 455, 7313, 297, 272, 283, 1023, 356, 283, 17, 297, 272, 283, 3710, 356, 283, 11654, 297, 272, 283, 5254, 1209, 356, 283, 13581, 297, 272, 283, 1802, 356, 408, 199, 2765, 859, 9584, 6391, 4713, 367, 486, 455, 7313, 370, 2040, 18428, 4390, 370, 623, 10479, 323, 370, 682, 30599, 199, 5695, 2486, 5918, 272, 10327, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 8912, 356, 788, 17740, 7313, 1673, 8707, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 4416, 15, 8707, 63, 4416, 14, 1652, 297, 272, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 715, 12, 272, 283, 3710, 356, 283, 14983, 297, 199, 93, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 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, 6171, 7653, 13950, 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, 26708, 598, 455, 7313, 297, 272, 283, 1023, 356, 283, 17, 297, 272, 283, 3710, 356, 283, 11654, 297, 272, 283, 5254, 1209, 356, 283, 13581, 297, 272, 283, 1802, 356, 408, 199, 2765, 859, 9584, 6391, 4713, 367, 486, 455, 7313, 370, 2040, 18428, 4390, 370, 623, 10479, 323, 370, 682, 30599, 199, 5695, 2486, 5918, 272, 10327, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 8912, 356, 788, 17740, 7313, 1673, 8707, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 4416, 15, 8707, 63, 4416, 14, 1652, 297, 272, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 715, 12, 272, 283, 3710, 356, 283, 14983, 297, 199, 93, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
emilianobilli/stog
stog.py
2
3129
import httplib import json import urllib import socket import getpass class stogError(Exception): def __init__(self, value, critical=False): self.value = value self.critical = critical def __str__(self): return str(self.value) def __repr__(self): return self.value class stogClient(object): def __init__(self, host = None, port = None, username = None, password = None): self.headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/json"} self.host = host self.port = port self.username = '' self.password = '' self.commands = [] self.srvmsg = '' self.srvauth = '' if host is not None and port is not None: try: conn = httplib.HTTPConnection(self.host,self.port) conn.request("GET", "/") response = conn.getresponse() jsr = json.loads(response.read()) self.commands = jsr['commands'] self.srvmsg = jsr['srvmsg'] self.srvauth = jsr['srvauth'] except socket.error as e: raise stogError("[%s:%d] -> %s\n" % (self.host, self.port, e)) if username is not None and password is not None: self.username = username self.password = password def getuser(self): user = raw_input("Username [%s]: " % getpass.getuser()) if not user: self.username = getpass.getuser() else: self.username = user self.password = getpass.getpass() def __command(self, command, arg = None): if arg is None: return urllib.urlencode({'username':self.username, 'password':self.password,'command':command}) else: return utllib.urlencode({'username':self.username, 'password':self.password,'command':command, 'arg':arg}) def doList(self): param = self.__command('LIST') try: conn = httplib.HTTPConnection(self.host, self.port) conn.request("POST", "", param, self.headers) response = conn.getresponse() print response.status except socket.error as e: raise stogError("[%s:%d] -> %s\n" % (self.host, self.port, e)) if response.status == 200: jslist = response.read() print jslist def doStor(self): param = self.__command('STOR') pass def doRetr(self, filename, WriteCallBack): param = self.__command('RETR', filename) try: conn = httplib.HTTPConnection(self.host, self.port) conn.request("POST", "", param, self.headers) response = conn.getresponse() except socket.error as e: raise stogError("[%s:%d] -> %s\n" % (self.host, self.port, e)) if response.status == 200: rsp = json.dumps(response.read()) sd = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def main(): end = False stog = None while not end: cmd = raw_input('stog> ') if cmd.upper() == 'QUIT': end = True elif cmd.upper() == 'CONNECT': host = raw_input('Hostname: ') if host: port = raw_input('Port: ') if port: stog = stogClient(host,int(port)) elif cmd.upper() == 'LIST': if stog: stog.doList() else: print "Not connected" elif cmd.upper() == 'STOR': pass elif cmd.upper() == 'RETR': pass else: print "Command not found\n" if __name__ == "__main__": main()
gpl-2.0
[ 646, 8809, 199, 646, 2022, 199, 646, 4011, 199, 646, 2838, 199, 646, 18354, 4388, 199, 533, 410, 974, 547, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 574, 12, 19698, 29, 797, 304, 199, 198, 277, 14, 585, 259, 275, 574, 199, 198, 277, 14, 13138, 275, 19698, 272, 347, 636, 495, 721, 277, 304, 199, 198, 1107, 620, 8, 277, 14, 585, 9, 272, 347, 636, 2722, 721, 277, 304, 199, 198, 1107, 291, 14, 585, 421, 199, 533, 410, 974, 3041, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1591, 275, 488, 12, 1844, 275, 488, 12, 3434, 275, 488, 12, 2505, 275, 488, 304, 199, 198, 277, 14, 2139, 275, 2420, 2714, 13, 466, 582, 298, 3578, 15, 88, 13, 1544, 13, 964, 13, 21886, 401, 686, 198, 2, 8422, 582, 298, 505, 15, 1001, 3570, 199, 198, 277, 14, 1102, 275, 1591, 199, 198, 277, 14, 719, 275, 1844, 199, 198, 277, 14, 2473, 275, 2125, 199, 198, 277, 14, 2060, 275, 2125, 199, 198, 277, 14, 4405, 275, 942, 199, 198, 277, 14, 15165, 1328, 257, 275, 2125, 199, 198, 277, 14, 15165, 1178, 221, 275, 2125, 421, 198, 692, 1591, 365, 440, 488, 436, 1844, 365, 440, 488, 26, 6722, 862, 26, 507, 198, 1631, 275, 8809, 14, 19114, 8, 277, 14, 1102, 12, 277, 14, 719, 9, 507, 198, 1631, 14, 1069, 480, 2970, 401, 3286, 531, 507, 198, 1310, 275, 2557, 14, 25006, 342, 507, 198, 3596, 82, 275, 2022, 14, 3640, 8, 1310, 14, 739, 1012, 507, 198, 277, 14, 4405, 275, 1335, 5474, 459, 4405, 418, 507, 198, 277, 14, 15165, 1328, 257, 275, 1335, 5474, 459, 15165, 1328, 418, 507, 198, 277, 14, 15165, 1178, 221, 275, 1335, 5474, 459, 15165, 1178, 418, 6722, 871, 2838, 14, 705, 465, 325, 26, 507, 198, 3730, 410, 974, 547, 480, 9722, 83, 2689, 68, 61, 1035, 450, 83, 60, 78, 2, 450, 334, 277, 14, 1102, 12, 291, 14, 719, 12, 325, 430, 421, 198, 692, 3434, 365, 440, 488, 436, 2505, 365, 440, 488, 26, 6722, 291, 14, 2473, 275, 3434, 6722, 291, 14, 2060, 275, 2505, 2286, 347, 664, 751, 8, 277, 304, 199, 198, 751, 275, 3066, 63, 1210, 480, 13355, 8978, 83, 2189, 298, 450, 18354, 14, 362, 751, 1012, 199, 198, 692, 440, 922, 26, 19066, 259, 291, 14, 2473, 275, 18354, 14, 362, 751, 342, 199, 198, 2836, 26, 6722, 291, 14, 2473, 275, 922, 199, 198, 277, 14, 2060, 275, 18354, 14, 27481, 342, 339, 347, 636, 1531, 8, 277, 12, 1414, 12, 1680, 275, 488, 304, 199, 198, 692, 1680, 365, 488, 26, 6722, 372, 4011, 14, 10738, 3252, 2473, 356, 277, 14, 2473, 12, 283, 2060, 356, 277, 14, 2060, 2584, 1531, 356, 1531, 1552, 199, 198, 2836, 26, 6722, 372, 11430, 76, 773, 14, 10738, 3252, 2473, 356, 277, 14, 2473, 12, 283, 2060, 356, 277, 14, 2060, 2584, 1531, 356, 1531, 12, 283, 1273, 356, 1273, 1552, 339, 347, 886, 1296, 8, 277, 304, 199, 198, 635, 275, 291, 855, 1531, 360, 4924, 358, 199, 198, 893, 26, 6722, 2557, 275, 8809, 14, 19114, 8, 277, 14, 1102, 12, 291, 14, 719, 9, 6722, 2557, 14, 1069, 480, 4030, 401, 4873, 1215, 12, 291, 14, 2139, 9, 6722, 1177, 275, 2557, 14, 25006, 342, 6722, 870, 1177, 14, 1205, 199, 198, 2590, 2838, 14, 705, 465, 325, 26, 6722, 746, 410, 974, 547, 480, 9722, 83, 2689, 68, 61, 1035, 450, 83, 60, 78, 2, 450, 334, 277, 14, 1102, 12, 291, 14, 719, 12, 325, 430, 421, 198, 692, 1177, 14, 1205, 508, 1926, 26, 6722, 8586, 513, 275, 1177, 14, 739, 342, 6722, 870, 8586, 513, 2742, 258, 339, 347, 886, 933, 269, 8, 277, 304, 199, 198, 635, 275, 291, 855, 1531, 360, 13774, 358, 199, 198, 1529, 339, 347, 886, 6816, 82, 8, 277, 12, 1788, 12, 6990, 2176, 4540, 304, 199, 198, 635, 275, 291, 855, 1531, 360, 7341, 50, 297, 1788, 9, 199, 198, 893, 26, 221, 6722, 2557, 275, 8809, 14, 19114, 8, 277, 14, 1102, 12, 291, 14, 719, 9, 6722, 2557, 14, 1069, 480, 4030, 401, 4873, 1215, 12, 291, 14, 2139, 9, 6722, 1177, 275, 2557, 14, 25006, 342, 199, 198, 2590, 2838, 14, 705, 465, 325, 26, 6722, 746, 410, 974, 547, 480, 9722, 83, 2689, 68, 61, 1035, 450, 83, 60, 78, 2, 450, 334, 277, 14, 1102, 12, 291, 14, 719, 12, 325, 430, 421, 198, 692, 1177, 14, 1205, 508, 1926, 26, 6722, 13684, 275, 2022, 14, 4180, 8, 1310, 14, 739, 1012, 6722, 14613, 221, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 4388, 199, 318, 2446, 837, 272, 1284, 221, 275, 756, 272, 410, 974, 275, 488, 272, 1830, 440, 1284, 26, 199, 198, 1760, 275, 3066, 63, 1210, 360, 270, 974, 30, 5320, 421, 198, 692, 2088, 14, 4142, 342, 508, 283, 2328, 649, 356, 6722, 1284, 275, 715, 199, 198, 4164, 2088, 14, 4142, 342, 508, 283, 14657, 356, 6722, 1591, 275, 3066, 63, 1210, 360, 25680, 26, 5320, 6722, 340, 1591, 26, 507, 198, 719, 275, 3066, 63, 1210, 360, 4313, 26, 5320, 507, 198, 692, 1844, 26, 15075, 410, 974, 275, 410, 974, 3041, 8, 1102, 12, 442, 8, 719, 430, 18118, 198, 4164, 2088, 14, 4142, 342, 508, 283, 4924, 356, 6722, 340, 410, 974, 26, 507, 198, 270, 974, 14, 1117, 1296, 342, 6722, 587, 26, 507, 198, 1361, 298, 1763, 8539, 2, 199, 198, 4164, 2088, 14, 4142, 342, 508, 283, 13774, 356, 6722, 986, 199, 198, 4164, 2088, 14, 4142, 342, 508, 283, 7341, 50, 356, 6722, 986, 199, 198, 2836, 26, 6722, 870, 298, 3110, 440, 1911, 60, 78, 2, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 342, 6905, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8809, 199, 646, 2022, 199, 646, 4011, 199, 646, 2838, 199, 646, 18354, 4388, 199, 533, 410, 974, 547, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 574, 12, 19698, 29, 797, 304, 199, 198, 277, 14, 585, 259, 275, 574, 199, 198, 277, 14, 13138, 275, 19698, 272, 347, 636, 495, 721, 277, 304, 199, 198, 1107, 620, 8, 277, 14, 585, 9, 272, 347, 636, 2722, 721, 277, 304, 199, 198, 1107, 291, 14, 585, 421, 199, 533, 410, 974, 3041, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1591, 275, 488, 12, 1844, 275, 488, 12, 3434, 275, 488, 12, 2505, 275, 488, 304, 199, 198, 277, 14, 2139, 275, 2420, 2714, 13, 466, 582, 298, 3578, 15, 88, 13, 1544, 13, 964, 13, 21886, 401, 686, 198, 2, 8422, 582, 298, 505, 15, 1001, 3570, 199, 198, 277, 14, 1102, 275, 1591, 199, 198, 277, 14, 719, 275, 1844, 199, 198, 277, 14, 2473, 275, 2125, 199, 198, 277, 14, 2060, 275, 2125, 199, 198, 277, 14, 4405, 275, 942, 199, 198, 277, 14, 15165, 1328, 257, 275, 2125, 199, 198, 277, 14, 15165, 1178, 221, 275, 2125, 421, 198, 692, 1591, 365, 440, 488, 436, 1844, 365, 440, 488, 26, 6722, 862, 26, 507, 198, 1631, 275, 8809, 14, 19114, 8, 277, 14, 1102, 12, 277, 14, 719, 9, 507, 198, 1631, 14, 1069, 480, 2970, 401, 3286, 531, 507, 198, 1310, 275, 2557, 14, 25006, 342, 507, 198, 3596, 82, 275, 2022, 14, 3640, 8, 1310, 14, 739, 1012, 507, 198, 277, 14, 4405, 275, 1335, 5474, 459, 4405, 418, 507, 198, 277, 14, 15165, 1328, 257, 275, 1335, 5474, 459, 15165, 1328, 418, 507, 198, 277, 14, 15165, 1178, 221, 275, 1335, 5474, 459, 15165, 1178, 418, 6722, 871, 2838, 14, 705, 465, 325, 26, 507, 198, 3730, 410, 974, 547, 480, 9722, 83, 2689, 68, 61, 1035, 450, 83, 60, 78, 2, 450, 334, 277, 14, 1102, 12, 291, 14, 719, 12, 325, 430, 421, 198, 692, 3434, 365, 440, 488, 436, 2505, 365, 440, 488, 26, 6722, 291, 14, 2473, 275, 3434, 6722, 291, 14, 2060, 275, 2505, 2286, 347, 664, 751, 8, 277, 304, 199, 198, 751, 275, 3066, 63, 1210, 480, 13355, 8978, 83, 2189, 298, 450, 18354, 14, 362, 751, 1012, 199, 198, 692, 440, 922, 26, 19066, 259, 291, 14, 2473, 275, 18354, 14, 362, 751, 342, 199, 198, 2836, 26, 6722, 291, 14, 2473, 275, 922, 199, 198, 277, 14, 2060, 275, 18354, 14, 27481, 342, 339, 347, 636, 1531, 8, 277, 12, 1414, 12, 1680, 275, 488, 304, 199, 198, 692, 1680, 365, 488, 26, 6722, 372, 4011, 14, 10738, 3252, 2473, 356, 277, 14, 2473, 12, 283, 2060, 356, 277, 14, 2060, 2584, 1531, 356, 1531, 1552, 199, 198, 2836, 26, 6722, 372, 11430, 76, 773, 14, 10738, 3252, 2473, 356, 277, 14, 2473, 12, 283, 2060, 356, 277, 14, 2060, 2584, 1531, 356, 1531, 12, 283, 1273, 356, 1273, 1552, 339, 347, 886, 1296, 8, 277, 304, 199, 198, 635, 275, 291, 855, 1531, 360, 4924, 358, 199, 198, 893, 26, 6722, 2557, 275, 8809, 14, 19114, 8, 277, 14, 1102, 12, 291, 14, 719, 9, 6722, 2557, 14, 1069, 480, 4030, 401, 4873, 1215, 12, 291, 14, 2139, 9, 6722, 1177, 275, 2557, 14, 25006, 342, 6722, 870, 1177, 14, 1205, 199, 198, 2590, 2838, 14, 705, 465, 325, 26, 6722, 746, 410, 974, 547, 480, 9722, 83, 2689, 68, 61, 1035, 450, 83, 60, 78, 2, 450, 334, 277, 14, 1102, 12, 291, 14, 719, 12, 325, 430, 421, 198, 692, 1177, 14, 1205, 508, 1926, 26, 6722, 8586, 513, 275, 1177, 14, 739, 342, 6722, 870, 8586, 513, 2742, 258, 339, 347, 886, 933, 269, 8, 277, 304, 199, 198, 635, 275, 291, 855, 1531, 360, 13774, 358, 199, 198, 1529, 339, 347, 886, 6816, 82, 8, 277, 12, 1788, 12, 6990, 2176, 4540, 304, 199, 198, 635, 275, 291, 855, 1531, 360, 7341, 50, 297, 1788, 9, 199, 198, 893, 26, 221, 6722, 2557, 275, 8809, 14, 19114, 8, 277, 14, 1102, 12, 291, 14, 719, 9, 6722, 2557, 14, 1069, 480, 4030, 401, 4873, 1215, 12, 291, 14, 2139, 9, 6722, 1177, 275, 2557, 14, 25006, 342, 199, 198, 2590, 2838, 14, 705, 465, 325, 26, 6722, 746, 410, 974, 547, 480, 9722, 83, 2689, 68, 61, 1035, 450, 83, 60, 78, 2, 450, 334, 277, 14, 1102, 12, 291, 14, 719, 12, 325, 430, 421, 198, 692, 1177, 14, 1205, 508, 1926, 26, 6722, 13684, 275, 2022, 14, 4180, 8, 1310, 14, 739, 1012, 6722, 14613, 221, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 4388, 199, 318, 2446, 837, 272, 1284, 221, 275, 756, 272, 410, 974, 275, 488, 272, 1830, 440, 1284, 26, 199, 198, 1760, 275, 3066, 63, 1210, 360, 270, 974, 30, 5320, 421, 198, 692, 2088, 14, 4142, 342, 508, 283, 2328, 649, 356, 6722, 1284, 275, 715, 199, 198, 4164, 2088, 14, 4142, 342, 508, 283, 14657, 356, 6722, 1591, 275, 3066, 63, 1210, 360, 25680, 26, 5320, 6722, 340, 1591, 26, 507, 198, 719, 275, 3066, 63, 1210, 360, 4313, 26, 5320, 507, 198, 692, 1844, 26, 15075, 410, 974, 275, 410, 974, 3041, 8, 1102, 12, 442, 8, 719, 430, 18118, 198, 4164, 2088, 14, 4142, 342, 508, 283, 4924, 356, 6722, 340, 410, 974, 26, 507, 198, 270, 974, 14, 1117, 1296, 342, 6722, 587, 26, 507, 198, 1361, 298, 1763, 8539, 2, 199, 198, 4164, 2088, 14, 4142, 342, 508, 283, 13774, 356, 6722, 986, 199, 198, 4164, 2088, 14, 4142, 342, 508, 283, 7341, 50, 356, 6722, 986, 199, 198, 2836, 26, 6722, 870, 298, 3110, 440, 1911, 60, 78, 2, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 342, 6905, 4388, 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 ]
Peddle/hue
desktop/core/ext-py/cx_Oracle-5.1.2/test/uNumberVar.py
34
10867
"""Module for testing number variables.""" import cx_Oracle import decimal class TestNumberVar(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) self.rawData = [] self.dataByKey = {} for i in range(1, 11): numberCol = i + i * 0.25 floatCol = i + i * 0.75 unconstrainedCol = i ** 3 + i * 0.5 if i % 2: nullableCol = 143L ** i else: nullableCol = None dataTuple = (i, numberCol, floatCol, unconstrainedCol, nullableCol) self.rawData.append(dataTuple) self.dataByKey[i] = dataTuple def testBindDecimal(self): "test binding in a decimal.Decimal" self.cursor.execute(u""" select * from TestNumbers where NumberCol - :value1 - :value2 = trunc(NumberCol)""", value1 = decimal.Decimal("0.20"), value2 = decimal.Decimal("0.05")) self.failUnlessEqual(self.cursor.fetchall(), [self.dataByKey[1], self.dataByKey[5], self.dataByKey[9]]) def testBindFloat(self): "test binding in a float" self.cursor.execute(u""" select * from TestNumbers where NumberCol - :value = trunc(NumberCol)""", value = 0.25) self.failUnlessEqual(self.cursor.fetchall(), [self.dataByKey[1], self.dataByKey[5], self.dataByKey[9]]) def testBindInteger(self): "test binding in an integer" self.cursor.execute(u""" select * from TestNumbers where IntCol = :value""", value = 2) self.failUnlessEqual(self.cursor.fetchall(), [self.dataByKey[2]]) def testBindSmallLong(self): "test binding in a small long integer" self.cursor.execute(u""" select * from TestNumbers where IntCol = :value""", value = 3L) self.failUnlessEqual(self.cursor.fetchall(), [self.dataByKey[3]]) def testBindLargeLong(self): "test binding in a large long integer" valueVar = self.cursor.var(cx_Oracle.NUMBER) valueVar.setvalue(0, 6088343244) self.cursor.execute(u""" begin :value := :value + 5; end;""", value = valueVar) value = valueVar.getvalue() self.failUnlessEqual(value, 6088343249) def testBindIntegerAfterString(self): "test binding in an number after setting input sizes to a string" self.cursor.setinputsizes(value = 15) self.cursor.execute(u""" select * from TestNumbers where IntCol = :value""", value = 3) self.failUnlessEqual(self.cursor.fetchall(), [self.dataByKey[3]]) def testBindNull(self): "test binding in a null" self.cursor.execute(u""" select * from TestNumbers where IntCol = :value""", value = None) self.failUnlessEqual(self.cursor.fetchall(), []) def testBindNumberArrayDirect(self): "test binding in a number array" returnValue = self.cursor.var(cx_Oracle.NUMBER) array = [r[1] for r in self.rawData] statement = u""" begin :p_ReturnValue := pkg_TestNumberArrays.TestInArrays( :p_StartValue, :p_Array); end;""" self.cursor.execute(statement, p_ReturnValue = returnValue, p_StartValue = 5, p_Array = array) self.failUnlessEqual(returnValue.getvalue(), 73.75) array = range(15) self.cursor.execute(statement, p_StartValue = 10, p_Array = array) self.failUnlessEqual(returnValue.getvalue(), 115.0) def testBindNumberArrayBySizes(self): "test binding in a number array (with setinputsizes)" returnValue = self.cursor.var(cx_Oracle.NUMBER) self.cursor.setinputsizes(p_Array = [cx_Oracle.NUMBER, 10]) array = [r[1] for r in self.rawData] self.cursor.execute(u""" begin :p_ReturnValue := pkg_TestNumberArrays.TestInArrays( :p_StartValue, :p_Array); end;""", p_ReturnValue = returnValue, p_StartValue = 6, p_Array = array) self.failUnlessEqual(returnValue.getvalue(), 74.75) def testBindNumberArrayByVar(self): "test binding in a number array (with arrayvar)" returnValue = self.cursor.var(cx_Oracle.NUMBER) array = self.cursor.arrayvar(cx_Oracle.NUMBER, [r[1] for r in self.rawData]) array.setvalue(0, [r[1] for r in self.rawData]) self.cursor.execute(u""" begin :p_ReturnValue := pkg_TestNumberArrays.TestInArrays( :p_IntegerValue, :p_Array); end;""", p_ReturnValue = returnValue, p_IntegerValue = 7, p_Array = array) self.failUnlessEqual(returnValue.getvalue(), 75.75) def testBindZeroLengthNumberArrayByVar(self): "test binding in a zero length number array (with arrayvar)" returnValue = self.cursor.var(cx_Oracle.NUMBER) array = self.cursor.arrayvar(cx_Oracle.NUMBER, 0) self.cursor.execute(u""" begin :p_ReturnValue := pkg_TestNumberArrays.TestInArrays( :p_IntegerValue, :p_Array); end;""", p_ReturnValue = returnValue, p_IntegerValue = 8, p_Array = array) self.failUnlessEqual(returnValue.getvalue(), 8.0) self.failUnlessEqual(array.getvalue(), []) def testBindInOutNumberArrayByVar(self): "test binding in/out a number array (with arrayvar)" array = self.cursor.arrayvar(cx_Oracle.NUMBER, 10) originalData = [r[1] for r in self.rawData] expectedData = [originalData[i - 1] * 10 for i in range(1, 6)] + \ originalData[5:] array.setvalue(0, originalData) self.cursor.execute(u""" begin pkg_TestNumberArrays.TestInOutArrays(:p_NumElems, :p_Array); end;""", p_NumElems = 5, p_Array = array) self.failUnlessEqual(array.getvalue(), expectedData) def testBindOutNumberArrayByVar(self): "test binding out a Number array (with arrayvar)" array = self.cursor.arrayvar(cx_Oracle.NUMBER, 6) expectedData = [i * 100 for i in range(1, 7)] self.cursor.execute(u""" begin pkg_TestNumberArrays.TestOutArrays(:p_NumElems, :p_Array); end;""", p_NumElems = 6, p_Array = array) self.failUnlessEqual(array.getvalue(), expectedData) def testBindOutSetInputSizes(self): "test binding out with set input sizes defined" vars = self.cursor.setinputsizes(value = cx_Oracle.NUMBER) self.cursor.execute(u""" begin :value := 5; end;""") self.failUnlessEqual(vars["value"].getvalue(), 5) def testBindInOutSetInputSizes(self): "test binding in/out with set input sizes defined" vars = self.cursor.setinputsizes(value = cx_Oracle.NUMBER) self.cursor.execute(u""" begin :value := :value + 5; end;""", value = 1.25) self.failUnlessEqual(vars["value"].getvalue(), 6.25) def testBindOutVar(self): "test binding out with cursor.var() method" var = self.cursor.var(cx_Oracle.NUMBER) self.cursor.execute(u""" begin :value := 5; end;""", value = var) self.failUnlessEqual(var.getvalue(), 5) def testBindInOutVarDirectSet(self): "test binding in/out with cursor.var() method" var = self.cursor.var(cx_Oracle.NUMBER) var.setvalue(0, 2.25) self.cursor.execute(u""" begin :value := :value + 5; end;""", value = var) self.failUnlessEqual(var.getvalue(), 7.25) def testCursorDescription(self): "test cursor description is accurate" self.cursor.execute(u"select * from TestNumbers") self.failUnlessEqual(self.cursor.description, [ (u'INTCOL', cx_Oracle.NUMBER, 10, 22, 9, 0, 0), (u'NUMBERCOL', cx_Oracle.NUMBER, 13, 22, 9, 2, 0), (u'FLOATCOL', cx_Oracle.NUMBER, 127, 22, 126, -127, 0), (u'UNCONSTRAINEDCOL', cx_Oracle.NUMBER, 127, 22, 0, -127, 0), (u'NULLABLECOL', cx_Oracle.NUMBER, 39, 22, 38, 0, 1) ]) def testFetchAll(self): "test that fetching all of the data returns the correct results" self.cursor.execute(u"select * From TestNumbers order by IntCol") self.failUnlessEqual(self.cursor.fetchall(), self.rawData) self.failUnlessEqual(self.cursor.fetchall(), []) def testFetchMany(self): "test that fetching data in chunks returns the correct results" self.cursor.execute(u"select * From TestNumbers order by IntCol") self.failUnlessEqual(self.cursor.fetchmany(3), self.rawData[0:3]) self.failUnlessEqual(self.cursor.fetchmany(2), self.rawData[3:5]) self.failUnlessEqual(self.cursor.fetchmany(4), self.rawData[5:9]) self.failUnlessEqual(self.cursor.fetchmany(3), self.rawData[9:]) self.failUnlessEqual(self.cursor.fetchmany(3), []) def testFetchOne(self): "test that fetching a single row returns the correct results" self.cursor.execute(u""" select * from TestNumbers where IntCol in (3, 4) order by IntCol""") self.failUnlessEqual(self.cursor.fetchone(), self.dataByKey[3]) self.failUnlessEqual(self.cursor.fetchone(), self.dataByKey[4]) self.failUnlessEqual(self.cursor.fetchone(), None) def testReturnAsLong(self): "test that fetching a long integer returns such in Python" self.cursor.execute(u""" select NullableCol from TestNumbers where IntCol = 9""") col, = self.cursor.fetchone() self.failUnless(isinstance(col, long), "long integer not returned") def testReturnAsFloat(self): "test that fetching a floating point number returns such in Python" self.cursor.execute(u"select 1.25 from dual") result, = self.cursor.fetchone() self.failUnlessEqual(result, 1.25)
apache-2.0
[ 624, 2377, 367, 5343, 1329, 2860, 1041, 199, 199, 646, 17280, 63, 21202, 199, 646, 6107, 199, 199, 533, 1379, 3259, 5894, 8, 20760, 304, 339, 347, 3613, 8, 277, 304, 489, 3523, 1746, 14, 5996, 8, 277, 9, 489, 291, 14, 1773, 1451, 275, 942, 489, 291, 14, 576, 2175, 1197, 275, 1052, 489, 367, 284, 315, 1425, 8, 17, 12, 4119, 304, 881, 1329, 2001, 275, 284, 435, 284, 627, 378, 14, 821, 881, 2069, 2001, 275, 284, 435, 284, 627, 378, 14, 2194, 881, 625, 25990, 2001, 275, 284, 1011, 650, 435, 284, 627, 378, 14, 21, 881, 340, 284, 450, 499, 26, 1598, 7854, 2001, 275, 29235, 44, 1011, 284, 881, 587, 26, 1598, 7854, 2001, 275, 488, 881, 666, 7075, 275, 334, 73, 12, 1329, 2001, 12, 2069, 2001, 12, 625, 25990, 2001, 12, 7854, 2001, 9, 881, 291, 14, 1773, 1451, 14, 740, 8, 576, 7075, 9, 881, 291, 14, 576, 2175, 1197, 59, 73, 61, 275, 666, 7075, 339, 347, 511, 8198, 6745, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 6107, 14, 6745, 2, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 3504, 627, 687, 1379, 22951, 355, 2382, 4860, 2001, 446, 520, 585, 17, 446, 520, 585, 18, 275, 8181, 67, 8, 3259, 2001, 9, 7208, 355, 574, 17, 275, 6107, 14, 6745, 480, 16, 14, 1165, 1288, 355, 574, 18, 275, 6107, 14, 6745, 480, 16, 14, 1717, 2237, 267, 291, 14, 14247, 8, 277, 14, 3937, 14, 10174, 1062, 355, 359, 277, 14, 576, 2175, 1197, 59, 17, 467, 291, 14, 576, 2175, 1197, 59, 21, 467, 291, 14, 576, 2175, 1197, 59, 25, 3934, 339, 347, 511, 8198, 5136, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 2069, 2, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 3504, 627, 687, 1379, 22951, 355, 2382, 4860, 2001, 446, 520, 585, 275, 8181, 67, 8, 3259, 2001, 9, 7208, 355, 574, 275, 378, 14, 821, 9, 267, 291, 14, 14247, 8, 277, 14, 3937, 14, 10174, 1062, 355, 359, 277, 14, 576, 2175, 1197, 59, 17, 467, 291, 14, 576, 2175, 1197, 59, 21, 467, 291, 14, 576, 2175, 1197, 59, 25, 3934, 339, 347, 511, 8198, 2674, 8, 277, 304, 267, 298, 396, 11696, 315, 376, 3000, 2, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 3504, 627, 687, 1379, 22951, 355, 2382, 9805, 2001, 275, 520, 585, 7208, 355, 574, 275, 499, 9, 267, 291, 14, 14247, 8, 277, 14, 3937, 14, 10174, 1062, 359, 277, 14, 576, 2175, 1197, 59, 18, 3934, 339, 347, 511, 8198, 10712, 9551, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 7425, 1846, 3000, 2, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 3504, 627, 687, 1379, 22951, 355, 2382, 9805, 2001, 275, 520, 585, 7208, 355, 574, 275, 650, 44, 9, 267, 291, 14, 14247, 8, 277, 14, 3937, 14, 10174, 1062, 359, 277, 14, 576, 2175, 1197, 59, 19, 3934, 339, 347, 511, 8198, 17149, 9551, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 7031, 1846, 3000, 2, 267, 574, 5894, 275, 291, 14, 3937, 14, 1391, 8, 11859, 63, 21202, 14, 9190, 9, 267, 574, 5894, 14, 409, 585, 8, 16, 12, 5212, 1299, 1082, 708, 1602, 9, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 5386, 2116, 520, 585, 12952, 520, 585, 435, 959, 27, 355, 1284, 27, 7208, 355, 574, 275, 574, 5894, 9, 267, 574, 275, 574, 5894, 14, 7150, 342, 267, 291, 14, 14247, 8, 585, 12, 5212, 1299, 1082, 708, 1887, 9, 339, 347, 511, 8198, 2674, 10881, 1558, 8, 277, 304, 267, 298, 396, 11696, 315, 376, 1329, 2410, 4260, 1324, 10627, 370, 282, 1059, 2, 267, 291, 14, 3937, 14, 409, 1210, 7723, 8, 585, 275, 4114, 9, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 3504, 627, 687, 1379, 22951, 355, 2382, 9805, 2001, 275, 520, 585, 7208, 355, 574, 275, 650, 9, 267, 291, 14, 14247, 8, 277, 14, 3937, 14, 10174, 1062, 359, 277, 14, 576, 2175, 1197, 59, 19, 3934, 339, 347, 511, 8198, 8849, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 2973, 2, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 3504, 627, 687, 1379, 22951, 355, 2382, 9805, 2001, 275, 520, 585, 7208, 355, 574, 275, 488, 9, 267, 291, 14, 14247, 8, 277, 14, 3937, 14, 10174, 1062, 3073, 339, 347, 511, 8198, 3259, 3836, 16281, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 1329, 1625, 2, 267, 372, 1110, 275, 291, 14, 3937, 14, 1391, 8, 11859, 63, 21202, 14, 9190, 9, 267, 1625, 275, 359, 82, 59, 17, 61, 367, 519, 315, 291, 14, 1773, 1451, 61, 267, 5164, 275, 399, 624, 355, 5386, 2116, 520, 80, 63, 1767, 1110, 12952, 5496, 63, 774, 3259, 29033, 14, 774, 607, 29033, 8, 1993, 520, 80, 63, 3162, 1110, 12, 520, 80, 63, 3836, 2736, 355, 1284, 27, 624, 267, 291, 14, 3937, 14, 2526, 8, 6242, 12, 355, 299, 63, 1767, 1110, 275, 372, 1110, 12, 355, 299, 63, 3162, 1110, 275, 959, 12, 355, 299, 63, 3836, 275, 1625, 9, 267, 291, 14, 14247, 8, 1107, 1110, 14, 7150, 1062, 18525, 14, 2194, 9, 267, 1625, 275, 1425, 8, 1046, 9, 267, 291, 14, 3937, 14, 2526, 8, 6242, 12, 355, 299, 63, 3162, 1110, 275, 1616, 12, 355, 299, 63, 3836, 275, 1625, 9, 267, 291, 14, 14247, 8, 1107, 1110, 14, 7150, 1062, 22560, 14, 16, 9, 339, 347, 511, 8198, 3259, 3836, 2175, 29790, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 1329, 1625, 334, 1045, 663, 1210, 7723, 2924, 267, 372, 1110, 275, 291, 14, 3937, 14, 1391, 8, 11859, 63, 21202, 14, 9190, 9, 267, 291, 14, 3937, 14, 409, 1210, 7723, 8, 80, 63, 3836, 275, 359, 11859, 63, 21202, 14, 9190, 12, 1616, 566, 267, 1625, 275, 359, 82, 59, 17, 61, 367, 519, 315, 291, 14, 1773, 1451, 61, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 5386, 2116, 520, 80, 63, 1767, 1110, 12952 ]
[ 2377, 367, 5343, 1329, 2860, 1041, 199, 199, 646, 17280, 63, 21202, 199, 646, 6107, 199, 199, 533, 1379, 3259, 5894, 8, 20760, 304, 339, 347, 3613, 8, 277, 304, 489, 3523, 1746, 14, 5996, 8, 277, 9, 489, 291, 14, 1773, 1451, 275, 942, 489, 291, 14, 576, 2175, 1197, 275, 1052, 489, 367, 284, 315, 1425, 8, 17, 12, 4119, 304, 881, 1329, 2001, 275, 284, 435, 284, 627, 378, 14, 821, 881, 2069, 2001, 275, 284, 435, 284, 627, 378, 14, 2194, 881, 625, 25990, 2001, 275, 284, 1011, 650, 435, 284, 627, 378, 14, 21, 881, 340, 284, 450, 499, 26, 1598, 7854, 2001, 275, 29235, 44, 1011, 284, 881, 587, 26, 1598, 7854, 2001, 275, 488, 881, 666, 7075, 275, 334, 73, 12, 1329, 2001, 12, 2069, 2001, 12, 625, 25990, 2001, 12, 7854, 2001, 9, 881, 291, 14, 1773, 1451, 14, 740, 8, 576, 7075, 9, 881, 291, 14, 576, 2175, 1197, 59, 73, 61, 275, 666, 7075, 339, 347, 511, 8198, 6745, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 6107, 14, 6745, 2, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 3504, 627, 687, 1379, 22951, 355, 2382, 4860, 2001, 446, 520, 585, 17, 446, 520, 585, 18, 275, 8181, 67, 8, 3259, 2001, 9, 7208, 355, 574, 17, 275, 6107, 14, 6745, 480, 16, 14, 1165, 1288, 355, 574, 18, 275, 6107, 14, 6745, 480, 16, 14, 1717, 2237, 267, 291, 14, 14247, 8, 277, 14, 3937, 14, 10174, 1062, 355, 359, 277, 14, 576, 2175, 1197, 59, 17, 467, 291, 14, 576, 2175, 1197, 59, 21, 467, 291, 14, 576, 2175, 1197, 59, 25, 3934, 339, 347, 511, 8198, 5136, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 2069, 2, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 3504, 627, 687, 1379, 22951, 355, 2382, 4860, 2001, 446, 520, 585, 275, 8181, 67, 8, 3259, 2001, 9, 7208, 355, 574, 275, 378, 14, 821, 9, 267, 291, 14, 14247, 8, 277, 14, 3937, 14, 10174, 1062, 355, 359, 277, 14, 576, 2175, 1197, 59, 17, 467, 291, 14, 576, 2175, 1197, 59, 21, 467, 291, 14, 576, 2175, 1197, 59, 25, 3934, 339, 347, 511, 8198, 2674, 8, 277, 304, 267, 298, 396, 11696, 315, 376, 3000, 2, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 3504, 627, 687, 1379, 22951, 355, 2382, 9805, 2001, 275, 520, 585, 7208, 355, 574, 275, 499, 9, 267, 291, 14, 14247, 8, 277, 14, 3937, 14, 10174, 1062, 359, 277, 14, 576, 2175, 1197, 59, 18, 3934, 339, 347, 511, 8198, 10712, 9551, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 7425, 1846, 3000, 2, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 3504, 627, 687, 1379, 22951, 355, 2382, 9805, 2001, 275, 520, 585, 7208, 355, 574, 275, 650, 44, 9, 267, 291, 14, 14247, 8, 277, 14, 3937, 14, 10174, 1062, 359, 277, 14, 576, 2175, 1197, 59, 19, 3934, 339, 347, 511, 8198, 17149, 9551, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 7031, 1846, 3000, 2, 267, 574, 5894, 275, 291, 14, 3937, 14, 1391, 8, 11859, 63, 21202, 14, 9190, 9, 267, 574, 5894, 14, 409, 585, 8, 16, 12, 5212, 1299, 1082, 708, 1602, 9, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 5386, 2116, 520, 585, 12952, 520, 585, 435, 959, 27, 355, 1284, 27, 7208, 355, 574, 275, 574, 5894, 9, 267, 574, 275, 574, 5894, 14, 7150, 342, 267, 291, 14, 14247, 8, 585, 12, 5212, 1299, 1082, 708, 1887, 9, 339, 347, 511, 8198, 2674, 10881, 1558, 8, 277, 304, 267, 298, 396, 11696, 315, 376, 1329, 2410, 4260, 1324, 10627, 370, 282, 1059, 2, 267, 291, 14, 3937, 14, 409, 1210, 7723, 8, 585, 275, 4114, 9, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 3504, 627, 687, 1379, 22951, 355, 2382, 9805, 2001, 275, 520, 585, 7208, 355, 574, 275, 650, 9, 267, 291, 14, 14247, 8, 277, 14, 3937, 14, 10174, 1062, 359, 277, 14, 576, 2175, 1197, 59, 19, 3934, 339, 347, 511, 8198, 8849, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 2973, 2, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 3504, 627, 687, 1379, 22951, 355, 2382, 9805, 2001, 275, 520, 585, 7208, 355, 574, 275, 488, 9, 267, 291, 14, 14247, 8, 277, 14, 3937, 14, 10174, 1062, 3073, 339, 347, 511, 8198, 3259, 3836, 16281, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 1329, 1625, 2, 267, 372, 1110, 275, 291, 14, 3937, 14, 1391, 8, 11859, 63, 21202, 14, 9190, 9, 267, 1625, 275, 359, 82, 59, 17, 61, 367, 519, 315, 291, 14, 1773, 1451, 61, 267, 5164, 275, 399, 624, 355, 5386, 2116, 520, 80, 63, 1767, 1110, 12952, 5496, 63, 774, 3259, 29033, 14, 774, 607, 29033, 8, 1993, 520, 80, 63, 3162, 1110, 12, 520, 80, 63, 3836, 2736, 355, 1284, 27, 624, 267, 291, 14, 3937, 14, 2526, 8, 6242, 12, 355, 299, 63, 1767, 1110, 275, 372, 1110, 12, 355, 299, 63, 3162, 1110, 275, 959, 12, 355, 299, 63, 3836, 275, 1625, 9, 267, 291, 14, 14247, 8, 1107, 1110, 14, 7150, 1062, 18525, 14, 2194, 9, 267, 1625, 275, 1425, 8, 1046, 9, 267, 291, 14, 3937, 14, 2526, 8, 6242, 12, 355, 299, 63, 3162, 1110, 275, 1616, 12, 355, 299, 63, 3836, 275, 1625, 9, 267, 291, 14, 14247, 8, 1107, 1110, 14, 7150, 1062, 22560, 14, 16, 9, 339, 347, 511, 8198, 3259, 3836, 2175, 29790, 8, 277, 304, 267, 298, 396, 11696, 315, 282, 1329, 1625, 334, 1045, 663, 1210, 7723, 2924, 267, 372, 1110, 275, 291, 14, 3937, 14, 1391, 8, 11859, 63, 21202, 14, 9190, 9, 267, 291, 14, 3937, 14, 409, 1210, 7723, 8, 80, 63, 3836, 275, 359, 11859, 63, 21202, 14, 9190, 12, 1616, 566, 267, 1625, 275, 359, 82, 59, 17, 61, 367, 519, 315, 291, 14, 1773, 1451, 61, 267, 291, 14, 3937, 14, 2526, 8, 85, 624, 355, 5386, 2116, 520, 80, 63, 1767, 1110, 12952, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sammuelyee/validator
build/build.py
2
51748
#!/usr/bin/env python2.7 # Copyright (c) 2007 Henri Sivonen # Copyright (c) 2008-2015 Mozilla Foundation # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. import os import shutil import httplib import urllib2 import socket import re try: from hashlib import md5 except ImportError: from md5 import new as md5 try: from hashlib import sha1 except ImportError: from sha1 import new as sha1 import zipfile import sys from sgmllib import SGMLParser import subprocess import time javaVersion = '1.6' javacCmd = 'javac' jarCmd = 'jar' javaCmd = 'java' javadocCmd = 'javadoc' herokuCmd= 'heroku' ghRelCmd = 'github-release' tarCmd = 'tar' scpCmd = 'scp' gitCmd = 'git' mvnCmd = 'mvn' gpgCmd = 'gpg2' snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/' stagingRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' # in your ~/.ssh/config, you'll need to define a host named "releasesHost" releasesHost = "releasesHost" nightliesPath = "/var/www/nightlies" releasesPath = "/var/www/releases" releaseDate = time.strftime('%d %B %Y') validatorVersion = time.strftime('%y.%-m.%-e') jingVersion = "20150629VNU" htmlparserVersion = "1.4.1" buildRoot = '.' distDir = os.path.join(buildRoot, "build", "dist") dependencyDir = os.path.join(buildRoot, "dependencies") jarsDir = os.path.join(buildRoot, "jars") jingTrangDir = os.path.join(buildRoot, "jing-trang") vnuSrc = os.path.join(buildRoot, "src", "nu", "validator") filesDir = os.path.join(vnuSrc, "localentities", "files") antRoot = os.path.join(jingTrangDir, "lib") antJar = os.path.join(antRoot, "ant.jar") antLauncherJar = os.path.join(antRoot, "ant-launcher.jar") pageTemplate = os.path.join("site", "PageEmitter.xml") formTemplate = os.path.join("site", "FormEmitter.xml") presetsFile = os.path.join("resources", "presets.txt") aboutFile = os.path.join("site", "about.html") stylesheetFile = os.path.join("site", "style.css") scriptFile = os.path.join("site", "script.js") portNumber = '8888' controlPort = None log4jProps = 'resources/log4j.properties' heapSize = '128' stackSize = '' html5specLink = 'https://www.whatwg.org/specs/web-apps/current-work/' html5specLoad = 'https://www.whatwg.org/specs/web-apps/current-work/' aboutPage = 'https://about.validator.nu/' userAgent = 'Validator.nu/LV' icon = None stylesheet = None script = None serviceName = 'Validator.nu' resultsTitle = 'Validation results' messagesLimit=1000 maxFileSize = 8192 usePromiscuousSsl = 0 genericHost = '' html5Host = '' parsetreeHost = '' genericPath = '/' html5Path = '/html5/' parsetreePath = '/parsetree/' deploymentTarget = None httpTimeoutSeconds = 120 connectionTimeoutSeconds = 5 socketTimeoutSeconds = 5 followW3Cspec = 0 statistics = 0 miniDoc = '<!doctype html><meta charset=utf-8><title>test</title>' dependencyPackages = [ ("https://repo1.maven.org/maven2/com/ibm/icu/icu4j/54.1.1/icu4j-54.1.1.jar", "d75417a813c37b958be2be0a766f0a65"), ("https://repo1.maven.org/maven2/commons-codec/commons-codec/1.10/commons-codec-1.10.jar", "353cf6a2bdba09595ccfa073b78c7fcb"), ("https://repo1.maven.org/maven2/commons-fileupload/commons-fileupload/1.3.1/commons-fileupload-1.3.1.jar", "ed8eec445e21ec7e49b86bf3cbcffcbc"), ("https://repo1.maven.org/maven2/commons-io/commons-io/2.4/commons-io-2.4.jar", "7f97854dc04c119d461fed14f5d8bb96"), ("https://repo1.maven.org/maven2/commons-logging/commons-logging/1.2/commons-logging-1.2.jar", "040b4b4d8eac886f6b4a2a3bd2f31b00"), ("https://repo1.maven.org/maven2/commons-logging/commons-logging/1.2/commons-logging-1.2-adapters.jar", "5c82e86cc5b769f72abd2af1f92255fa"), ("https://repo1.maven.org/maven2/commons-logging/commons-logging/1.2/commons-logging-1.2-api.jar", "289dcb376743ab24ecaeb194a0d287d9"), ("https://repo1.maven.org/maven2/io/mola/galimatias/galimatias/0.1.0/galimatias-0.1.0.jar", "55f2b9a4648d7593db3d8f307f84bb01"), ("https://repo1.maven.org/maven2/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar", "79de69e9f5ed8c7fcb8342585732bbf7"), ("https://repo1.maven.org/maven2/log4j/log4j/1.2.17/log4j-1.2.17.jar", "04a41f0a068986f0f73485cf507c0f40"), ("https://repo1.maven.org/maven2/net/sourceforge/jchardet/jchardet/1.0/jchardet-1.0.jar", "90c63f0e53e6f714dbc7641e066620e4"), ("https://repo1.maven.org/maven2/org/apache/httpcomponents/httpclient/4.4/httpclient-4.4.jar", "ccf9833ec0cbd38831ceeb8fc246e2dd"), ("https://repo1.maven.org/maven2/org/apache/httpcomponents/httpcore/4.4/httpcore-4.4.jar", "e016cf1346ba3f65302c3d71c5b91f44"), ("https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-http/9.2.9.v20150224/jetty-http-9.2.9.v20150224.jar", "800c59fd3f976720f2ded0b30986d072"), ("https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-io/9.2.9.v20150224/jetty-io-9.2.9.v20150224.jar", "37532e30810cf6a84fd09d9e7cf720e5"), ("https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-security/9.2.9.v20150224/jetty-security-9.2.9.v20150224.jar", "2bad0336376b71a5ec81bc3150b898a0"), ("https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-server/9.2.9.v20150224/jetty-server-9.2.9.v20150224.jar", "c8a746bc320459d16e8769485950cae1"), ("https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlet/9.2.9.v20150224/jetty-servlet-9.2.9.v20150224.jar", "b9686811e977ab4c0cc43cc5e0996c02"), ("https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlets/9.2.9.v20150224/jetty-servlets-9.2.9.v20150224.jar", "5ec4c25b552df1f7b6785b7b5bbbd54c"), ("https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util/9.2.9.v20150224/jetty-util-9.2.9.v20150224.jar", "cb039d6b03c838ea90748469fe928d60"), ("https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util-ajax/9.2.9.v20150224/jetty-util-ajax-9.2.9.v20150224.jar", "e3f16ce949fa5103975a1c056d2cc9cb"), ("https://repo1.maven.org/maven2/org/mozilla/rhino/1.7R5/rhino-1.7R5.jar", "515233bd8a534c0468f6e397fc6b1925"), ("https://repo1.maven.org/maven2/xom/xom/1.2.5/xom-1.2.5.jar", "91b16b5b53ae0804671a57dbf7623fad"), ("https://raw.githubusercontent.com/tabatkins/parse-css/a878df1503af3bfb63493a63685a117a24988959/parse-css.js", "adbb69f7c71c8d5703f8b9d770bfc71f"), ("https://raw.githubusercontent.com/douglascrockford/JSON-js/3d7767b6b1f3da363c625ff54e63bbf20e9e83ac/json.js", "f508cbf66725dc438c780334f6849e6f"), ] runDependencyJars = [ "commons-codec-1.10.jar", "commons-fileupload-1.3.1.jar", "commons-io-2.4.jar", "commons-logging-1.2.jar", "commons-logging-1.2-adapters.jar", "commons-logging-1.2-api.jar", "galimatias-0.1.0.jar", "httpcore-4.4.jar", "httpclient-4.4.jar", "icu4j-54.1.1.jar", "javax.servlet-api-3.1.0.jar", "jchardet-1.0.jar", "jetty-http-9.2.9.v20150224.jar", "jetty-io-9.2.9.v20150224.jar", "jetty-security-9.2.9.v20150224.jar", "jetty-server-9.2.9.v20150224.jar", "jetty-servlet-9.2.9.v20150224.jar", "jetty-servlets-9.2.9.v20150224.jar", "jetty-util-9.2.9.v20150224.jar", "jetty-util-ajax-9.2.9.v20150224.jar", "log4j-1.2.17.jar", "rhino-1.7R5.jar", ] buildOnlyDependencyJars = [ "xom-1.2.5.jar" ] dependencyJars = runDependencyJars + buildOnlyDependencyJars javaSafeNamePat = re.compile(r'[^a-zA-Z0-9]') directoryPat = re.compile(r'^[a-zA-Z0-9_-]+/$') leafPat = re.compile(r'^[a-zA-Z0-9_-]+\.[a-z]+$') class UrlExtractor(SGMLParser): def __init__(self, baseUrl): SGMLParser.__init__(self) self.baseUrl = baseUrl self.leaves = [] self.directories = [] def start_a(self, attrs): for name, value in attrs: if name == "href": if directoryPat.match(value): self.directories.append(self.baseUrl + value) if leafPat.match(value): self.leaves.append(self.baseUrl + value) def runCmd(cmd): print cmd if os.name == 'nt' and cmd[:1] == '"': subprocess.call(cmd) else: return os.system(cmd) def execCmd(cmd, args): print "%s %s" % (cmd, " ".join(args)) if os.name == 'nt': if subprocess.call([cmd,] + args): print "Command failed." sys.exit(2) else: if os.execvp(cmd, [cmd,] + args): print "Command failed." sys.exit(2) def removeIfExists(filePath): if os.path.exists(filePath): print "Removing %s" % filePath os.unlink(filePath) def removeIfDirExists(dirPath): if os.path.exists(dirPath): print "Removing %s" % dirPath shutil.rmtree(dirPath) def ensureDirExists(dirPath): if not os.path.exists(dirPath): os.makedirs(dirPath) def findFilesWithExtension(directory, extension): rv = [] ext = '.' + extension for root, dirs, files in os.walk(directory): for filename in files: if filename.endswith(ext): rv.append(os.path.join(root, filename)) return rv def findFiles(directory): rv = [] for root, dirs, files in os.walk(directory): for filename in files: candidate = os.path.join(root, filename) if candidate.find("/.svn") == -1: rv.append(candidate) return rv def jarNamesToPaths(names): return [os.path.join(jarsDir, name + ".jar") for name in names] def jingJarPath(): return [os.path.join("jing-trang", "build", "jing.jar"),] def runJavac(sourceDir, classDir, classPath): ensureDirExists(classDir) sourceFiles = findFilesWithExtension(sourceDir, "java") f = open("temp-javac-list", "w") if os.name == 'nt': f.write("\r\n".join(sourceFiles)) else: f.write("\n".join(sourceFiles)) f.close() args = [ '-g', '-nowarn', '-classpath "%s"' % classPath, '-sourcepath "%s"' % sourceDir, '-d "%s"' % classDir, '-encoding UTF-8', ] if javaVersion != "": args.append('-target ' + javaVersion) args.append('-source ' + javaVersion) if runCmd('"%s" %s %s' % (javacCmd, " ".join(args), '@temp-javac-list')): sys.exit(1) removeIfExists("temp-javac-list") def copyFiles(sourceDir, classDir): files = findFiles(sourceDir) for f in files: destFile = os.path.join(classDir, f[len(sourceDir)+1:]) head, tail = os.path.split(destFile) if not os.path.exists(head): os.makedirs(head) shutil.copyfile(f, destFile) def runJar(classDir, jarFile, sourceDir): classFiles = [] for file in findFiles(classDir): if file.endswith(".java"): continue classFiles.append(file) classList = ["-C " + classDir + " " + x[len(classDir)+1:] + "" for x in classFiles] f = open("temp-jar-list", "w") if os.name == 'nt': f.write("\r\n".join(classList)) else: f.write("\n".join(classList)) f.close() runCmd('"%s" cf "%s" %s' % (jarCmd, jarFile, "@temp-jar-list")) removeIfExists("temp-jar-list") def buildModule(rootDir, jarName, classPath): sourceDir = os.path.join(rootDir, "src") classDir = os.path.join(rootDir, "classes") modDistDir = os.path.join(rootDir, "dist") jarFile = os.path.join(modDistDir, jarName + ".jar") removeIfExists(jarFile) removeIfDirExists(classDir) ensureDirExists(classDir) ensureDirExists(modDistDir) runJavac(sourceDir, classDir, classPath) copyFiles(sourceDir, classDir) runJar(classDir, jarFile, sourceDir) ensureDirExists(jarsDir) shutil.copyfile(jarFile, os.path.join(jarsDir, jarName + ".jar")) removeIfDirExists(classDir) removeIfDirExists(modDistDir) def dependencyJarPaths(depList=dependencyJars): extrasDir = os.path.join(buildRoot, "extras") # XXX may need work for Windows portability pathList = [os.path.join(dependencyDir, dep) for dep in depList] for jar in ["saxon9.jar", "xercesImpl.jar", "xml-apis.jar", "isorelax.jar"]: pathList += [ os.path.join(jingTrangDir, "lib", jar) ] ensureDirExists(extrasDir) pathList += findFilesWithExtension(extrasDir, "jar") return pathList def buildSchemaDrivers(): baseDir = os.path.join(buildRoot, "schema") html5Dir = os.path.join(baseDir, "html5") driversDir = os.path.join(baseDir, ".drivers") legacyRnc = os.path.join(driversDir, "legacy.rnc") itsRnc = os.path.join(os.path.join(baseDir, "its2/its20-html5.rnc")) itsTypesRnc = os.path.join(os.path.join(baseDir, "its2/its20-html5-types.rnc")) buildSchemaDriverHtmlCore(html5Dir) buildSchemaDriverHtml5NoMicrodata(html5Dir) buildSchemaDriverHtml5(html5Dir) buildSchemaDriverHtml5RDFa(html5Dir) buildSchemaDriverHtml5RDFaLite(html5Dir) buildSchemaDriverXhtmlCore(html5Dir) buildSchemaDriverXhtmlCorePlusWf2(html5Dir) buildSchemaDriverXhtml5xhtmlNoMicrodata(html5Dir) buildSchemaDriverXhtml5htmlNoMicrodata(html5Dir) buildSchemaDriverXhtml5html(html5Dir) buildSchemaDriverXhtml5xhtml(html5Dir) buildSchemaDriverXhtml5xhtmlRDFa(html5Dir) buildSchemaDriverXhtml5xhtmlRDFaLite(html5Dir) buildSchemaDriverXhtml5htmlRDFaLite(html5Dir) for file in coreSchemaDriverFiles: print "Copying %s to %s" % (os.path.join(driversDir, file), os.path.join(baseDir, file)) shutil.copy(os.path.join(driversDir, file), baseDir) xhtmlSourceDir = os.path.join(driversDir, "xhtml10") xhtmlTargetDir = os.path.join(baseDir, "xhtml10") removeIfDirExists(xhtmlTargetDir) shutil.copytree(xhtmlSourceDir, xhtmlTargetDir) print "Copying %s to %s" % (xhtmlSourceDir, xhtmlTargetDir) rdfDir = os.path.join(baseDir, "rdf") removeIfDirExists(rdfDir) os.mkdir(rdfDir) print "Copying %s to %s/rdf.rnc" % (os.path.join(driversDir, "rdf.rnc"), rdfDir) shutil.copy(os.path.join(driversDir, "rdf.rnc"), rdfDir) removeIfExists(os.path.join(html5Dir, "legacy.rnc")) removeIfExists(os.path.join(html5Dir, "its20-html5.rnc")) removeIfExists(os.path.join(html5Dir, "its20-html5-types.rnc")) shutil.copy(legacyRnc, html5Dir) shutil.copy(itsRnc, html5Dir) shutil.copy(itsTypesRnc, html5Dir) ################################################################# # data and functions for building schema drivers ################################################################# coreSchemaDriverFiles = [ "html5-all.rnc", "html5-its.rnc", "html5-no-microdata.rnc", "html5-rdfalite-w3c.rnc", "html5-rdfalite.rnc", "html5-svg-mathml.rnc", "html5.rnc", "svg-xhtml5-rdf-mathml.rnc", "xhtml1-ruby-rdf-svg-mathml.rnc", "xhtml5-all.rnc", "xhtml5-no-microdata.rnc", "xhtml5-rdfalite-w3c.rnc", "xhtml5-rdfalite.rnc", "xhtml5-svg-mathml.rnc", "xhtml5.rnc" ] htmlSchemaDriverFiles = [ "html5core.rnc", "html5full-no-microdata.rnc", "html5full-rdfa.rnc", "html5full-rdfalite.rnc", "html5full.rnc", "its20-html5-types.rnc", "its20-html5.rnc", "legacy.rnc", "xhtml5core-plus-web-forms2.rnc", "xhtml5core.rnc", "xhtml5full-html-no-microdata.rnc", "xhtml5full-html-rdfalite.rnc", "xhtml5full-html.rnc", "xhtml5full-xhtml-no-microdata.rnc", "xhtml5full-xhtml-rdfa.rnc", "xhtml5full-xhtml-rdfalite.rnc", "xhtml5full-xhtml.rnc" ] schemaDriverBase = '''\ start = html.elem include "phrase.rnc" include "block.rnc" include "sectional.rnc" include "revision.rnc" include "embed.rnc" include "core-scripting.rnc" ''' schemaDriverHtml5NoMicrodata = '''\ include "structural.rnc" include "ruby.rnc" include "media.rnc" include "tables.rnc" include "form-datatypes.rnc" include "web-forms.rnc" include "web-forms2.rnc" include "web-components.rnc" include "applications.rnc" include "data.rnc" include "legacy.rnc" include "aria.rnc" include "meta.rnc" { html.inner = ( head.elem , ( body.elem | frameset.elem ) ) } ''' schemaDriverPlusWebForms2 = '''\ include "tables.rnc" include "form-datatypes.rnc" include "web-forms.rnc" include "web-forms2.rnc" ''' schemaDriverNamespace = '''\ default namespace = "http://www.w3.org/1999/xhtml" ''' schemaDriverMeta = '''\ include "meta.rnc" ''' schemaDriverToggle_HtmlCore = '''\ include "common.rnc" { XMLonly = notAllowed HTMLonly = empty v5only = notAllowed } ''' schemaDriverToggle_XhtmlCore = '''\ include "common.rnc" { XMLonly = empty HTMLonly = notAllowed v5only = notAllowed } ''' schemaDriverToggle_Html5 = '''\ include "common.rnc" { XMLonly = notAllowed HTMLonly = empty v5only = empty nonHTMLizable = notAllowed nonRoundtrippable = notAllowed ''' schemaDriverToggle_Xhtml5xhtml = '''\ include "common.rnc" { XMLonly = empty HTMLonly = notAllowed v5only = empty ''' schemaDriverToggle_Xhtml5html = '''\ include "common.rnc" { XMLonly = empty HTMLonly = notAllowed v5only = empty nonHTMLizable = notAllowed nonRoundtrippable = notAllowed ''' schemaDriverHtml5Microdata = '''\ include "microdata.rnc" ''' schemaDriverHtml5RDFa = '''\ include "rdfa.rnc" ''' schemaDriverHtml5RDFaLite = '''\ include "rdfa.rnc" { nonRDFaLite = notAllowed } ''' def openDriver(schemaDir, driverName, sourceName=""): removeIfExists(os.path.join(schemaDir, driverName)) if sourceName != "": # if we have a file sourceName, copy it so that we can later # just append additions to the copy shutil.copyfile(os.path.join(schemaDir, sourceName), os.path.join(schemaDir, driverName)) f = open(os.path.join(schemaDir, driverName), "a") return f def writeW3CToggle(f): if followW3Cspec: f.write("\t\tnonW3C = notAllowed\n") f.write("}\n") ################################ # HTML schema drivers ################################ def buildSchemaDriverHtmlCore(schemaDir): f = openDriver(schemaDir, "html5core.rnc") f.write(schemaDriverToggle_HtmlCore) f.write(schemaDriverBase) f.write(schemaDriverMeta) f.close() def buildSchemaDriverHtml5NoMicrodata(schemaDir): f = openDriver(schemaDir, "html5full-no-microdata.rnc") f.write(schemaDriverNamespace) f.write(schemaDriverToggle_Html5) writeW3CToggle(f) f.write(schemaDriverBase) f.write(schemaDriverHtml5NoMicrodata) # For W3C case, make HTML5 checking always include ITS2 support if followW3Cspec: f.write('include "its20-html5.rnc"\n') f.write('common.attrs &= its-html-attributes\n') f.close() def buildSchemaDriverHtml5(schemaDir): f = openDriver(schemaDir, "html5full.rnc", "html5full-no-microdata.rnc") f.write(schemaDriverHtml5Microdata) f.close() def buildSchemaDriverHtml5RDFa(schemaDir): f = openDriver(schemaDir, "html5full-rdfa.rnc", "html5full.rnc") f.write(schemaDriverHtml5RDFa) f.close() def buildSchemaDriverHtml5RDFaLite(schemaDir): f = openDriver(schemaDir, "html5full-rdfalite.rnc", "html5full.rnc") f.write(schemaDriverHtml5RDFaLite) f.close() ################################ # XHTML schema drivers ################################ def buildSchemaDriverXhtmlCore(schemaDir): f = openDriver(schemaDir, "xhtml5core.rnc") f.write(schemaDriverNamespace) f.write(schemaDriverToggle_XhtmlCore) f.write(schemaDriverBase) f.write(schemaDriverMeta) f.close() def buildSchemaDriverXhtmlCorePlusWf2(schemaDir): f = openDriver(schemaDir, "xhtml5core-plus-web-forms2.rnc", "xhtml5core.rnc") f.write(schemaDriverPlusWebForms2) f.close() def buildSchemaDriverXhtml5htmlNoMicrodata(schemaDir): f = openDriver(schemaDir, "xhtml5full-html-no-microdata.rnc") f.write(schemaDriverNamespace) f.write(schemaDriverToggle_Xhtml5html) writeW3CToggle(f) f.write(schemaDriverBase) f.write(schemaDriverHtml5NoMicrodata) f.close() def buildSchemaDriverXhtml5xhtmlNoMicrodata(schemaDir): f = openDriver(schemaDir, "xhtml5full-xhtml-no-microdata.rnc") f.write(schemaDriverNamespace) f.write(schemaDriverToggle_Xhtml5xhtml) writeW3CToggle(f) f.write(schemaDriverBase) f.write(schemaDriverHtml5NoMicrodata) f.close() def buildSchemaDriverXhtml5xhtml(schemaDir): f = openDriver(schemaDir, "xhtml5full-xhtml.rnc", "xhtml5full-xhtml-no-microdata.rnc") f.write(schemaDriverHtml5Microdata) f.close() def buildSchemaDriverXhtml5xhtmlRDFa(schemaDir): f = openDriver(schemaDir, "xhtml5full-xhtml-rdfa.rnc", "xhtml5full-xhtml.rnc") f.write(schemaDriverHtml5RDFa) f.close() def buildSchemaDriverXhtml5xhtmlRDFaLite(schemaDir): f = openDriver(schemaDir, "xhtml5full-xhtml-rdfalite.rnc", "xhtml5full-xhtml.rnc") f.write(schemaDriverHtml5RDFaLite) f.close() def buildSchemaDriverXhtml5html(schemaDir): f = openDriver(schemaDir, "xhtml5full-html.rnc", "xhtml5full-html-no-microdata.rnc") f.write(schemaDriverHtml5Microdata) f.close() def buildSchemaDriverXhtml5htmlRDFa(schemaDir): f = openDriver(schemaDir, "xhtml5full-html-rdfa.rnc", "xhtml5full-html.rnc") f.write(schemaDriverHtml5RDFa) f.close() def buildSchemaDriverXhtml5htmlRDFaLite(schemaDir): f = openDriver(schemaDir, "xhtml5full-html-rdfalite.rnc", "xhtml5full-html.rnc") f.write(schemaDriverHtml5RDFaLite) f.close() ################################################################# # end of data and functions for building schema drivers ################################################################# def buildHtmlParser(): classPath = os.pathsep.join(dependencyJarPaths()) buildModule( os.path.join(buildRoot, "htmlparser"), "htmlparser", classPath) def buildJing(): os.chdir("jing-trang") runCmd(os.path.join(".", "ant")) os.chdir("..") def buildEmitters(): compilerFile = os.path.join(vnuSrc, "xml", "SaxCompiler.java") compilerClass = "nu.validator.xml.SaxCompiler" classDir = os.path.join(buildRoot, "classes") ensureDirExists(classDir) args = [ '-g', '-nowarn', '-d "%s"' % classDir, '-encoding UTF-8', ] if javaVersion != "": args.append('-target ' + javaVersion) args.append('-source ' + javaVersion) if runCmd('"%s" %s %s' % (javacCmd, " ".join(args), compilerFile)): sys.exit(1) pageEmitter = os.path.join(vnuSrc, "servlet", "PageEmitter.java") formEmitter = os.path.join(vnuSrc, "servlet", "FormEmitter.java") if runCmd('"%s" -cp %s %s %s %s' % (javaCmd, classDir, compilerClass, pageTemplate, pageEmitter)): sys.exit(1) if runCmd('"%s" -cp %s %s %s %s' % (javaCmd, classDir, compilerClass, formTemplate, formEmitter)): sys.exit(1) removeIfDirExists(classDir) def buildValidator(): classPath = os.pathsep.join(dependencyJarPaths() + jarNamesToPaths(["htmlparser"]) + jingJarPath()) buildEmitters() buildModule(buildRoot, "validator", classPath) def ownJarList(): return jarNamesToPaths(["htmlparser", "validator"]) + jingJarPath() def buildRunJarPathList(): return dependencyJarPaths(runDependencyJars) + ownJarList() def getRunArgs(heap="$((HEAP))"): classPath = os.pathsep.join(buildRunJarPathList()) args = [ '-XX:-DontCompileHugeMethods', '-Xms%sk' % heap, '-Xmx%sk' % heap, '-classpath', classPath, '-Dnu.validator.datatype.warn=true', '-Dnu.validator.messages.limit=%d' % messagesLimit, '-Dnu.validator.servlet.about-page=' + aboutPage, '-Dnu.validator.servlet.connection-timeout=%d' % (connectionTimeoutSeconds * 1000), '-Dnu.validator.servlet.follow-w3c-spec=%d' % followW3Cspec, '-Dnu.validator.servlet.host.generic=' + genericHost, '-Dnu.validator.servlet.host.html5=' + html5Host, '-Dnu.validator.servlet.host.parsetree=' + parsetreeHost, '-Dnu.validator.servlet.icon=' + icon, '-Dnu.validator.servlet.log4j-properties=' + log4jProps, '-Dnu.validator.servlet.max-file-size=%d' % (maxFileSize * 1024), '-Dnu.validator.servlet.path.generic=' + genericPath, '-Dnu.validator.servlet.path.html5=' + html5Path, '-Dnu.validator.servlet.path.parsetree=' + parsetreePath, '-Dnu.validator.servlet.service-name=' + serviceName, '-Dnu.validator.servlet.read-local-log4j-properties=1', '-Dnu.validator.servlet.results-title=' + resultsTitle, '-Dnu.validator.servlet.script=' + script, '-Dnu.validator.servlet.socket-timeout=%d' % (socketTimeoutSeconds * 1000), '-Dnu.validator.servlet.statistics=%d' % statistics, '-Dnu.validator.servlet.style-sheet=' + stylesheet, '-Dnu.validator.servlet.user-agent=' + userAgent, '-Dnu.validator.servlet.version=' + validatorVersion, '-Dnu.validator.spec.html5-load=' + html5specLoad, '-Dnu.validator.spec.html5-link=' + html5specLink, '-Dorg.mortbay.http.HttpRequest.maxFormContentSize=%d' % (maxFileSize * 1024), ] if stackSize != "": args.append('-Xss' + stackSize + 'k') args.append('-XX:ThreadStackSize=' + stackSize + 'k') if usePromiscuousSsl: args.append('-Dnu.validator.xml.promiscuous-ssl=true') args.append('nu.validator.servlet.Main') args.append(portNumber) if controlPort: args.append(controlPort) return args def generateRunScript(): args = getRunArgs() f = open(os.path.join(buildRoot, "run-validator.sh"), 'wb') f.write("#!/bin/sh\n") if heapSize.startswith('-'): f.write("HEAP=`grep MemTotal /proc/meminfo | awk '{print $2}'`\n") f.write("HEAP=$((HEAP-%d))\n" % (int(heapSize[1:]) * 1024)) else: f.write("HEAP=%d\n" % (int(heapSize) * 1024)) # Quick hack to strike a balance between shell variable expansions # having to be unquoted and command line switches that take # human-readable string potentially containing spaces. f.write(" ".join([javaCmd,] + [("'{0}'".format(x) if " " in x else x) for x in args])) if controlPort: f.write(" <&- 1>/dev/null 2>&1 &") f.write("\n") f.close() def runValidator(): ensureDirExists(os.path.join(buildRoot, "logs")) args = getRunArgs(str(int(heapSize) * 1024)) execCmd(javaCmd, args) def checkService(): doc= miniDoc.replace(" ", "%20") query = "?out=gnu&doc=data:text/html;charset=utf-8,%s" % doc url = "http://localhost:%s/%s" % (portNumber, query) args = getRunArgs(str(int(heapSize) * 1024)) daemon = subprocess.Popen([javaCmd,] + args) time.sleep(15) print "Checking %s" % url try: print urllib2.urlopen(url).read() except urllib2.HTTPError as e: print e.reason sys.exit(1) except urllib2.URLError as e: print e.reason sys.exit(1) time.sleep(5) daemon.terminate() def clean(): removeIfDirExists(distDir) removeIfDirExists(dependencyDir) removeIfDirExists(jarsDir) class Release(): def __init__(self, artifactId="validator"): self.artifactId = artifactId self.version = validatorVersion self.buildXml = os.path.join(buildRoot, "build", "build.xml") self.classpath = os.pathsep.join([ antJar, antLauncherJar, os.pathsep.join(dependencyJarPaths()), os.path.join(jingTrangDir, "build", "jing.jar"), os.path.join(jarsDir, "htmlparser.jar"), ]) self.docs = ["index.html", "README.md", "CHANGELOG.md", "LICENSE"] def reInitDistDir(self): removeIfDirExists(distDir) ensureDirExists(distDir) def setVersion(self): if self.artifactId == "jing" : self.version = jingVersion if self.artifactId == "htmlparser": self.version = jingVersion self.writeVersion() def writeVersion(self): f = open(os.path.join(distDir, "VERSION"), "w") f.write(self.version) f.close() def writeHash(self, filename, md5OrSha1): BLOCKSIZE = 65536 hasher = md5() if md5OrSha1 == "sha1": hasher = sha1() with open(filename, 'rb') as f: buf = f.read(BLOCKSIZE) while len(buf) > 0: hasher.update(buf) buf = f.read(BLOCKSIZE) o = open("%s.%s" % (filename, md5OrSha1), 'wb') o.write(hasher.hexdigest()) o.close def writeHashes(self): for filename in findFiles(distDir): if os.path.basename(filename) in self.docs: continue self.writeHash(filename, "md5") self.writeHash(filename, "sha1") def sign(self): for filename in findFiles(distDir): if os.path.basename(filename) in self.docs: continue runCmd('"%s" --yes -ab %s' % (gpgCmd, filename)) def createArtifacts(self): self.reInitDistDir() self.setVersion() runCmd('"%s" -cp %s org.apache.tools.ant.Main -f %s %s-artifacts' % (javaCmd, self.classpath, self.buildXml, self.artifactId)) def createBundle(self): self.createArtifacts() print "Building %s/%s-%s-bundle.jar" % (distDir, self.artifactId, self.version) self.sign() self.writeVersion() runCmd('"%s" -cp %s org.apache.tools.ant.Main -f %s %s-bundle' % (javaCmd, self.classpath, self.buildXml, self.artifactId)) def deployToCentral(self, url): if url == snapshotsRepoUrl: self.version += "-SNAPSHOT" self.createArtifacts() basename = "%s-%s" % (self.artifactId, self.version) mvnArgs = [ "-f %s.pom" % os.path.join(distDir, basename), "gpg:sign-and-deploy-file", "-Dgpg.executable=%s" % gpgCmd, "-DrepositoryId=ossrh", "-Durl='%s'" % url, "-DpomFile='%s.pom'" % basename, "-Dfile='%s.jar'" % basename, "-Djavadoc='%s-javadoc.jar'" % basename, "-Dsources='%s-sources.jar'" % basename, ] runCmd('"%s" %s' % (mvnCmd, " ".join(mvnArgs))) mvnArgs = [ "-f %s.pom" % os.path.join(distDir, basename), "org.sonatype.plugins:nexus-staging-maven-plugin:rc-list", "-DnexusUrl=https://oss.sonatype.org/", "-DserverId=ossrh", ] output = subprocess.check_output("%s %s" % (mvnCmd, " ".join(mvnArgs)), shell=True) for line in output.split('\n'): if "nuvalidator" in line: stagingRepositoryId = "nuvalidator-" + line[19:23] mvnArgs = [ "-f %s.pom" % os.path.join(distDir, basename), "org.sonatype.plugins:nexus-staging-maven-plugin:rc-close", "-DnexusUrl=https://oss.sonatype.org/", "-DserverId=ossrh", "-DautoReleaseAfterClose=true", "-DstagingRepositoryId=" + stagingRepositoryId ] runCmd('"%s" %s' % (mvnCmd, " ".join(mvnArgs))) mvnArgs = [ "-f %s.pom" % os.path.join(distDir, basename), "org.sonatype.plugins:nexus-staging-maven-plugin:rc-release", "-DnexusUrl=https://oss.sonatype.org/", "-DserverId=ossrh", "-DautoReleaseAfterClose=true", "-DstagingRepositoryId=" + stagingRepositoryId ] runCmd('"%s" %s' % (mvnCmd, " ".join(mvnArgs))) def deployToHeroku(self): self.createExecutable("war") runCmd('"%s" deploy:war --war %s --app vnu' % (herokuCmd, os.path.join(distDir, "vnu.war"))) def createExecutable(self, jarOrWar): self.reInitDistDir() self.setVersion() if jarOrWar == "war": os.mkdir(os.path.join(distDir, "war")) runCmd('"%s" -cp %s org.apache.tools.ant.Main -f %s %s' % (javaCmd, self.classpath, self.buildXml, jarOrWar)) def removeExtras(self): removeIfExists(os.path.join(distDir, "VERSION")) sigsums = re.compile("^.+\.asc$|^.+\.md5$|.+\.sha1$") for filename in findFiles(distDir): if (os.path.basename(filename) in self.docs or sigsums.match(filename)): removeIfExists(filename) def cleanAndCreateAdditional(self): self.removeExtras() self.writeHashes() self.sign() def createNightly(self, jarOrWar): self.version = "nightly.%s" % time.strftime('%Y-%m-%d') self.createExecutable(jarOrWar) self.cleanAndCreateAdditional() self.createDist(jarOrWar) self.cleanAndCreateAdditional() self.uploadToReleasesHost("%s/%s" % (nightliesPath, jarOrWar)) def createAndUploadDist(self, jarOrWar): self.setVersion() self.createExecutable(jarOrWar) self.cleanAndCreateAdditional() self.createDist(jarOrWar) self.cleanAndCreateAdditional() self.uploadDist(jarOrWar) def createAndUploadDistributions(self): self.createAndUploadDist("jar") self.createAndUploadDist("war") def createDist(self, jarOrWar): print "Building %s/vnu.%s_%s.zip" % (distDir, jarOrWar, self.version) if "nightly" not in self.version: for filename in self.docs: shutil.copy(os.path.join(buildRoot, filename), distDir) os.chdir("build") distroFile = os.path.join("vnu.%s_%s.zip" % (jarOrWar, self.version)) removeIfExists(distroFile) zf = zipfile.ZipFile(distroFile, "w") for dirname, subdirs, files in os.walk("dist"): zf.write(dirname) for filename in files: zf.write(os.path.join(dirname, filename)) zf.close() shutil.move(distroFile, "dist") os.chdir("..") def createOrUpdateGithubData(self): runCmd('"%s" tag -f v%s' % (gitCmd, validatorVersion)) args = [ "-u validator -r validator", "-t %s" % validatorVersion, ] if (runCmd('"%s" info %s > /dev/null 2>&1' % (ghRelCmd, " ".join(args)))): runCmd('"%s" release -p %s' % (ghRelCmd, " ".join(args))) else: runCmd('"%s" delete %s' % (ghRelCmd, " ".join(args))) runCmd('"%s" release -p %s' % (ghRelCmd, " ".join(args))) args.append('-n "%s"' % releaseDate) f = open(os.path.join(buildRoot, "WHATSNEW.md")) desc = f.read().replace('"', '\\"') desc = f.read().replace('`', '\\`') args.append('-d "%s"' % desc) runCmd('"%s" edit -p %s' % (ghRelCmd, " ".join(args))) def uploadToGithub(self): for filename in findFiles(distDir): args = [ "-u validator -r validator", "-t %s" % validatorVersion, "-n %s" % os.path.basename(filename), "-f %s" % filename, ] if "zip" in filename: runCmd('"%s" upload %s' % (ghRelCmd, " ".join(args))) def uploadToReleasesHost(self, path): for filename in findFiles(distDir): runCmd('"%s" %s %s:%s' % (scpCmd, filename, releasesHost, path)) def uploadDist(self, jarOrWar): self.uploadToReleasesHost("%s/%s" % (releasesPath, jarOrWar)) self.uploadToGithub() def check(self): vnu = os.path.join(distDir, "vnu.jar") if not os.path.exists(vnu): return formats = ["gnu", "xml", "json", "text"] for _format in formats: if runCmd('echo \'%s\' | "%s" -jar %s --format %s -' % (miniDoc, javaCmd, vnu, _format)): sys.exit(1) # to also make sure it works even w/o --format value given; returns gnu output if runCmd('echo \'%s\' | "%s" -jar %s -' % (miniDoc, javaCmd, vnu)): sys.exit(1) if runCmd('"%s" -jar %s --version' % (javaCmd, vnu)): sys.exit(1) def createTarball(): args = [ "zcf", os.path.join(buildRoot, "jars.tar.gz"), os.path.join(buildRoot, "run-validator.sh"), os.path.join(buildRoot, "site", "style.css"), os.path.join(buildRoot, "site", "script.js"), os.path.join(buildRoot, "site", "icon.png"), ] + ownJarList() runCmd('"%s" %s' %(tarCmd, " ".join(args))) def createDepTarball(): args = [ "zcf", os.path.join(buildRoot, "deps.tar.gz"), ] + dependencyJarPaths(runDependencyJars) runCmd('"%s" %s' %(tarCmd, " ".join(args))) def deployOverScp(): if not deploymentTarget: print "No target" return runCmd('"%s" "%s" %s/deps.tar.gz' % (scpCmd, os.path.join(buildRoot, "deps.tar.gz"), deploymentTarget)) runCmd('"%s" "%s" %s/jars.tar.gz' % (scpCmd, os.path.join(buildRoot, "jars.tar.gz"), deploymentTarget)) emptyPath = os.path.join(buildRoot, "EMPTY") f = open(emptyPath, 'wb') f.close() runCmd('"%s" "%s" %s/DEPLOY' % (scpCmd, emptyPath, deploymentTarget)) os.remove(emptyPath) def fetchUrlTo(url, path, md5sum=None): # I bet there's a way to do this with more efficient IO and less memory print url completed = False defaultTimeout = socket.getdefaulttimeout() while not completed: try: socket.setdefaulttimeout(httpTimeoutSeconds) f = urllib2.urlopen(url) data = f.read() f.close() completed = True except httplib.BadStatusLine: print "received error, retrying" finally: socket.setdefaulttimeout(defaultTimeout) if md5sum: m = md5(data) if md5sum != m.hexdigest(): print "Bad MD5 hash for %s." % url sys.exit(1) head, tail = os.path.split(path) if not os.path.exists(head): os.makedirs(head) f = open(path, "wb") f.write(data) f.close() def spiderApacheDirectories(baseUrl, baseDir): f = urllib2.urlopen(baseUrl, timeout=httpTimeoutSeconds) parser = UrlExtractor(baseUrl) parser.feed(f.read()) f.close() parser.close() for leaf in parser.leaves: fetchUrlTo(leaf, os.path.join(baseDir, leaf[7:])) for directory in parser.directories: spiderApacheDirectories(directory, baseDir) def downloadLocalEntities(): removeIfDirExists(os.path.join(buildRoot, "local-entities")) fileMap = { "subtag-registry": "https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry", "syntax-descriptions": "https://wiki.whatwg.org/wiki/MicrosyntaxDescriptions", "vnu-alt-advice": "https://wiki.whatwg.org/wiki/Validator.nu_alt_advice", "link-rel-extensions": "https://help.whatwg.org/extensions/link-rel/", "a-rel-extensions": "https://help.whatwg.org/extensions/a-rel/", } ensureDirExists(filesDir) for filename in fileMap: fetchUrlTo(fileMap[filename], os.path.join(filesDir, filename)) def localPathToJarCompatName(path): return javaSafeNamePat.sub('_', path) def preparePropertiesFile(): f = open(os.path.join(filesDir, "misc.properties"), 'w') f.write("nu.validator.servlet.service-name=%s\n" % serviceName) f.write("nu.validator.servlet.results-title=%s\n" % resultsTitle) f.write("nu.validator.servlet.version=%s\n" % validatorVersion) f.write("nu.validator.servlet.user-agent=%s\n" % userAgent) f.close() def prepareLocalEntityJar(): ensureDirExists(filesDir) preparePropertiesFile() createCssParserJS(filesDir) shutil.copyfile(os.path.join(buildRoot, presetsFile), os.path.join(filesDir, "presets")) shutil.copyfile(os.path.join(buildRoot, aboutFile), os.path.join(filesDir, "about.html")) shutil.copyfile(os.path.join(buildRoot, stylesheetFile), os.path.join(filesDir, "style.css")) shutil.copyfile(os.path.join(buildRoot, scriptFile), os.path.join(filesDir, "script.js")) shutil.copyfile(os.path.join(buildRoot, "site", "icon.png"), os.path.join(filesDir, "icon.png")) shutil.copyfile(os.path.join(buildRoot, "resources", "spec", "html5.html"), os.path.join(filesDir, "html5spec")) if followW3Cspec: shutil.copyfile(os.path.join(buildRoot, "resources", "spec", "w3c-html5.html"), os.path.join(filesDir, "html5spec")) shutil.copyfile(os.path.join(buildRoot, "resources", "log4j.properties"), os.path.join(filesDir, "log4j.properties")) shutil.copyfile(os.path.join(buildRoot, "README.md"), os.path.join(filesDir, "cli-help")) f = open(os.path.join(buildRoot, "resources", "entity-map.txt")) o = open(os.path.join(filesDir, "entitymap"), 'wb') try: for line in f: url, path = line.strip().split("\t") entPath = "" if path.startswith("schema/html5/"): entPath = os.path.join(buildRoot, "schema", "html5", path[13:]) elif path.startswith("schema/"): entPath = os.path.join(buildRoot, path) safeName = localPathToJarCompatName(path) safePath = os.path.join(filesDir, safeName) if os.path.exists(entPath): o.write("%s\t%s\n" % (url, safeName)) shutil.copyfile(entPath, safePath) finally: f.close() o.close() schemaDir = os.path.join(buildRoot, "schema") for file in coreSchemaDriverFiles: removeIfExists(os.path.join(schemaDir, file)) for file in htmlSchemaDriverFiles: removeIfExists(os.path.join(schemaDir, "html5", file)) removeIfDirExists(os.path.join(schemaDir, "xhtml10")) removeIfDirExists(os.path.join(schemaDir, "rdf")) def createCssParserJS(filesDir): p = open(os.path.join(dependencyDir, "parse-css.js"), 'r') j = open(os.path.join(dependencyDir, "json.js"), 'r') o = open(os.path.join(filesDir, "parse-css-js"), 'wb') shutil.copyfileobj(p, o) shutil.copyfileobj(j, o) p.close() j.close() consoleLogForRhino = '''\ var console = { log: function (msg) { throw msg; return true; } } ''' o.write(consoleLogForRhino) o.close() def zipExtract(zipArch, targetDir): z = zipfile.ZipFile(zipArch) for name in z.namelist(): filepath = os.path.join(targetDir, name) # is this portable to Windows? if not name.endswith('/'): head, tail = os.path.split(filepath) ensureDirExists(head) o = open(filepath, 'wb') o.write(z.read(name)) o.flush() o.close() def downloadDependency(url, md5sum): ensureDirExists(dependencyDir) path = os.path.join(dependencyDir, url[url.rfind("/") + 1:]) if not os.path.exists(path): fetchUrlTo(url, path, md5sum) if path.endswith(".zip"): zipExtract(path, dependencyDir) def updateSubmodules(): runCmd('"%s" submodule update --init' % gitCmd) def downloadDependencies(): for url, md5sum in dependencyPackages: downloadDependency(url, md5sum) def buildAll(): if 'JAVA_HOME' not in os.environ: print "Error: The JAVA_HOME environment variable is not set." print "Set the JAVA_HOME environment variable to the pathname of the directory where your JDK is installed." sys.exit(1) buildJing() buildSchemaDrivers() prepareLocalEntityJar() buildHtmlParser() buildValidator() def runTests(): if followW3Cspec: args = "--ignore=hgroup tests/messages.json" else: args = "--ignore=html-its tests/messages.json" className = "nu.validator.client.TestRunner" classPath = os.pathsep.join(dependencyJarPaths() + jarNamesToPaths(["htmlparser", "validator"]) + jingJarPath()) if runCmd('"%s" -classpath %s %s %s' % (javaCmd, classPath, className, args)): sys.exit(1) def splitHostSpec(spec): index = spec.find('/') return (spec[0:index], spec[index:]) def printHelp(): print "Usage: python build/build.py [options] [tasks]" print "" print "Options:" print " --about=https://about.validator.nu/" print " Sets the URL for the about page" print " --control-port=-1" print " Sets the server control port number" print " (necessary for daemonizing)" print " --git=/usr/bin/git -- Sets the path to the git binary" print " --heap=64 -- Sets the Java heap size in MB" print " --html5link=http://www.whatwg.org/specs/web-apps/current-work/" print " Sets the link URL of the HTML5 spec" print " --html5load=http://www.whatwg.org/specs/web-apps/current-work/" print " Sets the load URL of the HTML5 spec" print " --jar=/usr/bin/jar -- Sets the path to the jar binary" print " --java=/usr/bin/java -- Sets the path to the java binary" print " --javac=/usr/bin/javac -- Sets the path to the javac binary" print " --javadoc=/usr/bin/javadoc -- Sets the path to the javadoc binary" print " --javaversion=N.N -- Sets the Java VM version to build for" print " --jdk-bin=/j2se/bin -- Sets the paths for all JDK tools" print " --log4j=log4j.properties -- Sets the path to log4 configuration" print " --messages-limit=1000" print " Sets the limit on the maximum number" print " of error+warning messages to report" print " for any document before stopping" print " --name=Validator.nu -- Sets the service name" print " --port=8888 -- Sets the server port number" print " --promiscuous-ssl=on -- Don't check SSL/TLS certificate trust chain" print " --results-title=Validation results" print " Sets the title to show on the results page" print " --script=script.js" print " Sets the URL for the script" print " Defaults to just script.js relative to" print " the validator URL" print " --stacksize=NN -- Sets the Java thread stack size in KB" print " --stylesheet=style.css" print " Sets the URL for the style sheet" print " Defaults to just style.css relative to" print " the validator URL" print " --user-agent Sets the User-Agent string for the checker" print "" print "Tasks:" print " update -- Update git submodules" print " dldeps -- Download missing dependency libraries and entities" print " build -- Build the source" print " test -- Run regression tests" print " check -- Perform self-test of the system" print " run -- Run the system" print " all -- update dldeps build test run" print " bundle -- Create a Maven release bundle" print " jar -- Create a JAR file containing a release distribution" print " war -- Create a WAR file containing a release distribution" print " checkjar -- Run tests with the build jar file" print " script -- Make run-validator.sh script for running the system" buildScript = sys.argv[0] argv = sys.argv[1:] if len(argv) == 0: printHelp() else: for arg in argv: if arg.startswith("--git="): gitCmd = arg[6:] elif arg.startswith("--java="): javaCmd = arg[7:] elif arg.startswith("--jar="): jarCmd = arg[6:] elif arg.startswith("--javac="): javacCmd = arg[8:] elif arg.startswith("--javadoc="): javadocCmd = arg[10:] elif arg.startswith("--jdk-bin="): jdkBinDir = arg[10:] javaCmd = os.path.join(jdkBinDir, "java") jarCmd = os.path.join(jdkBinDir, "jar") javacCmd = os.path.join(jdkBinDir, "javac") javadocCmd = os.path.join(jdkBinDir, "javadoc") elif arg.startswith("--port="): portNumber = arg[7:] elif arg.startswith("--control-port="): controlPort = arg[15:] elif arg.startswith("--log4j="): log4jProps = arg[8:] elif arg.startswith("--heap="): heapSize = arg[7:] elif arg.startswith("--stacksize="): stackSize = arg[12:] elif arg.startswith("--javaversion="): javaVersion = arg[14:] elif arg.startswith("--html5link="): html5specLink = arg[12:] elif arg.startswith("--html5load="): html5specLoad = arg[12:] ianaCharset = arg[15:] elif arg.startswith("--about="): aboutPage = arg[8:] elif arg.startswith("--stylesheet="): stylesheet = arg[13:] elif arg.startswith("--icon="): icon = arg[7:] elif arg.startswith("--user-agent="): userAgent = arg[13:] elif arg.startswith("--scp-target="): deploymentTarget = arg[13:] elif arg.startswith("--script="): script = arg[9:] elif arg.startswith("--name="): serviceName = arg[7:] elif arg.startswith("--results-title="): resultsTitle = arg[16:] elif arg.startswith("--messages-limit="): messagesLimit = int(arg[17:]) elif arg.startswith("--genericpath="): (genericHost, genericPath) = splitHostSpec(arg[14:]) elif arg.startswith("--html5path="): (html5Host, html5Path) = splitHostSpec(arg[12:]) elif arg.startswith("--parsetreepath="): (parsetreeHost, parsetreePath) = splitHostSpec(arg[16:]) elif arg.startswith("--page-template="): pageTemplate = arg[16:] elif arg.startswith("--form-template="): formTemplate = arg[16:] elif arg.startswith("--presets-file="): presetsFile = arg[15:] elif arg.startswith("--about-file="): aboutFile = arg[13:] elif arg.startswith("--stylesheet-file="): stylesheetFile = arg[18:] elif arg.startswith("--script-file="): scriptFile = arg[14:] elif arg == '--promiscuous-ssl=on': usePromiscuousSsl = 1 elif arg == '--promiscuous-ssl=off': usePromiscuousSsl = 0 elif arg == '--no-self-update': pass elif arg == '--local': pass elif arg.startswith("--connection-timeout="): connectionTimeoutSeconds = int(arg[21:]) elif arg.startswith("--socket-timeout="): socketTimeoutSeconds = int(arg[17:]) elif arg == '--follow-w3c-spec': followW3Cspec = 1 elif arg == '--statistics': statistics = 1 elif arg == '--help': printHelp() elif arg == 'update': updateSubmodules() elif arg == 'dldeps': downloadDependencies() downloadLocalEntities() elif arg == 'checkout': pass elif arg == 'build': buildAll() elif arg == 'bundle': release = Release() release.createBundle() elif arg == 'snapshot': release = Release() release.deployToCentral(snapshotsRepoUrl) elif arg == 'release': release = Release() release.deployToCentral(stagingRepoUrl) release.createOrUpdateGithubData() release.createAndUploadDistributions() elif arg == 'htmlparser-bundle': release = Release("htmlparser") release.createBundle() elif arg == 'htmlparser-snapshot': release = Release("htmlparser") release.deployToCentral(snapshotsRepoUrl) elif arg == 'htmlparser-release': release = Release("htmlparser") release.deployToCentral(stagingRepoUrl) elif arg == 'jing-bundle': release = Release("jing") release.createBundle() elif arg == 'jing-snapshot': release = Release("jing") release.deployToCentral(snapshotsRepoUrl) elif arg == 'jing-release': release = Release("jing") release.deployToCentral(stagingRepoUrl) elif arg == 'jar': release = Release() release.createExecutable("jar") release.check() elif arg == 'war': release = Release() release.createExecutable("war") elif arg == 'nightly': release = Release() release.createNightly("jar") release.createNightly("war") elif arg == 'heroku': release = Release() release.deployToHeroku() elif arg == 'localent': prepareLocalEntityJar() elif arg == 'deploy': deployOverScp() elif arg == 'tar': createTarball() createDepTarball() elif arg == 'script': if not stylesheet: stylesheet = 'style.css' if not script: script = 'script.js' if not icon: icon = 'icon.png' generateRunScript() elif arg == 'test': runTests() elif arg == 'check': if not stylesheet: stylesheet = 'style.css' if not script: script = 'script.js' if not icon: icon = 'icon.png' checkService() elif arg == 'clean': clean(); elif arg == 'run': if not stylesheet: stylesheet = 'style.css' if not script: script = 'script.js' if not icon: icon = 'icon.png' runValidator() elif arg == 'all': updateSubmodules() downloadDependencies() downloadLocalEntities() prepareLocalEntityJar() buildAll() runTests() if not stylesheet: stylesheet = 'style.css' if not script: script = 'script.js' if not icon: icon = 'icon.png' runValidator() else: print "Unknown option %s." % arg # vim: sw=2
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 14, 23, 199, 199, 3, 1898, 334, 67, 9, 10219, 20855, 322, 428, 1003, 265, 287, 199, 3, 1898, 334, 67, 9, 9079, 13, 7806, 17728, 2752, 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, 298, 10337, 1288, 199, 3, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 199, 3, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 199, 3, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 199, 3, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 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, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 199, 3, 2334, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 199, 3, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 199, 3, 13198, 1621, 2334, 4141, 14, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 8809, 199, 646, 4011, 18, 199, 646, 2838, 199, 646, 295, 199, 893, 26, 523, 687, 8337, 492, 6128, 21, 199, 2590, 3545, 26, 523, 687, 6128, 21, 492, 892, 465, 6128, 21, 199, 893, 26, 523, 687, 8337, 492, 7793, 17, 199, 2590, 3545, 26, 523, 687, 7793, 17, 492, 892, 465, 7793, 17, 199, 646, 10392, 199, 646, 984, 199, 504, 12578, 25598, 492, 18868, 1698, 2842, 199, 646, 3873, 199, 646, 900, 199, 199, 6138, 3353, 275, 283, 17, 14, 22, 7, 199, 30738, 645, 7874, 275, 283, 30738, 645, 7, 199, 7338, 7874, 275, 283, 7338, 7, 199, 6138, 7874, 275, 283, 6138, 7, 199, 30738, 350, 679, 7874, 275, 283, 30738, 350, 679, 7, 199, 2523, 745, 85, 7874, 29, 283, 2523, 745, 85, 7, 199, 3561, 5640, 7874, 275, 283, 5031, 13, 3221, 7, 199, 5369, 7874, 275, 283, 5369, 7, 199, 17124, 7874, 275, 283, 17124, 7, 199, 3187, 7874, 275, 283, 3187, 7, 199, 77, 6002, 7874, 275, 283, 77, 6002, 7, 199, 21284, 7874, 275, 283, 21284, 18, 7, 199, 199, 15331, 11334, 6417, 275, 283, 2859, 921, 26890, 14, 834, 8588, 14, 1308, 15, 1317, 15, 23949, 15, 15331, 4805, 199, 26840, 11334, 6417, 275, 283, 2859, 921, 26890, 14, 834, 8588, 14, 1308, 15, 1364, 15, 1832, 15, 26840, 15, 11060, 15, 391, 1856, 18, 4805, 199, 3, 315, 2195, 25975, 5510, 15, 888, 12, 1265, 7171, 1929, 370, 5627, 282, 1591, 4310, 298, 11840, 4965, 2, 199, 11840, 4965, 275, 298, 11840, 4965, 2, 199, 14873, 6528, 2042, 275, 3286, 1391, 15, 1544, 15, 14873, 6528, 2, 199, 11840, 2042, 275, 3286, 1391, 15, 1544, 15, 11840, 2, 199, 199, 3221, 2506, 275, 900, 14, 6205, 3508, 68, 450, 34, 450, 57, 358, 199, 11034, 3353, 275, 900, 14, 6205, 3508, 89, 4111, 13, 77, 4111, 13, 69, 358, 199, 74, 316, 3353, 275, 298, 1797, 13725, 1398, 54, 1440, 2, 199, 1360, 2087, 3353, 275, 298, 17, 14, 20, 14, 17, 2, 199, 199, 1506, 6405, 275, 7815, 199, 2686, 3567, 275, 747, 14, 515, 14, 904, 8, 1506, 6405, 12, 298, 1506, 401, 298, 2686, 531, 199, 8575, 3567, 275, 747, 14, 515, 14, 904, 8, 1506, 6405, 12, 298, 5714, 531, 199, 32262, 3567, 275, 747, 14, 515, 14, 904, 8, 1506, 6405, 12, 298, 32262, 531, 199, 74, 316, 14064, 621, 3567, 275, 747, 14, 515, 14, 904, 8, 1506, 6405, 12, 298, 74, 316, 13, 454, 621, 531, 199, 86, 4850, 21261, 275, 747, 14, 515, 14, 904, 8, 1506, 6405, 12, 298, 2164, 401, 298, 4850, 401, 298, 11034, 531, 199, 1725, 3567, 275, 747, 14, 515, 14, 904, 8, 86, 4850, 21261, 12, 298, 320, 696, 552, 5080, 401, 298, 1725, 531, 199, 867, 6405, 275, 747, 14, 515, 14, 904, 8, 74, 316, 14064, 621, 3567, 12, 298, 773, 531, 199, 867, 12977, 275, 747, 14, 515, 14, 904, 8, 867, 6405, 12, 298, 867, 14, 7338, 531, 199, 867, 18543, 281, 12977, 275, 747, 14, 515, 14, 904, 8, 867, 6405, 12, 298, 867, 13, 27326, 14, 7338, 531, 199, 199, 1606, 4231, 275, 747, 14, 515, 14, 904, 480, 2124, 401, 298, 3276, 37, 22541, 14, 1652, 531, 199, 964, 4231, 275, 747, 14, 515, 14, 904, 480, 2124, 401, 298, 2821, 37, 22541, 14, 1652, 531, 199, 657, 2193, 1173, 275, 747, 14, 515, 14, 904, 480, 4435, 401, 298, 657, 2193, 14, 2424, 531, 199, 10254, 1173, 275, 747, 14, 515, 14, 904, 480, 2124, 401, 298, 10254, 14, 1360, 531, 199, 15479, 1173, 275, 747, 14, 515, 14, 904, 480, 2124, 401, 298, 2487, 14, 3919, 531, 199, 1579, 1173, 275, 747, 14, 515, 14, 904, 480, 2124, 401, 298, 1579, 14, 3596, 531, 199, 199, 719, 3259, 275, 283, 14871, 7, 199, 2785, 4313, 275, 488, 199, 793, 20, 74, 24188, 275, 283, 4435, 15, 793, 20, 74, 14, 3282, 7, 199, 12492, 2320, 275, 283, 3933, 7, 199, 2340, 2320, 275, 2125, 199, 1360, 21, 1650, 3834, 275, 283, 2859, 921, 1544, 14, 10058, 23596, 14, 1308, 15, 7273, 15, 2520, 13, 5181, 15, 1818, 13, 800, 4805, 199, 1360, 21, 1650, 6200, 275, 283, 2859, 921, 1544, 14, 10058, 23596, 14, 1308, 15, 7273, 15, 2520, 13, 5181, 15, 1818, 13, 800, 4805, 199, 10254, 3276, 275, 283, 2859, 921, 10254, 14, 11034, 14, 4850, 4805, 199, 751, 7788, 275, 283, 8640, 14, 4850, 15, 18750, 7, 199, 4677, 275, 488, 199, 15479 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 14, 23, 199, 199, 3, 1898, 334, 67, 9, 10219, 20855, 322, 428, 1003, 265, 287, 199, 3, 1898, 334, 67, 9, 9079, 13, 7806, 17728, 2752, 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, 298, 10337, 1288, 199, 3, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 199, 3, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 199, 3, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 199, 3, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 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, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 199, 3, 2334, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 199, 3, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 199, 3, 13198, 1621, 2334, 4141, 14, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 8809, 199, 646, 4011, 18, 199, 646, 2838, 199, 646, 295, 199, 893, 26, 523, 687, 8337, 492, 6128, 21, 199, 2590, 3545, 26, 523, 687, 6128, 21, 492, 892, 465, 6128, 21, 199, 893, 26, 523, 687, 8337, 492, 7793, 17, 199, 2590, 3545, 26, 523, 687, 7793, 17, 492, 892, 465, 7793, 17, 199, 646, 10392, 199, 646, 984, 199, 504, 12578, 25598, 492, 18868, 1698, 2842, 199, 646, 3873, 199, 646, 900, 199, 199, 6138, 3353, 275, 283, 17, 14, 22, 7, 199, 30738, 645, 7874, 275, 283, 30738, 645, 7, 199, 7338, 7874, 275, 283, 7338, 7, 199, 6138, 7874, 275, 283, 6138, 7, 199, 30738, 350, 679, 7874, 275, 283, 30738, 350, 679, 7, 199, 2523, 745, 85, 7874, 29, 283, 2523, 745, 85, 7, 199, 3561, 5640, 7874, 275, 283, 5031, 13, 3221, 7, 199, 5369, 7874, 275, 283, 5369, 7, 199, 17124, 7874, 275, 283, 17124, 7, 199, 3187, 7874, 275, 283, 3187, 7, 199, 77, 6002, 7874, 275, 283, 77, 6002, 7, 199, 21284, 7874, 275, 283, 21284, 18, 7, 199, 199, 15331, 11334, 6417, 275, 283, 2859, 921, 26890, 14, 834, 8588, 14, 1308, 15, 1317, 15, 23949, 15, 15331, 4805, 199, 26840, 11334, 6417, 275, 283, 2859, 921, 26890, 14, 834, 8588, 14, 1308, 15, 1364, 15, 1832, 15, 26840, 15, 11060, 15, 391, 1856, 18, 4805, 199, 3, 315, 2195, 25975, 5510, 15, 888, 12, 1265, 7171, 1929, 370, 5627, 282, 1591, 4310, 298, 11840, 4965, 2, 199, 11840, 4965, 275, 298, 11840, 4965, 2, 199, 14873, 6528, 2042, 275, 3286, 1391, 15, 1544, 15, 14873, 6528, 2, 199, 11840, 2042, 275, 3286, 1391, 15, 1544, 15, 11840, 2, 199, 199, 3221, 2506, 275, 900, 14, 6205, 3508, 68, 450, 34, 450, 57, 358, 199, 11034, 3353, 275, 900, 14, 6205, 3508, 89, 4111, 13, 77, 4111, 13, 69, 358, 199, 74, 316, 3353, 275, 298, 1797, 13725, 1398, 54, 1440, 2, 199, 1360, 2087, 3353, 275, 298, 17, 14, 20, 14, 17, 2, 199, 199, 1506, 6405, 275, 7815, 199, 2686, 3567, 275, 747, 14, 515, 14, 904, 8, 1506, 6405, 12, 298, 1506, 401, 298, 2686, 531, 199, 8575, 3567, 275, 747, 14, 515, 14, 904, 8, 1506, 6405, 12, 298, 5714, 531, 199, 32262, 3567, 275, 747, 14, 515, 14, 904, 8, 1506, 6405, 12, 298, 32262, 531, 199, 74, 316, 14064, 621, 3567, 275, 747, 14, 515, 14, 904, 8, 1506, 6405, 12, 298, 74, 316, 13, 454, 621, 531, 199, 86, 4850, 21261, 275, 747, 14, 515, 14, 904, 8, 1506, 6405, 12, 298, 2164, 401, 298, 4850, 401, 298, 11034, 531, 199, 1725, 3567, 275, 747, 14, 515, 14, 904, 8, 86, 4850, 21261, 12, 298, 320, 696, 552, 5080, 401, 298, 1725, 531, 199, 867, 6405, 275, 747, 14, 515, 14, 904, 8, 74, 316, 14064, 621, 3567, 12, 298, 773, 531, 199, 867, 12977, 275, 747, 14, 515, 14, 904, 8, 867, 6405, 12, 298, 867, 14, 7338, 531, 199, 867, 18543, 281, 12977, 275, 747, 14, 515, 14, 904, 8, 867, 6405, 12, 298, 867, 13, 27326, 14, 7338, 531, 199, 199, 1606, 4231, 275, 747, 14, 515, 14, 904, 480, 2124, 401, 298, 3276, 37, 22541, 14, 1652, 531, 199, 964, 4231, 275, 747, 14, 515, 14, 904, 480, 2124, 401, 298, 2821, 37, 22541, 14, 1652, 531, 199, 657, 2193, 1173, 275, 747, 14, 515, 14, 904, 480, 4435, 401, 298, 657, 2193, 14, 2424, 531, 199, 10254, 1173, 275, 747, 14, 515, 14, 904, 480, 2124, 401, 298, 10254, 14, 1360, 531, 199, 15479, 1173, 275, 747, 14, 515, 14, 904, 480, 2124, 401, 298, 2487, 14, 3919, 531, 199, 1579, 1173, 275, 747, 14, 515, 14, 904, 480, 2124, 401, 298, 1579, 14, 3596, 531, 199, 199, 719, 3259, 275, 283, 14871, 7, 199, 2785, 4313, 275, 488, 199, 793, 20, 74, 24188, 275, 283, 4435, 15, 793, 20, 74, 14, 3282, 7, 199, 12492, 2320, 275, 283, 3933, 7, 199, 2340, 2320, 275, 2125, 199, 1360, 21, 1650, 3834, 275, 283, 2859, 921, 1544, 14, 10058, 23596, 14, 1308, 15, 7273, 15, 2520, 13, 5181, 15, 1818, 13, 800, 4805, 199, 1360, 21, 1650, 6200, 275, 283, 2859, 921, 1544, 14, 10058, 23596, 14, 1308, 15, 7273, 15, 2520, 13, 5181, 15, 1818, 13, 800, 4805, 199, 10254, 3276, 275, 283, 2859, 921, 10254, 14, 11034, 14, 4850, 4805, 199, 751, 7788, 275, 283, 8640, 14, 4850, 15, 18750, 7, 199, 4677, 275, 488, 199, 15479, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
andyzsf/django-cms
cms/models/pluginmodel.py
7
20106
# -*- coding: utf-8 -*- from datetime import date import json from operator import itemgetter import os import warnings from django.conf import settings from django.core.urlresolvers import NoReverseMatch from django.core.exceptions import ValidationError, ObjectDoesNotExist from django.db import models from django.db.models import signals, Model from django.db.models.base import model_unpickle, ModelBase from django.db.models.query_utils import DeferredAttribute from django.utils import six, timezone from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.safestring import mark_safe from django.utils.six.moves import filter from django.utils.translation import ugettext_lazy as _ from cms.exceptions import DontUsePageAttributeWarning from cms.models.placeholdermodel import Placeholder from cms.plugin_rendering import PluginContext, render_plugin from cms.utils import get_cms_setting from cms.utils.helpers import reversion_register from cms.utils.urlutils import admin_reverse from treebeard.mp_tree import MP_Node class BoundRenderMeta(object): def __init__(self, meta): self.index = 0 self.total = 1 self.text_enabled = getattr(meta, 'text_enabled', False) class PluginModelBase(ModelBase): """ Metaclass for all CMSPlugin subclasses. This class should not be used for any other type of models. """ def __new__(cls, name, bases, attrs): # remove RenderMeta from the plugin class attr_meta = attrs.pop('RenderMeta', None) # create a new class (using the super-metaclass) new_class = super(PluginModelBase, cls).__new__(cls, name, bases, attrs) # if there is a RenderMeta in attrs, use this one # else try to use the one from the superclass (if present) meta = attr_meta or getattr(new_class, '_render_meta', None) treebeard_view_fields = (f for f in new_class._meta.fields if f.name in ('depth', 'numchild', 'path')) for field in treebeard_view_fields: field.editable = False # set a new BoundRenderMeta to prevent leaking of state new_class._render_meta = BoundRenderMeta(meta) return new_class @python_2_unicode_compatible class CMSPlugin(six.with_metaclass(PluginModelBase, MP_Node)): ''' The base class for a CMS plugin model. When defining a new custom plugin, you should store plugin-instance specific information on a subclass of this class. An example for this would be to store the number of pictures to display in a galery. Two restrictions apply when subclassing this to use in your own models: 1. Subclasses of CMSPlugin *cannot be further subclassed* 2. Subclasses of CMSPlugin cannot define a "text" field. ''' placeholder = models.ForeignKey(Placeholder, editable=False, null=True) parent = models.ForeignKey('self', blank=True, null=True, editable=False) position = models.PositiveSmallIntegerField(_("position"), blank=True, null=True, editable=False) language = models.CharField(_("language"), max_length=15, blank=False, db_index=True, editable=False) plugin_type = models.CharField(_("plugin_name"), max_length=50, db_index=True, editable=False) creation_date = models.DateTimeField(_("creation date"), editable=False, default=timezone.now) changed_date = models.DateTimeField(auto_now=True) child_plugin_instances = None translatable_content_excluded_fields = [] class Meta: app_label = 'cms' class RenderMeta: index = 0 total = 1 text_enabled = False def __reduce__(self): """ Provide pickling support. Normally, this just dispatches to Python's standard handling. However, for models with deferred field loading, we need to do things manually, as they're dynamically created classes and only module-level classes can be pickled by the default path. """ data = self.__dict__ # The obvious thing to do here is to invoke super().__reduce__() # for the non-deferred case. Don't do that. # On Python 2.4, there is something wierd with __reduce__, # and as a result, the super call will cause an infinite recursion. # See #10547 and #12121. deferred_fields = [f for f in self._meta.fields if isinstance(self.__class__.__dict__.get(f.attname), DeferredAttribute)] model = self._meta.proxy_for_model return (model_unpickle, (model, deferred_fields), data) def __str__(self): return force_text(self.pk) def get_plugin_name(self): from cms.plugin_pool import plugin_pool return plugin_pool.get_plugin(self.plugin_type).name def get_short_description(self): instance = self.get_plugin_instance()[0] if instance is not None: return force_text(instance) return _("<Empty>") def get_plugin_class(self): from cms.plugin_pool import plugin_pool return plugin_pool.get_plugin(self.plugin_type) def get_plugin_class_instance(self, admin=None): plugin_class = self.get_plugin_class() # needed so we have the same signature as the original ModelAdmin return plugin_class(plugin_class.model, admin) def get_plugin_instance(self, admin=None): ''' Given a plugin instance (usually as a CMSPluginBase), this method returns a tuple containing: instance - The instance AS THE APPROPRIATE SUBCLASS OF CMSPluginBase and not necessarily just 'self', which is often just a CMSPluginBase, plugin - the associated plugin class instance (subclass of CMSPlugin) ''' plugin = self.get_plugin_class_instance(admin) if hasattr(self, "_inst"): return self._inst, plugin if plugin.model != self.__class__: # and self.__class__ == CMSPlugin: # (if self is actually a subclass, getattr below would break) try: instance = plugin.model.objects.get(cmsplugin_ptr=self) instance._render_meta = self._render_meta except (AttributeError, ObjectDoesNotExist): instance = None else: instance = self self._inst = instance return self._inst, plugin def render_plugin(self, context=None, placeholder=None, admin=False, processors=None): instance, plugin = self.get_plugin_instance() if instance and not (admin and not plugin.admin_preview): if not placeholder or not isinstance(placeholder, Placeholder): placeholder = instance.placeholder placeholder_slot = placeholder.slot current_app = context.current_app if context else None context = PluginContext(context, instance, placeholder, current_app=current_app) context = plugin.render(context, instance, placeholder_slot) request = context.get('request', None) page = None if request: page = request.current_page context['allowed_child_classes'] = plugin.get_child_classes(placeholder_slot, page) if plugin.render_plugin: template = plugin._get_render_template(context, instance, placeholder) if not template: raise ValidationError("plugin has no render_template: %s" % plugin.__class__) else: template = None return render_plugin(context, instance, placeholder, template, processors, context.current_app) else: from cms.middleware.toolbar import toolbar_plugin_processor if processors and toolbar_plugin_processor in processors: if not placeholder: placeholder = self.placeholder current_app = context.current_app if context else None context = PluginContext(context, self, placeholder, current_app=current_app) template = None return render_plugin(context, self, placeholder, template, processors, context.current_app) return "" def get_media_path(self, filename): pages = self.placeholder.page_set.all() if pages.count(): return pages[0].get_media_path(filename) else: # django 1.0.2 compatibility today = date.today() return os.path.join(get_cms_setting('PAGE_MEDIA_PATH'), str(today.year), str(today.month), str(today.day), filename) @property def page(self): warnings.warn( "Don't use the page attribute on CMSPlugins! CMSPlugins are not " "guaranteed to have a page associated with them!", DontUsePageAttributeWarning) return self.placeholder.page if self.placeholder_id else None def get_instance_icon_src(self): """ Get src URL for instance's icon """ instance, plugin = self.get_plugin_instance() return plugin.icon_src(instance) if instance else u'' def get_instance_icon_alt(self): """ Get alt text for instance's icon """ instance, plugin = self.get_plugin_instance() return force_text(plugin.icon_alt(instance)) if instance else u'' def save(self, no_signals=False, *args, **kwargs): if not self.depth: if self.parent_id or self.parent: self.parent.add_child(instance=self) else: if not self.position and not self.position == 0: self.position == CMSPlugin.objects.filter(parent__isnull=True, placeholder_id=self.placeholder_id).count() self.add_root(instance=self) return super(CMSPlugin, self).save() def reload(self): return CMSPlugin.objects.get(pk=self.pk) def move(self, target, pos=None): super(CMSPlugin, self).move(target, pos) return self.reload() def set_base_attr(self, plugin): for attr in ['parent_id', 'placeholder', 'language', 'plugin_type', 'creation_date', 'depth', 'path', 'numchild', 'pk', 'position']: setattr(plugin, attr, getattr(self, attr)) def copy_plugin(self, target_placeholder, target_language, parent_cache, no_signals=False): """ Copy this plugin and return the new plugin. The logic of this method is the following: # get a new generic plugin instance # assign the position in the plugin tree # save it to let mptt/treebeard calculate the tree attributes # then get a copy of the current plugin instance # assign to it the id of the generic plugin instance above; this will effectively change the generic plugin created above into a concrete one # copy the tree related attributes from the generic plugin to the concrete one # save the concrete plugin # trigger the copy relations # return the generic plugin instance This copy logic is required because we don't know what the fields of the real plugin are. By getting another instance of it at step 4 and then overwriting its ID at step 5, the ORM will copy the custom fields for us. """ try: plugin_instance, cls = self.get_plugin_instance() except KeyError: # plugin type not found anymore return # set up some basic attributes on the new_plugin new_plugin = CMSPlugin() new_plugin.placeholder = target_placeholder # we assign a parent to our new plugin parent_cache[self.pk] = new_plugin if self.parent: parent = parent_cache[self.parent_id] parent = CMSPlugin.objects.get(pk=parent.pk) new_plugin.parent_id = parent.pk new_plugin.parent = parent new_plugin.language = target_language new_plugin.plugin_type = self.plugin_type if no_signals: from cms.signals import pre_save_plugins signals.pre_save.disconnect(pre_save_plugins, sender=CMSPlugin, dispatch_uid='cms_pre_save_plugin') signals.pre_save.disconnect(pre_save_plugins, sender=CMSPlugin) new_plugin._no_reorder = True new_plugin.save() if plugin_instance: # get a new instance so references do not get mixed up plugin_instance = plugin_instance.__class__.objects.get(pk=plugin_instance.pk) plugin_instance.pk = new_plugin.pk plugin_instance.id = new_plugin.pk plugin_instance.placeholder = target_placeholder plugin_instance.cmsplugin_ptr = new_plugin plugin_instance.language = target_language plugin_instance.parent = new_plugin.parent plugin_instance.depth = new_plugin.depth plugin_instance.path = new_plugin.path plugin_instance.numchild = new_plugin.numchild plugin_instance._no_reorder = True plugin_instance.save() old_instance = plugin_instance.__class__.objects.get(pk=self.pk) plugin_instance.copy_relations(old_instance) if no_signals: signals.pre_save.connect(pre_save_plugins, sender=CMSPlugin, dispatch_uid='cms_pre_save_plugin') return new_plugin @classmethod def fix_tree(cls, destructive=False): """ Fixes the plugin tree by first calling treebeard fix_tree and the recalculating the correct position property for each plugin. """ from cms.utils.plugins import reorder_plugins super(CMSPlugin, cls).fix_tree(destructive) for placeholder in Placeholder.objects.all(): for language, __ in settings.LANGUAGES: order = CMSPlugin.objects.filter(placeholder_id=placeholder.pk, language=language, parent_id__isnull=True ).values_list('pk', flat=True) reorder_plugins(placeholder, None, language, order) for plugin in CMSPlugin.objects.filter(placeholder_id=placeholder.pk, language=language).order_by('depth', 'path'): order = CMSPlugin.objects.filter(parent_id=plugin.pk).values_list('pk', flat=True) reorder_plugins(placeholder, plugin.pk, language, order) def post_copy(self, old_instance, new_old_ziplist): """ Handle more advanced cases (eg Text Plugins) after the original is copied """ pass def copy_relations(self, old_instance): """ Handle copying of any relations attached to this plugin. Custom plugins have to do this themselves! """ pass def has_change_permission(self, request): page = self.placeholder.page if self.placeholder else None if page: return page.has_change_permission(request) elif self.placeholder: return self.placeholder.has_change_permission(request) return False def get_position_in_placeholder(self): """ 1 based position! """ return self.position + 1 def get_breadcrumb(self): from cms.models import Page model = self.placeholder._get_attached_model() or Page breadcrumb = [] if not self.parent_id: try: url = force_text( admin_reverse("%s_%s_edit_plugin" % (model._meta.app_label, model._meta.model_name), args=[self.pk])) except NoReverseMatch: url = force_text( admin_reverse("%s_%s_edit_plugin" % (Page._meta.app_label, Page._meta.model_name), args=[self.pk])) breadcrumb.append({'title': force_text(self.get_plugin_name()), 'url': url}) return breadcrumb for parent in self.get_ancestors().reverse(): try: url = force_text( admin_reverse("%s_%s_edit_plugin" % (model._meta.app_label, model._meta.model_name), args=[parent.pk])) except NoReverseMatch: url = force_text( admin_reverse("%s_%s_edit_plugin" % (Page._meta.app_label, Page._meta.model_name), args=[parent.pk])) breadcrumb.append({'title': force_text(parent.get_plugin_name()), 'url': url}) return breadcrumb def get_breadcrumb_json(self): result = json.dumps(self.get_breadcrumb()) result = mark_safe(result) return result def num_children(self): return self.numchild def notify_on_autoadd(self, request, conf): """ Method called when we auto add this plugin via default_plugins in CMS_PLACEHOLDER_CONF. Some specific plugins may have some special stuff to do when they are auto added. """ pass def notify_on_autoadd_children(self, request, conf, children): """ Method called when we auto add children to this plugin via default_plugins/<plugin>/children in CMS_PLACEHOLDER_CONF. Some specific plugins may have some special stuff to do when we add children to them. ie : TextPlugin must update its content to add HTML tags to be able to see his children in WYSIWYG. """ pass def get_translatable_content(self): """ Returns {field_name: field_contents} for translatable fields, where field_contents > '' """ fields = (f for f in self._meta.fields if isinstance(f, (models.CharField, models.TextField)) and f.editable and not f.choices and f.name not in self.translatable_content_excluded_fields) return dict(filter(itemgetter(1), ((f.name, getattr(self, f.name)) for f in fields))) def set_translatable_content(self, fields): for field, value in fields.items(): setattr(self, field, value) self.save() return all(getattr(self, field) == value for field, value in fields.items()) def delete(self, no_mp=False, *args, **kwargs): if no_mp: Model.delete(self, *args, **kwargs) else: super(CMSPlugin, self).delete(*args, **kwargs) @property def add_url(self): """ Returns a custom url to add plugin instances """ return None @property def edit_url(self): """ Returns a custom url to edit plugin instances """ return None @property def move_url(self): """ Returns a custom url to move plugin instances """ return None @property def delete_url(self): """ Returns a custom url to delete plugin instances """ return None @property def copy_url(self): """ Returns a custom url to copy plugin instances """ return None reversion_register(CMSPlugin) def get_plugin_media_path(instance, filename): """ Django 1.7 requires that unbound function used in fields' definitions are defined outside the parent class (see https://docs.djangoproject.com/en/dev/topics/migrations/#serializing-values) This function is used withing field definition: file = models.FileField(_("file"), upload_to=get_plugin_media_path) and it invokes the bounded method on the given instance at runtime """ return instance.get_media_path(filename)
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 2197, 492, 1434, 199, 646, 2022, 199, 504, 4182, 492, 1242, 7416, 199, 646, 747, 199, 646, 3598, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 16522, 492, 32036, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 12, 24803, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 10166, 12, 5822, 199, 504, 1639, 14, 697, 14, 992, 14, 1095, 492, 1402, 63, 324, 8092, 12, 5822, 1563, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 17448, 1646, 199, 504, 1639, 14, 1208, 492, 3816, 12, 7137, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 2366, 63, 18, 63, 2975, 63, 6490, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 2457, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 19240, 14, 3924, 492, 577, 1888, 6119, 3276, 1646, 3849, 199, 504, 19240, 14, 992, 14, 6199, 1238, 492, 10902, 4302, 199, 504, 19240, 14, 2718, 63, 28228, 492, 11349, 2998, 12, 3795, 63, 2718, 199, 504, 19240, 14, 1208, 492, 664, 63, 10781, 63, 6031, 199, 504, 19240, 14, 1208, 14, 7546, 492, 295, 1023, 63, 2683, 199, 504, 19240, 14, 1208, 14, 633, 1208, 492, 4628, 63, 4471, 199, 199, 504, 3123, 15283, 14, 311, 63, 2350, 492, 27365, 63, 1716, 421, 199, 533, 21972, 9216, 3396, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3404, 304, 267, 291, 14, 1080, 275, 378, 267, 291, 14, 2923, 275, 413, 267, 291, 14, 505, 63, 3827, 275, 2519, 8, 2024, 12, 283, 505, 63, 3827, 297, 756, 9, 421, 199, 533, 11349, 1685, 1563, 8, 1685, 1563, 304, 272, 408, 272, 6288, 533, 367, 1006, 29554, 5061, 9180, 14, 961, 1021, 1077, 440, 506, 1202, 367, 272, 1263, 1163, 730, 402, 1709, 14, 272, 408, 339, 347, 636, 1222, 721, 1886, 12, 536, 12, 9768, 12, 3290, 304, 267, 327, 2813, 17769, 3396, 687, 314, 3589, 1021, 267, 1921, 63, 2024, 275, 3290, 14, 1935, 360, 9216, 3396, 297, 488, 9, 398, 327, 1218, 282, 892, 1021, 334, 4941, 314, 1613, 13, 6577, 9, 267, 892, 63, 533, 275, 1613, 8, 5061, 1685, 1563, 12, 843, 2843, 1222, 721, 1886, 12, 536, 12, 9768, 12, 3290, 9, 398, 327, 340, 2337, 365, 282, 17769, 3396, 315, 3290, 12, 675, 642, 1373, 267, 327, 587, 862, 370, 675, 314, 1373, 687, 314, 17035, 334, 692, 3451, 9, 267, 3404, 275, 1921, 63, 2024, 503, 2519, 8, 1222, 63, 533, 12, 2513, 3352, 63, 2024, 297, 488, 9, 267, 3123, 15283, 63, 1345, 63, 955, 275, 334, 70, 367, 289, 315, 892, 63, 533, 423, 2024, 14, 955, 639, 340, 289, 14, 354, 315, 661, 4631, 297, 283, 1507, 1739, 297, 283, 515, 1333, 267, 367, 901, 315, 3123, 15283, 63, 1345, 63, 955, 26, 288, 901, 14, 10820, 275, 756, 267, 327, 663, 282, 892, 21972, 9216, 3396, 370, 7981, 1026, 11124, 402, 1174, 267, 892, 63, 533, 423, 3352, 63, 2024, 275, 21972, 9216, 3396, 8, 2024, 9, 267, 372, 892, 63, 533, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 29554, 5061, 8, 4174, 14, 1045, 63, 6577, 8, 5061, 1685, 1563, 12, 27365, 63, 1716, 2298, 272, 1449, 272, 710, 1300, 1021, 367, 282, 29554, 3589, 1402, 14, 3979, 12669, 282, 892, 3537, 3589, 12, 1265, 1077, 272, 3877, 3589, 13, 842, 2488, 2556, 641, 282, 5516, 402, 642, 1021, 14, 339, 1626, 2893, 367, 642, 3955, 506, 370, 3877, 314, 1329, 402, 6682, 22004, 370, 2929, 315, 282, 486, 1895, 651, 14, 339, 16853, 24488, 4838, 1380, 24572, 642, 370, 675, 315, 2195, 5705, 1709, 26, 272, 413, 14, 20196, 402, 29554, 5061, 627, 11250, 506, 9848, 1007, 28271, 10, 272, 499, 14, 20196, 402, 29554, 5061, 3913, 5627, 282, 298, 505, 2, 901, 14, 339, 1449, 272, 10069, 275, 1709, 14, 3190, 8, 20185, 12, 14783, 29, 797, 12, 2973, 29, 549, 9, 272, 1676, 275, 1709, 14, 3190, 360, 277, 297, 4596, 29, 549, 12, 2973, 29, 549, 12, 14783, 29, 797, 9, 272, 3421, 275, 1709, 14, 25197, 6115, 3124, 1288, 4596, 29, 549, 12, 2973, 29, 549, 12, 14783, 29, 797, 9, 272, 2637, 275, 1709, 14, 2183, 6115, 3671, 1288, 1390, 63, 1267, 29, 1046, 12, 4596, 29, 797, 12, 1592, 63, 1080, 29, 549, 12, 14783, 29, 797, 9, 272, 3589, 63, 466, 275, 1709, 14, 2183, 6115, 2718, 63, 354, 1288, 1390, 63, 1267, 29, 1400, 12, 1592, 63, 1080, 29, 549, 12, 14783, 29, 797, 9, 272, 7143, 63, 602, 275, 1709, 14, 4626, 6115, 8782, 1434, 1288, 14783, 29, 797, 12, 849, 29, 7145, 14, 2131, 9, 272, 2896, 63, 602, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 9, 272, 1982, 63, 2718, 63, 5990, 275, 488, 272, 1752, 25099, 63, 1317, 63, 12144, 63, 955, 275, 942, 339, 1021, 6288, 26, 267, 1145, 63, 1302, 275, 283, 10781, 7, 339, 1021, 17769, 3396, 26, 267, 1478, 275, 378, 267, 3141, 275, 413, 267, 1318, 63, 3827, 275, 756, 339, 347, 636, 5270, 721, 277, 304, 267, 408, 267, 22896, 24394, 2291, 14, 24573, 12, 642, 2951, 7634, 397, 370, 2018, 1159, 267, 4465, 7252, 14, 9738, 12, 367, 1709, 543, 12309, 901, 8697, 12, 781, 267, 1929, 370, 886, 7645, 10250, 12, 465, 2985, 3984, 18774, 2737, 3992, 436, 267, 1454, 859, 13, 1896, 3992, 883, 506, 18731, 701, 314, 849, 931, 14, 267, 408, 267, 666, 275, 291, 855, 807, 363, 267, 327, 710, 25259, 8377, 370, 886, 2348, 365, 370, 12677, 1613, 11027, 5270, 4533, 267, 327, 367, 314, 2222, 13, 12116, 1930, 14, 7529, 1133, 886, 626, 14, 267, 327, 4068, 2018, 499, 14, 20, 12, 2337, 365, 6020, 336, 4446, 68, 543, 636, 5270, 3108, 267, 327, 436, 465, 282, 754, 12, 314, 1613, 1240, 911, 7675, 376, 15258, 16189, 14, 267, 327, 1666, 327, 709 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 2197, 492, 1434, 199, 646, 2022, 199, 504, 4182, 492, 1242, 7416, 199, 646, 747, 199, 646, 3598, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 16522, 492, 32036, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 12, 24803, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 10166, 12, 5822, 199, 504, 1639, 14, 697, 14, 992, 14, 1095, 492, 1402, 63, 324, 8092, 12, 5822, 1563, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 17448, 1646, 199, 504, 1639, 14, 1208, 492, 3816, 12, 7137, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 2366, 63, 18, 63, 2975, 63, 6490, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 2457, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 19240, 14, 3924, 492, 577, 1888, 6119, 3276, 1646, 3849, 199, 504, 19240, 14, 992, 14, 6199, 1238, 492, 10902, 4302, 199, 504, 19240, 14, 2718, 63, 28228, 492, 11349, 2998, 12, 3795, 63, 2718, 199, 504, 19240, 14, 1208, 492, 664, 63, 10781, 63, 6031, 199, 504, 19240, 14, 1208, 14, 7546, 492, 295, 1023, 63, 2683, 199, 504, 19240, 14, 1208, 14, 633, 1208, 492, 4628, 63, 4471, 199, 199, 504, 3123, 15283, 14, 311, 63, 2350, 492, 27365, 63, 1716, 421, 199, 533, 21972, 9216, 3396, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3404, 304, 267, 291, 14, 1080, 275, 378, 267, 291, 14, 2923, 275, 413, 267, 291, 14, 505, 63, 3827, 275, 2519, 8, 2024, 12, 283, 505, 63, 3827, 297, 756, 9, 421, 199, 533, 11349, 1685, 1563, 8, 1685, 1563, 304, 272, 408, 272, 6288, 533, 367, 1006, 29554, 5061, 9180, 14, 961, 1021, 1077, 440, 506, 1202, 367, 272, 1263, 1163, 730, 402, 1709, 14, 272, 408, 339, 347, 636, 1222, 721, 1886, 12, 536, 12, 9768, 12, 3290, 304, 267, 327, 2813, 17769, 3396, 687, 314, 3589, 1021, 267, 1921, 63, 2024, 275, 3290, 14, 1935, 360, 9216, 3396, 297, 488, 9, 398, 327, 1218, 282, 892, 1021, 334, 4941, 314, 1613, 13, 6577, 9, 267, 892, 63, 533, 275, 1613, 8, 5061, 1685, 1563, 12, 843, 2843, 1222, 721, 1886, 12, 536, 12, 9768, 12, 3290, 9, 398, 327, 340, 2337, 365, 282, 17769, 3396, 315, 3290, 12, 675, 642, 1373, 267, 327, 587, 862, 370, 675, 314, 1373, 687, 314, 17035, 334, 692, 3451, 9, 267, 3404, 275, 1921, 63, 2024, 503, 2519, 8, 1222, 63, 533, 12, 2513, 3352, 63, 2024, 297, 488, 9, 267, 3123, 15283, 63, 1345, 63, 955, 275, 334, 70, 367, 289, 315, 892, 63, 533, 423, 2024, 14, 955, 639, 340, 289, 14, 354, 315, 661, 4631, 297, 283, 1507, 1739, 297, 283, 515, 1333, 267, 367, 901, 315, 3123, 15283, 63, 1345, 63, 955, 26, 288, 901, 14, 10820, 275, 756, 267, 327, 663, 282, 892, 21972, 9216, 3396, 370, 7981, 1026, 11124, 402, 1174, 267, 892, 63, 533, 423, 3352, 63, 2024, 275, 21972, 9216, 3396, 8, 2024, 9, 267, 372, 892, 63, 533, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 29554, 5061, 8, 4174, 14, 1045, 63, 6577, 8, 5061, 1685, 1563, 12, 27365, 63, 1716, 2298, 272, 1449, 272, 710, 1300, 1021, 367, 282, 29554, 3589, 1402, 14, 3979, 12669, 282, 892, 3537, 3589, 12, 1265, 1077, 272, 3877, 3589, 13, 842, 2488, 2556, 641, 282, 5516, 402, 642, 1021, 14, 339, 1626, 2893, 367, 642, 3955, 506, 370, 3877, 314, 1329, 402, 6682, 22004, 370, 2929, 315, 282, 486, 1895, 651, 14, 339, 16853, 24488, 4838, 1380, 24572, 642, 370, 675, 315, 2195, 5705, 1709, 26, 272, 413, 14, 20196, 402, 29554, 5061, 627, 11250, 506, 9848, 1007, 28271, 10, 272, 499, 14, 20196, 402, 29554, 5061, 3913, 5627, 282, 298, 505, 2, 901, 14, 339, 1449, 272, 10069, 275, 1709, 14, 3190, 8, 20185, 12, 14783, 29, 797, 12, 2973, 29, 549, 9, 272, 1676, 275, 1709, 14, 3190, 360, 277, 297, 4596, 29, 549, 12, 2973, 29, 549, 12, 14783, 29, 797, 9, 272, 3421, 275, 1709, 14, 25197, 6115, 3124, 1288, 4596, 29, 549, 12, 2973, 29, 549, 12, 14783, 29, 797, 9, 272, 2637, 275, 1709, 14, 2183, 6115, 3671, 1288, 1390, 63, 1267, 29, 1046, 12, 4596, 29, 797, 12, 1592, 63, 1080, 29, 549, 12, 14783, 29, 797, 9, 272, 3589, 63, 466, 275, 1709, 14, 2183, 6115, 2718, 63, 354, 1288, 1390, 63, 1267, 29, 1400, 12, 1592, 63, 1080, 29, 549, 12, 14783, 29, 797, 9, 272, 7143, 63, 602, 275, 1709, 14, 4626, 6115, 8782, 1434, 1288, 14783, 29, 797, 12, 849, 29, 7145, 14, 2131, 9, 272, 2896, 63, 602, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 9, 272, 1982, 63, 2718, 63, 5990, 275, 488, 272, 1752, 25099, 63, 1317, 63, 12144, 63, 955, 275, 942, 339, 1021, 6288, 26, 267, 1145, 63, 1302, 275, 283, 10781, 7, 339, 1021, 17769, 3396, 26, 267, 1478, 275, 378, 267, 3141, 275, 413, 267, 1318, 63, 3827, 275, 756, 339, 347, 636, 5270, 721, 277, 304, 267, 408, 267, 22896, 24394, 2291, 14, 24573, 12, 642, 2951, 7634, 397, 370, 2018, 1159, 267, 4465, 7252, 14, 9738, 12, 367, 1709, 543, 12309, 901, 8697, 12, 781, 267, 1929, 370, 886, 7645, 10250, 12, 465, 2985, 3984, 18774, 2737, 3992, 436, 267, 1454, 859, 13, 1896, 3992, 883, 506, 18731, 701, 314, 849, 931, 14, 267, 408, 267, 666, 275, 291, 855, 807, 363, 267, 327, 710, 25259, 8377, 370, 886, 2348, 365, 370, 12677, 1613, 11027, 5270, 4533, 267, 327, 367, 314, 2222, 13, 12116, 1930, 14, 7529, 1133, 886, 626, 14, 267, 327, 4068, 2018, 499, 14, 20, 12, 2337, 365, 6020, 336, 4446, 68, 543, 636, 5270, 3108, 267, 327, 436, 465, 282, 754, 12, 314, 1613, 1240, 911, 7675, 376, 15258, 16189, 14, 267, 327, 1666, 327, 709, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
nuuuboo/odoo
openerp/addons/base/tests/test_qweb.py
289
4814
# -*- coding: utf-8 -*- import cgi import json import os.path import glob import re import collections from lxml import etree import openerp.addons.base.ir.ir_qweb import openerp.modules from openerp.tests import common from openerp.addons.base.ir import ir_qweb class TestQWebTField(common.TransactionCase): def setUp(self): super(TestQWebTField, self).setUp() self.engine = self.registry('ir.qweb') def context(self, values): return ir_qweb.QWebContext( self.cr, self.uid, values, context={'inherit_branding': True}) def test_trivial(self): field = etree.Element('span', {'t-field': u'company.name'}) Companies = self.registry('res.company') company_id = Companies.create(self.cr, self.uid, { 'name': "My Test Company" }) result = self.engine.render_node(field, self.context({ 'company': Companies.browse(self.cr, self.uid, company_id), })) self.assertEqual( result, '<span data-oe-model="res.company" data-oe-id="%d" ' 'data-oe-field="name" data-oe-type="char" ' 'data-oe-expression="company.name">%s</span>' % ( company_id, "My Test Company",)) def test_i18n(self): field = etree.Element('span', {'t-field': u'company.name'}) Companies = self.registry('res.company') s = u"Testing «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!" company_id = Companies.create(self.cr, self.uid, { 'name': s, }) result = self.engine.render_node(field, self.context({ 'company': Companies.browse(self.cr, self.uid, company_id), })) self.assertEqual( result, '<span data-oe-model="res.company" data-oe-id="%d" ' 'data-oe-field="name" data-oe-type="char" ' 'data-oe-expression="company.name">%s</span>' % ( company_id, cgi.escape(s.encode('utf-8')),)) def test_reject_crummy_tags(self): field = etree.Element('td', {'t-field': u'company.name'}) with self.assertRaisesRegexp( AssertionError, r'^RTE widgets do not work correctly'): self.engine.render_node(field, self.context({ 'company': None })) def test_reject_t_tag(self): field = etree.Element('t', {'t-field': u'company.name'}) with self.assertRaisesRegexp( AssertionError, r'^t-field can not be used on a t element'): self.engine.render_node(field, self.context({ 'company': None })) class TestQWeb(common.TransactionCase): matcher = re.compile('^qweb-test-(.*)\.xml$') @classmethod def get_cases(cls): path = cls.qweb_test_file_path() return ( cls("test_qweb_{}".format(cls.matcher.match(f).group(1))) for f in os.listdir(path) # js inheritance if f != 'qweb-test-extend.xml' if cls.matcher.match(f) ) @classmethod def qweb_test_file_path(cls): path = os.path.dirname( openerp.modules.get_module_resource( 'web', 'static', 'lib', 'qweb', 'qweb2.js')) return path def __getattr__(self, item): if not item.startswith('test_qweb_'): raise AttributeError("No {} on {}".format(item, self)) f = 'qweb-test-{}.xml'.format(item[10:]) path = self.qweb_test_file_path() return lambda: self.run_test_file(os.path.join(path, f)) def run_test_file(self, path): context = openerp.addons.base.ir.ir_qweb.QWebContext(self.cr, self.uid, {}) qweb = self.env['ir.qweb'] doc = etree.parse(path).getroot() qweb.load_document(doc, None, context) for template in context.templates: if template.startswith('_'): continue param = doc.find('params[@id="{}"]'.format(template)) # OrderedDict to ensure JSON mappings are iterated in source order # so output is predictable & repeatable params = {} if param is None else json.loads(param.text, object_pairs_hook=collections.OrderedDict) ctx = context.copy() ctx.update(params) result = doc.find('result[@id="{}"]'.format(template)).text self.assertEqual( qweb.render(template, qwebcontext=ctx).strip(), (result or u'').strip().encode('utf-8'), template ) def load_tests(loader, suite, _): # can't override TestQWeb.__dir__ because dir() called on *class* not # instance suite.addTests(TestQWeb.get_cases()) return suite
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 16004, 199, 646, 2022, 199, 646, 747, 14, 515, 199, 646, 5739, 199, 646, 295, 199, 646, 5055, 199, 199, 504, 14490, 492, 7559, 199, 646, 5166, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 22600, 199, 646, 5166, 14, 3112, 199, 199, 504, 5166, 14, 2219, 492, 2863, 199, 504, 5166, 14, 10788, 14, 1095, 14, 723, 492, 8190, 63, 22600, 199, 199, 533, 1379, 49, 5926, 52, 792, 8, 2330, 14, 10161, 1538, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 49, 5926, 52, 792, 12, 291, 680, 5996, 342, 267, 291, 14, 3908, 275, 291, 14, 5189, 360, 723, 14, 22600, 358, 339, 347, 1067, 8, 277, 12, 1338, 304, 267, 372, 8190, 63, 22600, 14, 49, 5926, 2998, 8, 288, 291, 14, 1556, 12, 291, 14, 1535, 12, 1338, 12, 1067, 3713, 6486, 63, 19026, 316, 356, 715, 1552, 339, 347, 511, 63, 23844, 8, 277, 304, 267, 901, 275, 7559, 14, 2162, 360, 3751, 297, 791, 84, 13, 698, 356, 399, 7, 4627, 14, 354, 3071, 398, 3599, 23461, 275, 291, 14, 5189, 360, 470, 14, 4627, 358, 267, 7233, 63, 344, 275, 3599, 23461, 14, 981, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 469, 288, 283, 354, 356, 298, 5713, 1379, 15878, 2, 267, 3828, 267, 754, 275, 291, 14, 3908, 14, 3352, 63, 932, 8, 698, 12, 291, 14, 1100, 2561, 288, 283, 4627, 356, 3599, 23461, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 7233, 63, 344, 395, 267, 23451, 398, 291, 14, 629, 8, 288, 754, 12, 288, 2650, 3751, 666, 13, 13361, 13, 1238, 628, 470, 14, 4627, 2, 666, 13, 13361, 13, 344, 5961, 68, 2, 283, 2116, 283, 576, 13, 13361, 13, 698, 628, 354, 2, 666, 13, 13361, 13, 466, 628, 1560, 2, 283, 2116, 283, 576, 13, 13361, 13, 5599, 628, 4627, 14, 354, 14423, 83, 1108, 3751, 3524, 450, 334, 355, 7233, 63, 344, 12, 355, 298, 5713, 1379, 15878, 401, 430, 339, 347, 511, 63, 73, 1085, 78, 8, 277, 304, 267, 901, 275, 7559, 14, 2162, 360, 3751, 297, 791, 84, 13, 698, 356, 399, 7, 4627, 14, 354, 3071, 398, 3599, 23461, 275, 291, 14, 5189, 360, 470, 14, 4627, 358, 267, 308, 275, 399, 2, 9029, 22405, 105, 17123, 13500, 141, 240, 141, 106, 159, 227, 242, 20136, 127, 120, 26, 413, 28, 18, 1253, 841, 11, 17, 30, 19, 12, 3063, 3388, 5, 2331, 9539, 267, 7233, 63, 344, 275, 3599, 23461, 14, 981, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 469, 288, 283, 354, 356, 308, 12, 267, 3828, 267, 754, 275, 291, 14, 3908, 14, 3352, 63, 932, 8, 698, 12, 291, 14, 1100, 2561, 288, 283, 4627, 356, 3599, 23461, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 7233, 63, 344, 395, 267, 23451, 398, 291, 14, 629, 8, 288, 754, 12, 288, 2650, 3751, 666, 13, 13361, 13, 1238, 628, 470, 14, 4627, 2, 666, 13, 13361, 13, 344, 5961, 68, 2, 283, 2116, 283, 576, 13, 13361, 13, 698, 628, 354, 2, 666, 13, 13361, 13, 466, 628, 1560, 2, 283, 2116, 283, 576, 13, 13361, 13, 5599, 628, 4627, 14, 354, 14423, 83, 1108, 3751, 3524, 450, 334, 355, 7233, 63, 344, 12, 355, 16004, 14, 3765, 8, 83, 14, 2143, 360, 1624, 13, 24, 3855, 430, 339, 347, 511, 63, 16857, 63, 1556, 3323, 63, 2969, 8, 277, 304, 267, 901, 275, 7559, 14, 2162, 360, 2076, 297, 791, 84, 13, 698, 356, 399, 7, 4627, 14, 354, 3071, 398, 543, 291, 14, 10835, 8, 355, 9070, 12, 355, 519, 4289, 50, 3727, 11114, 886, 440, 1736, 6657, 735, 288, 291, 14, 3908, 14, 3352, 63, 932, 8, 698, 12, 291, 14, 1100, 2561, 355, 283, 4627, 356, 488, 288, 23451, 339, 347, 511, 63, 16857, 63, 84, 63, 1450, 8, 277, 304, 267, 901, 275, 7559, 14, 2162, 360, 84, 297, 791, 84, 13, 698, 356, 399, 7, 4627, 14, 354, 3071, 398, 543, 291, 14, 10835, 8, 355, 9070, 12, 355, 519, 4289, 84, 13, 698, 883, 440, 506, 1202, 641, 282, 307, 1819, 735, 288, 291, 14, 3908, 14, 3352, 63, 932, 8, 698, 12, 291, 14, 1100, 2561, 355, 283, 4627, 356, 488, 288, 23451, 199, 199, 533, 1379, 49, 5926, 8, 2330, 14, 10161, 1538, 304, 272, 15990, 275, 295, 14, 2014, 9097, 22600, 13, 396, 15426, 2795, 31477, 1652, 9988, 339, 768, 3744, 272, 347, 664, 63, 9403, 8, 1886, 304, 267, 931, 275, 843, 14, 22600, 63, 396, 63, 493, 63, 515, 342, 398, 372, 334, 288, 843, 480, 396, 63, 22600, 63, 13536, 908, 8, 1886, 14, 16135, 14, 1431, 8, 70, 680, 923, 8, 17, 1724, 288, 367, 289, 315, 747, 14, 7374, 8, 515, 9, 288, 327, 8586, 15433, 288, 340, 289, 1137, 283, 22600, 13, 396, 13, 2880, 14, 1652, 7, 288, 340, 843, 14, 16135, 14, 1431, 8, 70, 9, 267, 776, 272, 768, 3744, 272, 347, 31094, 63, 396, 63, 493, 63, 515, 8, 1886, 304, 267, 931, 275, 747, 14, 515, 14, 3475, 8, 288, 5166, 14, 3112, 14, 362, 63, 578, 63, 1927, 8, 355, 283, 2520, 297, 283, 1986, 297, 283, 773, 297, 283, 22600, 297, 283, 22600, 18, 14, 3596, 1333, 267, 372, 931, 339, 347, 636, 5675, 721, 277, 12, 1242, 304, 267, 340, 440, 1242, 14, 2460, 360, 396, 63, 22600, 25865, 288, 746, 4281, 480, 1944, 1052, 641, 8352, 908, 8, 1053, 12, 291, 430, 398, 289, 275, 283, 22600, 13, 396, 13, 31270, 1652, 1370, 908, 8, 1053, 59, 709, 5728, 267, 931, 275, 291, 14, 22600, 63, 396, 63, 493, 63, 515, 342, 398, 372, 2400, 26, 291, 14, 1065, 63, 396, 63, 493, 8, 736, 14, 515, 14, 904, 8, 515, 12, 289, 430, 339, 347, 1255, 63, 396, 63, 493, 8, 277, 12, 931, 304, 267, 1067, 275, 5166, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 22600, 14, 49, 5926, 2998, 8, 277, 14, 1556, 12, 291 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 16004, 199, 646, 2022, 199, 646, 747, 14, 515, 199, 646, 5739, 199, 646, 295, 199, 646, 5055, 199, 199, 504, 14490, 492, 7559, 199, 646, 5166, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 22600, 199, 646, 5166, 14, 3112, 199, 199, 504, 5166, 14, 2219, 492, 2863, 199, 504, 5166, 14, 10788, 14, 1095, 14, 723, 492, 8190, 63, 22600, 199, 199, 533, 1379, 49, 5926, 52, 792, 8, 2330, 14, 10161, 1538, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 49, 5926, 52, 792, 12, 291, 680, 5996, 342, 267, 291, 14, 3908, 275, 291, 14, 5189, 360, 723, 14, 22600, 358, 339, 347, 1067, 8, 277, 12, 1338, 304, 267, 372, 8190, 63, 22600, 14, 49, 5926, 2998, 8, 288, 291, 14, 1556, 12, 291, 14, 1535, 12, 1338, 12, 1067, 3713, 6486, 63, 19026, 316, 356, 715, 1552, 339, 347, 511, 63, 23844, 8, 277, 304, 267, 901, 275, 7559, 14, 2162, 360, 3751, 297, 791, 84, 13, 698, 356, 399, 7, 4627, 14, 354, 3071, 398, 3599, 23461, 275, 291, 14, 5189, 360, 470, 14, 4627, 358, 267, 7233, 63, 344, 275, 3599, 23461, 14, 981, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 469, 288, 283, 354, 356, 298, 5713, 1379, 15878, 2, 267, 3828, 267, 754, 275, 291, 14, 3908, 14, 3352, 63, 932, 8, 698, 12, 291, 14, 1100, 2561, 288, 283, 4627, 356, 3599, 23461, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 7233, 63, 344, 395, 267, 23451, 398, 291, 14, 629, 8, 288, 754, 12, 288, 2650, 3751, 666, 13, 13361, 13, 1238, 628, 470, 14, 4627, 2, 666, 13, 13361, 13, 344, 5961, 68, 2, 283, 2116, 283, 576, 13, 13361, 13, 698, 628, 354, 2, 666, 13, 13361, 13, 466, 628, 1560, 2, 283, 2116, 283, 576, 13, 13361, 13, 5599, 628, 4627, 14, 354, 14423, 83, 1108, 3751, 3524, 450, 334, 355, 7233, 63, 344, 12, 355, 298, 5713, 1379, 15878, 401, 430, 339, 347, 511, 63, 73, 1085, 78, 8, 277, 304, 267, 901, 275, 7559, 14, 2162, 360, 3751, 297, 791, 84, 13, 698, 356, 399, 7, 4627, 14, 354, 3071, 398, 3599, 23461, 275, 291, 14, 5189, 360, 470, 14, 4627, 358, 267, 308, 275, 399, 2, 9029, 22405, 105, 17123, 13500, 141, 240, 141, 106, 159, 227, 242, 20136, 127, 120, 26, 413, 28, 18, 1253, 841, 11, 17, 30, 19, 12, 3063, 3388, 5, 2331, 9539, 267, 7233, 63, 344, 275, 3599, 23461, 14, 981, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 469, 288, 283, 354, 356, 308, 12, 267, 3828, 267, 754, 275, 291, 14, 3908, 14, 3352, 63, 932, 8, 698, 12, 291, 14, 1100, 2561, 288, 283, 4627, 356, 3599, 23461, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 7233, 63, 344, 395, 267, 23451, 398, 291, 14, 629, 8, 288, 754, 12, 288, 2650, 3751, 666, 13, 13361, 13, 1238, 628, 470, 14, 4627, 2, 666, 13, 13361, 13, 344, 5961, 68, 2, 283, 2116, 283, 576, 13, 13361, 13, 698, 628, 354, 2, 666, 13, 13361, 13, 466, 628, 1560, 2, 283, 2116, 283, 576, 13, 13361, 13, 5599, 628, 4627, 14, 354, 14423, 83, 1108, 3751, 3524, 450, 334, 355, 7233, 63, 344, 12, 355, 16004, 14, 3765, 8, 83, 14, 2143, 360, 1624, 13, 24, 3855, 430, 339, 347, 511, 63, 16857, 63, 1556, 3323, 63, 2969, 8, 277, 304, 267, 901, 275, 7559, 14, 2162, 360, 2076, 297, 791, 84, 13, 698, 356, 399, 7, 4627, 14, 354, 3071, 398, 543, 291, 14, 10835, 8, 355, 9070, 12, 355, 519, 4289, 50, 3727, 11114, 886, 440, 1736, 6657, 735, 288, 291, 14, 3908, 14, 3352, 63, 932, 8, 698, 12, 291, 14, 1100, 2561, 355, 283, 4627, 356, 488, 288, 23451, 339, 347, 511, 63, 16857, 63, 84, 63, 1450, 8, 277, 304, 267, 901, 275, 7559, 14, 2162, 360, 84, 297, 791, 84, 13, 698, 356, 399, 7, 4627, 14, 354, 3071, 398, 543, 291, 14, 10835, 8, 355, 9070, 12, 355, 519, 4289, 84, 13, 698, 883, 440, 506, 1202, 641, 282, 307, 1819, 735, 288, 291, 14, 3908, 14, 3352, 63, 932, 8, 698, 12, 291, 14, 1100, 2561, 355, 283, 4627, 356, 488, 288, 23451, 199, 199, 533, 1379, 49, 5926, 8, 2330, 14, 10161, 1538, 304, 272, 15990, 275, 295, 14, 2014, 9097, 22600, 13, 396, 15426, 2795, 31477, 1652, 9988, 339, 768, 3744, 272, 347, 664, 63, 9403, 8, 1886, 304, 267, 931, 275, 843, 14, 22600, 63, 396, 63, 493, 63, 515, 342, 398, 372, 334, 288, 843, 480, 396, 63, 22600, 63, 13536, 908, 8, 1886, 14, 16135, 14, 1431, 8, 70, 680, 923, 8, 17, 1724, 288, 367, 289, 315, 747, 14, 7374, 8, 515, 9, 288, 327, 8586, 15433, 288, 340, 289, 1137, 283, 22600, 13, 396, 13, 2880, 14, 1652, 7, 288, 340, 843, 14, 16135, 14, 1431, 8, 70, 9, 267, 776, 272, 768, 3744, 272, 347, 31094, 63, 396, 63, 493, 63, 515, 8, 1886, 304, 267, 931, 275, 747, 14, 515, 14, 3475, 8, 288, 5166, 14, 3112, 14, 362, 63, 578, 63, 1927, 8, 355, 283, 2520, 297, 283, 1986, 297, 283, 773, 297, 283, 22600, 297, 283, 22600, 18, 14, 3596, 1333, 267, 372, 931, 339, 347, 636, 5675, 721, 277, 12, 1242, 304, 267, 340, 440, 1242, 14, 2460, 360, 396, 63, 22600, 25865, 288, 746, 4281, 480, 1944, 1052, 641, 8352, 908, 8, 1053, 12, 291, 430, 398, 289, 275, 283, 22600, 13, 396, 13, 31270, 1652, 1370, 908, 8, 1053, 59, 709, 5728, 267, 931, 275, 291, 14, 22600, 63, 396, 63, 493, 63, 515, 342, 398, 372, 2400, 26, 291, 14, 1065, 63, 396, 63, 493, 8, 736, 14, 515, 14, 904, 8, 515, 12, 289, 430, 339, 347, 1255, 63, 396, 63, 493, 8, 277, 12, 931, 304, 267, 1067, 275, 5166, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 22600, 14, 49, 5926, 2998, 8, 277, 14, 1556, 12, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
krbaker/Diamond
src/diamond/handler/rabbitmq_pubsub.py
21
6661
# coding=utf-8 """ Output the collected values to RabitMQ pub/sub channel """ from Handler import Handler import time try: import pika except ImportError: pika = None class rmqHandler (Handler): """ Implements the abstract Handler class Sending data to a RabbitMQ pub/sub channel """ def __init__(self, config=None): """ Create a new instance of rmqHandler class """ # Initialize Handler Handler.__init__(self, config) if pika is None: self.log.error('pika import failed. Handler disabled') self.enabled = False return # Initialize Data self.connections = {} self.channels = {} self.reconnect_interval = 1 # Initialize Options tmp_rmq_server = self.config['rmq_server'] if type(tmp_rmq_server) is list: self.rmq_server = tmp_rmq_server else: self.rmq_server = [tmp_rmq_server] self.rmq_port = 5672 self.rmq_exchange = self.config['rmq_exchange'] self.rmq_user = None self.rmq_password = None self.rmq_vhost = '/' self.rmq_exchange_type = 'fanout' self.rmq_durable = True self.rmq_heartbeat_interval = 300 self.get_config() # Create rabbitMQ pub socket and bind try: self._bind_all() except pika.exceptions.AMQPConnectionError: self.log.error('Failed to bind to rabbitMQ pub socket') def get_config(self): """ Get and set config options from config file """ if 'rmq_port' in self.config: self.rmq_port = int(self.config['rmq_port']) if 'rmq_user' in self.config: self.rmq_user = self.config['rmq_user'] if 'rmq_password' in self.config: self.rmq_password = self.config['rmq_password'] if 'rmq_vhost' in self.config: self.rmq_vhost = self.config['rmq_vhost'] if 'rmq_exchange_type' in self.config: self.rmq_exchange_type = self.config['rmq_exchange_type'] if 'rmq_durable' in self.config: self.rmq_durable = bool(self.config['rmq_durable']) if 'rmq_heartbeat_interval' in self.config: self.rmq_heartbeat_interval = int( self.config['rmq_heartbeat_interval']) def get_default_config_help(self): """ Returns the help text for the configuration options for this handler """ config = super(rmqHandler, self).get_default_config_help() config.update({ 'server': '', 'rmq_exchange': '', }) return config def get_default_config(self): """ Return the default config for the handler """ config = super(rmqHandler, self).get_default_config() config.update({ 'server': '127.0.0.1', 'rmq_exchange': 'diamond', }) return config def _bind_all(self): """ Bind all RMQ servers defined in config """ for rmq_server in self.rmq_server: self._bind(rmq_server) def _bind(self, rmq_server): """ Create PUB socket and bind """ if (rmq_server in self.connections.keys() and self.connections[rmq_server] is not None and self.connections[rmq_server].is_open): # It seems we already have this server, so let's try _unbind just # to be safe. self._unbind(rmq_server) credentials = None if self.rmq_user and self.rmq_password: credentials = pika.PlainCredentials( self.rmq_user, self.rmq_password) parameters = pika.ConnectionParameters( host=rmq_server, port=self.rmq_port, virtual_host=self.rmq_vhost, credentials=credentials, heartbeat_interval=self.rmq_heartbeat_interval, retry_delay=5, connection_attempts=3) self.connections[rmq_server] = None while (self.connections[rmq_server] is None or self.connections[rmq_server].is_open is False): try: self.connections[rmq_server] = pika.BlockingConnection( parameters) self.channels[rmq_server] = self.connections[ rmq_server].channel() self.channels[rmq_server].exchange_declare( exchange=self.rmq_exchange, type=self.rmq_exchange_type, durable=self.rmq_durable) # Reset reconnect_interval after a successful connection self.reconnect_interval = 1 except Exception, exception: self.log.debug("Caught exception in _bind: %s", exception) if rmq_server in self.connections.keys(): self._unbind(rmq_server) if self.reconnect_interval >= 16: break if self.reconnect_interval < 16: self.reconnect_interval = self.reconnect_interval * 2 time.sleep(self.reconnect_interval) def _unbind(self, rmq_server=None): """ Close AMQP connection and unset channel """ try: self.connections[rmq_server].close() except AttributeError: pass self.connections[rmq_server] = None self.channels[rmq_server] = None def __del__(self): """ Destroy instance of the rmqHandler class """ if hasattr(self, 'connections'): for rmq_server in self.connections.keys(): self._unbind(rmq_server) def process(self, metric): """ Process a metric and send it to RMQ pub socket """ for rmq_server in self.connections.keys(): try: if (self.connections[rmq_server] is None or self.connections[rmq_server].is_open is False): self._bind(rmq_server) channel = self.channels[rmq_server] channel.basic_publish(exchange=self.rmq_exchange, routing_key='', body="%s" % metric) except Exception, exception: self.log.error( "Failed publishing to %s, attempting reconnect", rmq_server) self.log.debug("Caught exception: %s", exception) self._unbind(rmq_server) self._bind(rmq_server)
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 199, 624, 199, 2959, 314, 13736, 1338, 370, 820, 30299, 14449, 7974, 15, 954, 3623, 199, 624, 199, 199, 504, 18599, 492, 18599, 199, 646, 900, 199, 199, 893, 26, 272, 492, 299, 26966, 199, 2590, 3545, 26, 272, 299, 26966, 275, 488, 421, 199, 533, 519, 8334, 2461, 334, 2461, 304, 272, 408, 489, 24664, 314, 9006, 18599, 1021, 489, 428, 3219, 666, 370, 282, 820, 371, 2075, 14449, 7974, 15, 954, 3623, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1101, 29, 403, 304, 267, 408, 881, 2790, 282, 892, 1256, 402, 519, 8334, 2461, 1021, 267, 408, 398, 327, 11578, 18599, 267, 18599, 855, 826, 721, 277, 12, 1101, 9, 398, 340, 299, 26966, 365, 488, 26, 288, 291, 14, 793, 14, 705, 360, 1038, 7351, 492, 3405, 14, 18599, 6980, 358, 288, 291, 14, 3827, 275, 756, 288, 372, 398, 327, 11578, 3918, 267, 291, 14, 7995, 275, 1052, 267, 291, 14, 6324, 275, 1052, 267, 291, 14, 29464, 63, 4284, 275, 413, 398, 327, 11578, 8394, 267, 3529, 63, 5682, 81, 63, 1000, 275, 291, 14, 888, 459, 5682, 81, 63, 1000, 418, 267, 340, 730, 8, 2791, 63, 5682, 81, 63, 1000, 9, 365, 769, 26, 288, 291, 14, 5682, 81, 63, 1000, 275, 3529, 63, 5682, 81, 63, 1000, 267, 587, 26, 288, 291, 14, 5682, 81, 63, 1000, 275, 359, 2791, 63, 5682, 81, 63, 1000, 61, 398, 291, 14, 5682, 81, 63, 719, 275, 959, 20298, 267, 291, 14, 5682, 81, 63, 14197, 275, 291, 14, 888, 459, 5682, 81, 63, 14197, 418, 267, 291, 14, 5682, 81, 63, 751, 275, 488, 267, 291, 14, 5682, 81, 63, 2060, 275, 488, 267, 291, 14, 5682, 81, 63, 32071, 275, 7324, 267, 291, 14, 5682, 81, 63, 14197, 63, 466, 275, 283, 12269, 548, 7, 267, 291, 14, 5682, 81, 63, 68, 15684, 275, 715, 267, 291, 14, 5682, 81, 63, 22685, 63, 4284, 275, 9601, 398, 291, 14, 362, 63, 888, 342, 267, 327, 2790, 29773, 2075, 14449, 7974, 2838, 436, 5398, 267, 862, 26, 288, 291, 423, 3409, 63, 452, 342, 267, 871, 299, 26966, 14, 3924, 14, 1156, 31208, 20349, 26, 288, 291, 14, 793, 14, 705, 360, 4276, 370, 5398, 370, 29773, 2075, 14449, 7974, 2838, 358, 339, 347, 664, 63, 888, 8, 277, 304, 267, 408, 2372, 436, 663, 1101, 1511, 687, 1101, 570, 408, 267, 340, 283, 5682, 81, 63, 719, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 719, 275, 1109, 8, 277, 14, 888, 459, 5682, 81, 63, 719, 1105, 398, 340, 283, 5682, 81, 63, 751, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 751, 275, 291, 14, 888, 459, 5682, 81, 63, 751, 418, 398, 340, 283, 5682, 81, 63, 2060, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 2060, 275, 291, 14, 888, 459, 5682, 81, 63, 2060, 418, 398, 340, 283, 5682, 81, 63, 32071, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 32071, 275, 291, 14, 888, 459, 5682, 81, 63, 32071, 418, 398, 340, 283, 5682, 81, 63, 14197, 63, 466, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 14197, 63, 466, 275, 291, 14, 888, 459, 5682, 81, 63, 14197, 63, 466, 418, 398, 340, 283, 5682, 81, 63, 68, 15684, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 68, 15684, 275, 2155, 8, 277, 14, 888, 459, 5682, 81, 63, 68, 15684, 1105, 398, 340, 283, 5682, 81, 63, 22685, 63, 4284, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 22685, 63, 4284, 275, 1109, 8, 355, 291, 14, 888, 459, 5682, 81, 63, 22685, 63, 4284, 1105, 339, 347, 664, 63, 885, 63, 888, 63, 3437, 8, 277, 304, 267, 408, 267, 1803, 314, 1720, 1318, 367, 314, 2897, 1511, 367, 642, 3016, 267, 408, 267, 1101, 275, 1613, 8, 5682, 81, 2461, 12, 291, 680, 362, 63, 885, 63, 888, 63, 3437, 342, 398, 1101, 14, 873, 2561, 288, 283, 1000, 356, 3260, 288, 283, 5682, 81, 63, 14197, 356, 3260, 267, 3828, 267, 372, 1101, 339, 347, 664, 63, 885, 63, 888, 8, 277, 304, 267, 408, 267, 1432, 314, 849, 1101, 367, 314, 3016, 267, 408, 267, 1101, 275, 1613, 8, 5682, 81, 2461, 12, 291, 680, 362, 63, 885, 63, 888, 342, 398, 1101, 14, 873, 2561, 288, 283, 1000, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 288, 283, 5682, 81, 63, 14197, 356, 283, 328, 24940, 297, 267, 3828, 398, 372, 1101, 339, 347, 485, 3409, 63, 452, 8, 277, 304, 267, 408, 267, 22630, 1006, 820, 14449, 8037, 3247, 315, 1101, 267, 408, 267, 367, 519, 8334, 63, 1000, 315, 291, 14, 5682, 81, 63, 1000, 26, 288, 291, 423, 3409, 8, 5682, 81, 63, 1000, 9, 339, 347, 485, 3409, 8, 277, 12, 519, 8334, 63, 1000, 304, 267, 408, 1779, 2790, 18787, 2838, 436, 5398, 267, 408, 267, 340, 334, 5682, 81, 63, 1000, 315, 291, 14, 7995, 14, 1612, 342, 355, 436, 291, 14, 7995, 59, 5682, 81, 63, 1000, 61, 365, 440, 488, 355, 436, 291, 14, 7995, 59, 5682, 81, 63, 1000, 1055, 374, 63, 1490, 304, 288, 327, 2779, 12237, 781, 2575, 1172, 642, 1654, 12, 880, 4691, 1159, 862, 485, 324, 3409, 2951, 288, 327, 370, 506, 5048, 14, 288, 291, 423, 324, 3409, 8, 5682, 81, 63, 1000, 9, 398, 6235, 275, 488, 267, 340, 291, 14, 5682, 81, 63, 751, 436, 291, 14, 5682, 81, 63, 2060, 26, 288, 6235, 275, 299, 26966, 14, 20711, 13428, 8, 355, 291, 14, 5682, 81, 63, 751, 12, 355, 291, 14, 5682, 81, 63, 2060, 9, 398, 2633, 275, 299, 26966, 14, 3225, 5976, 8, 288, 1591, 29, 5682, 81, 63, 1000, 12, 288, 1844, 29, 277, 14, 5682, 81, 63, 719, 12, 288, 5791, 63, 1102, 29, 277, 14, 5682, 81, 63, 32071, 12, 288, 6235, 29, 6942, 12, 288, 32015, 63, 4284, 29, 277, 14, 5682 ]
[ 2803, 29, 1624, 13, 24, 199, 199, 624, 199, 2959, 314, 13736, 1338, 370, 820, 30299, 14449, 7974, 15, 954, 3623, 199, 624, 199, 199, 504, 18599, 492, 18599, 199, 646, 900, 199, 199, 893, 26, 272, 492, 299, 26966, 199, 2590, 3545, 26, 272, 299, 26966, 275, 488, 421, 199, 533, 519, 8334, 2461, 334, 2461, 304, 272, 408, 489, 24664, 314, 9006, 18599, 1021, 489, 428, 3219, 666, 370, 282, 820, 371, 2075, 14449, 7974, 15, 954, 3623, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1101, 29, 403, 304, 267, 408, 881, 2790, 282, 892, 1256, 402, 519, 8334, 2461, 1021, 267, 408, 398, 327, 11578, 18599, 267, 18599, 855, 826, 721, 277, 12, 1101, 9, 398, 340, 299, 26966, 365, 488, 26, 288, 291, 14, 793, 14, 705, 360, 1038, 7351, 492, 3405, 14, 18599, 6980, 358, 288, 291, 14, 3827, 275, 756, 288, 372, 398, 327, 11578, 3918, 267, 291, 14, 7995, 275, 1052, 267, 291, 14, 6324, 275, 1052, 267, 291, 14, 29464, 63, 4284, 275, 413, 398, 327, 11578, 8394, 267, 3529, 63, 5682, 81, 63, 1000, 275, 291, 14, 888, 459, 5682, 81, 63, 1000, 418, 267, 340, 730, 8, 2791, 63, 5682, 81, 63, 1000, 9, 365, 769, 26, 288, 291, 14, 5682, 81, 63, 1000, 275, 3529, 63, 5682, 81, 63, 1000, 267, 587, 26, 288, 291, 14, 5682, 81, 63, 1000, 275, 359, 2791, 63, 5682, 81, 63, 1000, 61, 398, 291, 14, 5682, 81, 63, 719, 275, 959, 20298, 267, 291, 14, 5682, 81, 63, 14197, 275, 291, 14, 888, 459, 5682, 81, 63, 14197, 418, 267, 291, 14, 5682, 81, 63, 751, 275, 488, 267, 291, 14, 5682, 81, 63, 2060, 275, 488, 267, 291, 14, 5682, 81, 63, 32071, 275, 7324, 267, 291, 14, 5682, 81, 63, 14197, 63, 466, 275, 283, 12269, 548, 7, 267, 291, 14, 5682, 81, 63, 68, 15684, 275, 715, 267, 291, 14, 5682, 81, 63, 22685, 63, 4284, 275, 9601, 398, 291, 14, 362, 63, 888, 342, 267, 327, 2790, 29773, 2075, 14449, 7974, 2838, 436, 5398, 267, 862, 26, 288, 291, 423, 3409, 63, 452, 342, 267, 871, 299, 26966, 14, 3924, 14, 1156, 31208, 20349, 26, 288, 291, 14, 793, 14, 705, 360, 4276, 370, 5398, 370, 29773, 2075, 14449, 7974, 2838, 358, 339, 347, 664, 63, 888, 8, 277, 304, 267, 408, 2372, 436, 663, 1101, 1511, 687, 1101, 570, 408, 267, 340, 283, 5682, 81, 63, 719, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 719, 275, 1109, 8, 277, 14, 888, 459, 5682, 81, 63, 719, 1105, 398, 340, 283, 5682, 81, 63, 751, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 751, 275, 291, 14, 888, 459, 5682, 81, 63, 751, 418, 398, 340, 283, 5682, 81, 63, 2060, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 2060, 275, 291, 14, 888, 459, 5682, 81, 63, 2060, 418, 398, 340, 283, 5682, 81, 63, 32071, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 32071, 275, 291, 14, 888, 459, 5682, 81, 63, 32071, 418, 398, 340, 283, 5682, 81, 63, 14197, 63, 466, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 14197, 63, 466, 275, 291, 14, 888, 459, 5682, 81, 63, 14197, 63, 466, 418, 398, 340, 283, 5682, 81, 63, 68, 15684, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 68, 15684, 275, 2155, 8, 277, 14, 888, 459, 5682, 81, 63, 68, 15684, 1105, 398, 340, 283, 5682, 81, 63, 22685, 63, 4284, 7, 315, 291, 14, 888, 26, 288, 291, 14, 5682, 81, 63, 22685, 63, 4284, 275, 1109, 8, 355, 291, 14, 888, 459, 5682, 81, 63, 22685, 63, 4284, 1105, 339, 347, 664, 63, 885, 63, 888, 63, 3437, 8, 277, 304, 267, 408, 267, 1803, 314, 1720, 1318, 367, 314, 2897, 1511, 367, 642, 3016, 267, 408, 267, 1101, 275, 1613, 8, 5682, 81, 2461, 12, 291, 680, 362, 63, 885, 63, 888, 63, 3437, 342, 398, 1101, 14, 873, 2561, 288, 283, 1000, 356, 3260, 288, 283, 5682, 81, 63, 14197, 356, 3260, 267, 3828, 267, 372, 1101, 339, 347, 664, 63, 885, 63, 888, 8, 277, 304, 267, 408, 267, 1432, 314, 849, 1101, 367, 314, 3016, 267, 408, 267, 1101, 275, 1613, 8, 5682, 81, 2461, 12, 291, 680, 362, 63, 885, 63, 888, 342, 398, 1101, 14, 873, 2561, 288, 283, 1000, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 288, 283, 5682, 81, 63, 14197, 356, 283, 328, 24940, 297, 267, 3828, 398, 372, 1101, 339, 347, 485, 3409, 63, 452, 8, 277, 304, 267, 408, 267, 22630, 1006, 820, 14449, 8037, 3247, 315, 1101, 267, 408, 267, 367, 519, 8334, 63, 1000, 315, 291, 14, 5682, 81, 63, 1000, 26, 288, 291, 423, 3409, 8, 5682, 81, 63, 1000, 9, 339, 347, 485, 3409, 8, 277, 12, 519, 8334, 63, 1000, 304, 267, 408, 1779, 2790, 18787, 2838, 436, 5398, 267, 408, 267, 340, 334, 5682, 81, 63, 1000, 315, 291, 14, 7995, 14, 1612, 342, 355, 436, 291, 14, 7995, 59, 5682, 81, 63, 1000, 61, 365, 440, 488, 355, 436, 291, 14, 7995, 59, 5682, 81, 63, 1000, 1055, 374, 63, 1490, 304, 288, 327, 2779, 12237, 781, 2575, 1172, 642, 1654, 12, 880, 4691, 1159, 862, 485, 324, 3409, 2951, 288, 327, 370, 506, 5048, 14, 288, 291, 423, 324, 3409, 8, 5682, 81, 63, 1000, 9, 398, 6235, 275, 488, 267, 340, 291, 14, 5682, 81, 63, 751, 436, 291, 14, 5682, 81, 63, 2060, 26, 288, 6235, 275, 299, 26966, 14, 20711, 13428, 8, 355, 291, 14, 5682, 81, 63, 751, 12, 355, 291, 14, 5682, 81, 63, 2060, 9, 398, 2633, 275, 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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 ]
openhatch/oh-mainline
vendor/packages/twisted/twisted/test/test_jelly.py
18
19479
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Test cases for L{jelly} object serialization. """ import datetime try: import decimal except ImportError: decimal = None from twisted.spread import jelly, pb from twisted.python.compat import set, frozenset from twisted.trial import unittest from twisted.test.proto_helpers import StringTransport class TestNode(object, jelly.Jellyable): """ An object to test jellyfying of new style class instances. """ classAttr = 4 def __init__(self, parent=None): if parent: self.id = parent.id + 1 parent.children.append(self) else: self.id = 1 self.parent = parent self.children = [] class A: """ Dummy class. """ def amethod(self): """ Method tp be used in serialization tests. """ def afunc(self): """ A dummy function to test function serialization. """ class B: """ Dummy class. """ def bmethod(self): """ Method to be used in serialization tests. """ class C: """ Dummy class. """ def cmethod(self): """ Method to be used in serialization tests. """ class D(object): """ Dummy new-style class. """ class E(object): """ Dummy new-style class with slots. """ __slots__ = ("x", "y") def __init__(self, x=None, y=None): self.x = x self.y = y def __getstate__(self): return {"x" : self.x, "y" : self.y} def __setstate__(self, state): self.x = state["x"] self.y = state["y"] class SimpleJellyTest: def __init__(self, x, y): self.x = x self.y = y def isTheSameAs(self, other): return self.__dict__ == other.__dict__ class JellyTestCase(unittest.TestCase): """ Testcases for L{jelly} module serialization. @cvar decimalData: serialized version of decimal data, to be used in tests. @type decimalData: C{list} """ def _testSecurity(self, inputList, atom): """ Helper test method to test security options for a type. @param inputList: a sample input for the type. @param inputList: C{list} @param atom: atom identifier for the type. @type atom: C{str} """ c = jelly.jelly(inputList) taster = jelly.SecurityOptions() taster.allowBasicTypes() # By default, it should succeed jelly.unjelly(c, taster) taster.allowedTypes.pop(atom) # But it should raise an exception when disallowed self.assertRaises(jelly.InsecureJelly, jelly.unjelly, c, taster) def test_methodSelfIdentity(self): a = A() b = B() a.bmethod = b.bmethod b.a = a im_ = jelly.unjelly(jelly.jelly(b)).a.bmethod self.assertEquals(im_.im_class, im_.im_self.__class__) def test_methodsNotSelfIdentity(self): """ If a class change after an instance has been created, L{jelly.unjelly} shoud raise a C{TypeError} when trying to unjelly the instance. """ a = A() b = B() c = C() a.bmethod = c.cmethod b.a = a savecmethod = C.cmethod del C.cmethod try: self.assertRaises(TypeError, jelly.unjelly, jelly.jelly(b)) finally: C.cmethod = savecmethod def test_newStyle(self): n = D() n.x = 1 n2 = D() n.n2 = n2 n.n3 = n2 c = jelly.jelly(n) m = jelly.unjelly(c) self.assertIsInstance(m, D) self.assertIdentical(m.n2, m.n3) def test_newStyleWithSlots(self): """ A class defined with I{slots} can be jellied and unjellied with the values for its attributes preserved. """ n = E() n.x = 1 c = jelly.jelly(n) m = jelly.unjelly(c) self.assertIsInstance(m, E) self.assertEquals(n.x, 1) def test_typeOldStyle(self): """ Test that an old style class type can be jellied and unjellied to the original type. """ t = [C] r = jelly.unjelly(jelly.jelly(t)) self.assertEquals(t, r) def test_typeNewStyle(self): """ Test that a new style class type can be jellied and unjellied to the original type. """ t = [D] r = jelly.unjelly(jelly.jelly(t)) self.assertEquals(t, r) def test_typeBuiltin(self): """ Test that a builtin type can be jellied and unjellied to the original type. """ t = [str] r = jelly.unjelly(jelly.jelly(t)) self.assertEquals(t, r) def test_dateTime(self): dtn = datetime.datetime.now() dtd = datetime.datetime.now() - dtn input = [dtn, dtd] c = jelly.jelly(input) output = jelly.unjelly(c) self.assertEquals(input, output) self.assertNotIdentical(input, output) def test_decimal(self): """ Jellying L{decimal.Decimal} instances and then unjellying the result should produce objects which represent the values of the original inputs. """ inputList = [decimal.Decimal('9.95'), decimal.Decimal(0), decimal.Decimal(123456), decimal.Decimal('-78.901')] c = jelly.jelly(inputList) output = jelly.unjelly(c) self.assertEquals(inputList, output) self.assertNotIdentical(inputList, output) decimalData = ['list', ['decimal', 995, -2], ['decimal', 0, 0], ['decimal', 123456, 0], ['decimal', -78901, -3]] def test_decimalUnjelly(self): """ Unjellying the s-expressions produced by jelly for L{decimal.Decimal} instances should result in L{decimal.Decimal} instances with the values represented by the s-expressions. This test also verifies that C{self.decimalData} contains valid jellied data. This is important since L{test_decimalMissing} re-uses C{self.decimalData} and is expected to be unable to produce L{decimal.Decimal} instances even though the s-expression correctly represents a list of them. """ expected = [decimal.Decimal('9.95'), decimal.Decimal(0), decimal.Decimal(123456), decimal.Decimal('-78.901')] output = jelly.unjelly(self.decimalData) self.assertEquals(output, expected) def test_decimalMissing(self): """ If decimal is unavailable on the unjelly side, L{jelly.unjelly} should gracefully return L{jelly.Unpersistable} objects. """ self.patch(jelly, 'decimal', None) output = jelly.unjelly(self.decimalData) self.assertEquals(len(output), 4) for i in range(4): self.assertIsInstance(output[i], jelly.Unpersistable) self.assertEquals(output[0].reason, "Could not unpersist decimal: 9.95") self.assertEquals(output[1].reason, "Could not unpersist decimal: 0") self.assertEquals(output[2].reason, "Could not unpersist decimal: 123456") self.assertEquals(output[3].reason, "Could not unpersist decimal: -78.901") def test_decimalSecurity(self): """ By default, C{decimal} objects should be allowed by L{jelly.SecurityOptions}. If not allowed, L{jelly.unjelly} should raise L{jelly.InsecureJelly} when trying to unjelly it. """ inputList = [decimal.Decimal('9.95')] self._testSecurity(inputList, "decimal") if decimal is None: skipReason = "decimal not available" test_decimal.skip = skipReason test_decimalUnjelly.skip = skipReason test_decimalSecurity.skip = skipReason def test_set(self): """ Jellying C{set} instances and then unjellying the result should produce objects which represent the values of the original inputs. """ inputList = [set([1, 2, 3])] output = jelly.unjelly(jelly.jelly(inputList)) self.assertEquals(inputList, output) self.assertNotIdentical(inputList, output) def test_frozenset(self): """ Jellying C{frozenset} instances and then unjellying the result should produce objects which represent the values of the original inputs. """ inputList = [frozenset([1, 2, 3])] output = jelly.unjelly(jelly.jelly(inputList)) self.assertEquals(inputList, output) self.assertNotIdentical(inputList, output) def test_setSecurity(self): """ By default, C{set} objects should be allowed by L{jelly.SecurityOptions}. If not allowed, L{jelly.unjelly} should raise L{jelly.InsecureJelly} when trying to unjelly it. """ inputList = [set([1, 2, 3])] self._testSecurity(inputList, "set") def test_frozensetSecurity(self): """ By default, C{frozenset} objects should be allowed by L{jelly.SecurityOptions}. If not allowed, L{jelly.unjelly} should raise L{jelly.InsecureJelly} when trying to unjelly it. """ inputList = [frozenset([1, 2, 3])] self._testSecurity(inputList, "frozenset") def test_oldSets(self): """ Test jellying C{sets.Set}: it should serialize to the same thing as C{set} jelly, and be unjellied as C{set} if available. """ inputList = [jelly._sets.Set([1, 2, 3])] inputJelly = jelly.jelly(inputList) self.assertEquals(inputJelly, jelly.jelly([set([1, 2, 3])])) output = jelly.unjelly(inputJelly) # Even if the class is different, it should coerce to the same list self.assertEquals(list(inputList[0]), list(output[0])) if set is jelly._sets.Set: self.assertIsInstance(output[0], jelly._sets.Set) else: self.assertIsInstance(output[0], set) def test_oldImmutableSets(self): """ Test jellying C{sets.ImmutableSet}: it should serialize to the same thing as C{frozenset} jelly, and be unjellied as C{frozenset} if available. """ inputList = [jelly._sets.ImmutableSet([1, 2, 3])] inputJelly = jelly.jelly(inputList) self.assertEquals(inputJelly, jelly.jelly([frozenset([1, 2, 3])])) output = jelly.unjelly(inputJelly) # Even if the class is different, it should coerce to the same list self.assertEquals(list(inputList[0]), list(output[0])) if frozenset is jelly._sets.ImmutableSet: self.assertIsInstance(output[0], jelly._sets.ImmutableSet) else: self.assertIsInstance(output[0], frozenset) def test_simple(self): """ Simplest test case. """ self.failUnless(SimpleJellyTest('a', 'b').isTheSameAs( SimpleJellyTest('a', 'b'))) a = SimpleJellyTest(1, 2) cereal = jelly.jelly(a) b = jelly.unjelly(cereal) self.failUnless(a.isTheSameAs(b)) def test_identity(self): """ Test to make sure that objects retain identity properly. """ x = [] y = (x) x.append(y) x.append(y) self.assertIdentical(x[0], x[1]) self.assertIdentical(x[0][0], x) s = jelly.jelly(x) z = jelly.unjelly(s) self.assertIdentical(z[0], z[1]) self.assertIdentical(z[0][0], z) def test_unicode(self): x = unicode('blah') y = jelly.unjelly(jelly.jelly(x)) self.assertEquals(x, y) self.assertEquals(type(x), type(y)) def test_stressReferences(self): reref = [] toplevelTuple = ({'list': reref}, reref) reref.append(toplevelTuple) s = jelly.jelly(toplevelTuple) z = jelly.unjelly(s) self.assertIdentical(z[0]['list'], z[1]) self.assertIdentical(z[0]['list'][0], z) def test_moreReferences(self): a = [] t = (a,) a.append((t,)) s = jelly.jelly(t) z = jelly.unjelly(s) self.assertIdentical(z[0][0][0], z) def test_typeSecurity(self): """ Test for type-level security of serialization. """ taster = jelly.SecurityOptions() dct = jelly.jelly({}) self.assertRaises(jelly.InsecureJelly, jelly.unjelly, dct, taster) def test_newStyleClasses(self): j = jelly.jelly(D) uj = jelly.unjelly(D) self.assertIdentical(D, uj) def test_lotsaTypes(self): """ Test for all types currently supported in jelly """ a = A() jelly.unjelly(jelly.jelly(a)) jelly.unjelly(jelly.jelly(a.amethod)) items = [afunc, [1, 2, 3], not bool(1), bool(1), 'test', 20.3, (1, 2, 3), None, A, unittest, {'a': 1}, A.amethod] for i in items: self.assertEquals(i, jelly.unjelly(jelly.jelly(i))) def test_setState(self): global TupleState class TupleState: def __init__(self, other): self.other = other def __getstate__(self): return (self.other,) def __setstate__(self, state): self.other = state[0] def __hash__(self): return hash(self.other) a = A() t1 = TupleState(a) t2 = TupleState(a) t3 = TupleState((t1, t2)) d = {t1: t1, t2: t2, t3: t3, "t3": t3} t3prime = jelly.unjelly(jelly.jelly(d))["t3"] self.assertIdentical(t3prime.other[0].other, t3prime.other[1].other) def test_classSecurity(self): """ Test for class-level security of serialization. """ taster = jelly.SecurityOptions() taster.allowInstancesOf(A, B) a = A() b = B() c = C() # add a little complexity to the data a.b = b a.c = c # and a backreference a.x = b b.c = c # first, a friendly insecure serialization friendly = jelly.jelly(a, taster) x = jelly.unjelly(friendly, taster) self.assertIsInstance(x.c, jelly.Unpersistable) # now, a malicious one mean = jelly.jelly(a) self.assertRaises(jelly.InsecureJelly, jelly.unjelly, mean, taster) self.assertIdentical(x.x, x.b, "Identity mismatch") # test class serialization friendly = jelly.jelly(A, taster) x = jelly.unjelly(friendly, taster) self.assertIdentical(x, A, "A came back: %s" % x) def test_unjellyable(self): """ Test that if Unjellyable is used to deserialize a jellied object, state comes out right. """ class JellyableTestClass(jelly.Jellyable): pass jelly.setUnjellyableForClass(JellyableTestClass, jelly.Unjellyable) input = JellyableTestClass() input.attribute = 'value' output = jelly.unjelly(jelly.jelly(input)) self.assertEquals(output.attribute, 'value') self.assertIsInstance(output, jelly.Unjellyable) def test_persistentStorage(self): perst = [{}, 1] def persistentStore(obj, jel, perst = perst): perst[1] = perst[1] + 1 perst[0][perst[1]] = obj return str(perst[1]) def persistentLoad(pidstr, unj, perst = perst): pid = int(pidstr) return perst[0][pid] a = SimpleJellyTest(1, 2) b = SimpleJellyTest(3, 4) c = SimpleJellyTest(5, 6) a.b = b a.c = c c.b = b jel = jelly.jelly(a, persistentStore = persistentStore) x = jelly.unjelly(jel, persistentLoad = persistentLoad) self.assertIdentical(x.b, x.c.b) self.failUnless(perst[0], "persistentStore was not called.") self.assertIdentical(x.b, a.b, "Persistent storage identity failure.") def test_newStyleClassesAttributes(self): n = TestNode() n1 = TestNode(n) n11 = TestNode(n1) n2 = TestNode(n) # Jelly it jel = jelly.jelly(n) m = jelly.unjelly(jel) # Check that it has been restored ok self._check_newstyle(n, m) def _check_newstyle(self, a, b): self.assertEqual(a.id, b.id) self.assertEqual(a.classAttr, 4) self.assertEqual(b.classAttr, 4) self.assertEqual(len(a.children), len(b.children)) for x, y in zip(a.children, b.children): self._check_newstyle(x, y) def test_referenceable(self): """ A L{pb.Referenceable} instance jellies to a structure which unjellies to a L{pb.RemoteReference}. The C{RemoteReference} has a I{luid} that matches up with the local object key in the L{pb.Broker} which sent the L{Referenceable}. """ ref = pb.Referenceable() jellyBroker = pb.Broker() jellyBroker.makeConnection(StringTransport()) j = jelly.jelly(ref, invoker=jellyBroker) unjellyBroker = pb.Broker() unjellyBroker.makeConnection(StringTransport()) uj = jelly.unjelly(j, invoker=unjellyBroker) self.assertIn(uj.luid, jellyBroker.localObjects) class ClassA(pb.Copyable, pb.RemoteCopy): def __init__(self): self.ref = ClassB(self) class ClassB(pb.Copyable, pb.RemoteCopy): def __init__(self, ref): self.ref = ref class CircularReferenceTestCase(unittest.TestCase): """ Tests for circular references handling in the jelly/unjelly process. """ def test_simpleCircle(self): jelly.setUnjellyableForClass(ClassA, ClassA) jelly.setUnjellyableForClass(ClassB, ClassB) a = jelly.unjelly(jelly.jelly(ClassA())) self.assertIdentical(a.ref.ref, a, "Identity not preserved in circular reference") def test_circleWithInvoker(self): class DummyInvokerClass: pass dummyInvoker = DummyInvokerClass() dummyInvoker.serializingPerspective = None a0 = ClassA() jelly.setUnjellyableForClass(ClassA, ClassA) jelly.setUnjellyableForClass(ClassB, ClassB) j = jelly.jelly(a0, invoker=dummyInvoker) a1 = jelly.unjelly(j) self.failUnlessIdentical(a1.ref.ref, a1, "Identity not preserved in circular reference") def test_set(self): """ Check that a C{set} can contain a circular reference and be serialized and unserialized without losing the reference. """ s = set() a = SimpleJellyTest(s, None) s.add(a) res = jelly.unjelly(jelly.jelly(a)) self.assertIsInstance(res.x, set) self.assertEquals(list(res.x), [res]) def test_frozenset(self): """ Check that a C{frozenset} can contain a circular reference and be serializeserialized without losing the reference. """ a = SimpleJellyTest(None, None) s = frozenset([a]) a.x = s res = jelly.unjelly(jelly.jelly(a)) self.assertIsInstance(res.x, frozenset) self.assertEquals(list(res.x), [res])
agpl-3.0
[ 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 774, 5560, 367, 491, 91, 74, 29051, 93, 909, 16953, 14, 199, 624, 199, 199, 646, 2197, 199, 199, 893, 26, 272, 492, 6107, 199, 2590, 3545, 26, 272, 6107, 275, 488, 199, 199, 504, 7390, 14, 29889, 492, 1335, 29051, 12, 10446, 199, 504, 7390, 14, 1548, 14, 5819, 492, 663, 12, 9522, 199, 504, 7390, 14, 14443, 492, 2882, 199, 504, 7390, 14, 396, 14, 2625, 63, 7546, 492, 2624, 7836, 421, 199, 533, 1379, 1716, 8, 785, 12, 1335, 29051, 14, 42, 29051, 461, 304, 272, 408, 272, 1626, 909, 370, 511, 1335, 29051, 1399, 316, 402, 892, 3449, 1021, 4454, 14, 272, 408, 272, 1021, 7144, 275, 841, 339, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 304, 267, 340, 1676, 26, 288, 291, 14, 344, 275, 1676, 14, 344, 435, 413, 288, 1676, 14, 3223, 14, 740, 8, 277, 9, 267, 587, 26, 288, 291, 14, 344, 275, 413, 267, 291, 14, 1708, 275, 1676, 267, 291, 14, 3223, 275, 942, 4388, 199, 533, 437, 26, 272, 408, 272, 9762, 1021, 14, 272, 408, 339, 347, 282, 765, 8, 277, 304, 267, 408, 267, 9075, 9253, 506, 1202, 315, 16953, 2295, 14, 267, 408, 4388, 199, 318, 282, 1532, 8, 277, 304, 272, 408, 272, 437, 7283, 805, 370, 511, 805, 16953, 14, 272, 408, 4388, 199, 533, 699, 26, 272, 408, 272, 9762, 1021, 14, 272, 408, 339, 347, 330, 765, 8, 277, 304, 267, 408, 267, 9075, 370, 506, 1202, 315, 16953, 2295, 14, 267, 408, 4388, 199, 533, 445, 26, 272, 408, 272, 9762, 1021, 14, 272, 408, 339, 347, 286, 765, 8, 277, 304, 267, 408, 267, 9075, 370, 506, 1202, 315, 16953, 2295, 14, 267, 408, 4388, 199, 533, 577, 8, 785, 304, 272, 408, 272, 9762, 892, 13, 2487, 1021, 14, 272, 408, 4388, 199, 533, 662, 8, 785, 304, 272, 408, 272, 9762, 892, 13, 2487, 1021, 543, 14319, 14, 272, 408, 339, 636, 7257, 363, 275, 1689, 88, 401, 298, 89, 531, 339, 347, 636, 826, 721, 277, 12, 671, 29, 403, 12, 612, 29, 403, 304, 267, 291, 14, 88, 275, 671, 267, 291, 14, 89, 275, 612, 2378, 347, 636, 16011, 721, 277, 304, 267, 372, 2420, 88, 2, 520, 291, 14, 88, 12, 298, 89, 2, 520, 291, 14, 89, 93, 2378, 347, 636, 17212, 721, 277, 12, 1174, 304, 267, 291, 14, 88, 275, 1174, 905, 88, 937, 267, 291, 14, 89, 275, 1174, 905, 89, 937, 4388, 199, 533, 5870, 42, 29051, 774, 26, 272, 347, 636, 826, 721, 277, 12, 671, 12, 612, 304, 267, 291, 14, 88, 275, 671, 267, 291, 14, 89, 275, 612, 339, 347, 365, 1918, 8479, 2822, 8, 277, 12, 1163, 304, 267, 372, 291, 855, 807, 363, 508, 1163, 855, 807, 363, 4388, 199, 533, 1603, 29051, 1746, 8, 2796, 14, 1746, 304, 272, 408, 272, 1379, 9403, 367, 491, 91, 74, 29051, 93, 859, 16953, 14, 339, 768, 26781, 6107, 1451, 26, 6380, 1015, 402, 6107, 666, 12, 370, 506, 1202, 315, 2295, 14, 272, 768, 466, 6107, 1451, 26, 445, 91, 513, 93, 272, 408, 339, 347, 485, 396, 7676, 8, 277, 12, 1324, 1296, 12, 6222, 304, 267, 408, 267, 11642, 511, 1083, 370, 511, 6391, 1511, 367, 282, 730, 14, 398, 768, 635, 1324, 1296, 26, 282, 2690, 1324, 367, 314, 730, 14, 267, 768, 635, 1324, 1296, 26, 445, 91, 513, 93, 398, 768, 635, 6222, 26, 6222, 5148, 367, 314, 730, 14, 267, 768, 466, 6222, 26, 445, 91, 495, 93, 267, 408, 267, 286, 275, 1335, 29051, 14, 74, 29051, 8, 1210, 1296, 9, 267, 307, 2311, 275, 1335, 29051, 14, 7676, 4558, 342, 267, 307, 2311, 14, 3306, 6845, 4100, 342, 267, 327, 4885, 849, 12, 652, 1077, 17961, 267, 1335, 29051, 14, 324, 74, 29051, 8, 67, 12, 307, 2311, 9, 267, 307, 2311, 14, 6541, 4100, 14, 1935, 8, 4188, 9, 267, 327, 11017, 652, 1077, 746, 376, 1919, 1380, 30994, 267, 291, 14, 1855, 8, 74, 29051, 14, 607, 7817, 42, 29051, 12, 1335, 29051, 14, 324, 74, 29051, 12, 286, 12, 307, 2311, 9, 2378, 347, 511, 63, 765, 12887, 10193, 8, 277, 304, 267, 282, 275, 437, 342, 267, 330, 275, 699, 342, 267, 282, 14, 66, 765, 275, 330, 14, 66, 765, 267, 330, 14, 65, 275, 282, 267, 3416, 63, 275, 1335, 29051, 14, 324, 74, 29051, 8, 74, 29051, 14, 74, 29051, 8, 66, 4992, 65, 14, 66, 765, 267, 291, 14, 2947, 8, 1017, 3754, 1017, 63, 533, 12, 3416, 3754, 1017, 63, 277, 855, 533, 3368, 2378, 347, 511, 63, 2474, 1763, 12887, 10193, 8, 277, 304, 267, 408, 267, 982, 282, 1021, 1570, 2410, 376, 1256, 965, 2757, 2737, 12, 491, 91, 74, 29051, 14, 324, 74, 29051, 93, 267, 930, 1181, 746, 282, 445, 91, 4333, 93, 1380, 9936, 370, 625, 74, 29051, 314, 1256, 14, 267, 408, 267, 282, 275, 437, 342, 267, 330, 275, 699, 342, 267, 286, 275, 445, 342, 267, 282, 14, 66, 765, 275, 286, 14, 67, 765, 267, 330, 14, 65, 275, 282, 267, 3354, 67, 765, 275, 445, 14, 67, 765, 267, 2150, 445, 14, 67, 765, 267, 862, 26, 288, 291, 14, 1855, 8, 4333, 12, 1335, 29051, 14, 324, 74, 29051, 12, 1335, 29051, 14, 74, 29051, 8, 66, 430, 267, 3753, 26, 288, 445, 14, 67, 765, 275, 3354, 67, 765, 2378, 347, 511, 63, 1222, 6609, 8, 277, 304, 267, 302, 275, 577, 342, 267, 302, 14, 88, 275, 413, 267, 302, 18, 275, 577, 342, 267, 302, 14, 78, 18, 275, 302, 18, 267, 302, 14, 78, 19, 275, 302, 18, 267, 286, 275, 1335, 29051, 14, 74, 29051, 8, 78, 9, 267, 333, 275, 1335, 29051, 14, 324, 74, 29051, 8, 67, 9, 267, 291, 14, 6926, 8, 77, 12, 577, 9, 267, 291, 14, 479, 22469, 8, 77, 14, 78, 18, 12, 333, 14, 78, 19, 9, 2378, 347, 511, 63, 1222, 6609, 3007 ]
[ 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 774, 5560, 367, 491, 91, 74, 29051, 93, 909, 16953, 14, 199, 624, 199, 199, 646, 2197, 199, 199, 893, 26, 272, 492, 6107, 199, 2590, 3545, 26, 272, 6107, 275, 488, 199, 199, 504, 7390, 14, 29889, 492, 1335, 29051, 12, 10446, 199, 504, 7390, 14, 1548, 14, 5819, 492, 663, 12, 9522, 199, 504, 7390, 14, 14443, 492, 2882, 199, 504, 7390, 14, 396, 14, 2625, 63, 7546, 492, 2624, 7836, 421, 199, 533, 1379, 1716, 8, 785, 12, 1335, 29051, 14, 42, 29051, 461, 304, 272, 408, 272, 1626, 909, 370, 511, 1335, 29051, 1399, 316, 402, 892, 3449, 1021, 4454, 14, 272, 408, 272, 1021, 7144, 275, 841, 339, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 304, 267, 340, 1676, 26, 288, 291, 14, 344, 275, 1676, 14, 344, 435, 413, 288, 1676, 14, 3223, 14, 740, 8, 277, 9, 267, 587, 26, 288, 291, 14, 344, 275, 413, 267, 291, 14, 1708, 275, 1676, 267, 291, 14, 3223, 275, 942, 4388, 199, 533, 437, 26, 272, 408, 272, 9762, 1021, 14, 272, 408, 339, 347, 282, 765, 8, 277, 304, 267, 408, 267, 9075, 9253, 506, 1202, 315, 16953, 2295, 14, 267, 408, 4388, 199, 318, 282, 1532, 8, 277, 304, 272, 408, 272, 437, 7283, 805, 370, 511, 805, 16953, 14, 272, 408, 4388, 199, 533, 699, 26, 272, 408, 272, 9762, 1021, 14, 272, 408, 339, 347, 330, 765, 8, 277, 304, 267, 408, 267, 9075, 370, 506, 1202, 315, 16953, 2295, 14, 267, 408, 4388, 199, 533, 445, 26, 272, 408, 272, 9762, 1021, 14, 272, 408, 339, 347, 286, 765, 8, 277, 304, 267, 408, 267, 9075, 370, 506, 1202, 315, 16953, 2295, 14, 267, 408, 4388, 199, 533, 577, 8, 785, 304, 272, 408, 272, 9762, 892, 13, 2487, 1021, 14, 272, 408, 4388, 199, 533, 662, 8, 785, 304, 272, 408, 272, 9762, 892, 13, 2487, 1021, 543, 14319, 14, 272, 408, 339, 636, 7257, 363, 275, 1689, 88, 401, 298, 89, 531, 339, 347, 636, 826, 721, 277, 12, 671, 29, 403, 12, 612, 29, 403, 304, 267, 291, 14, 88, 275, 671, 267, 291, 14, 89, 275, 612, 2378, 347, 636, 16011, 721, 277, 304, 267, 372, 2420, 88, 2, 520, 291, 14, 88, 12, 298, 89, 2, 520, 291, 14, 89, 93, 2378, 347, 636, 17212, 721, 277, 12, 1174, 304, 267, 291, 14, 88, 275, 1174, 905, 88, 937, 267, 291, 14, 89, 275, 1174, 905, 89, 937, 4388, 199, 533, 5870, 42, 29051, 774, 26, 272, 347, 636, 826, 721, 277, 12, 671, 12, 612, 304, 267, 291, 14, 88, 275, 671, 267, 291, 14, 89, 275, 612, 339, 347, 365, 1918, 8479, 2822, 8, 277, 12, 1163, 304, 267, 372, 291, 855, 807, 363, 508, 1163, 855, 807, 363, 4388, 199, 533, 1603, 29051, 1746, 8, 2796, 14, 1746, 304, 272, 408, 272, 1379, 9403, 367, 491, 91, 74, 29051, 93, 859, 16953, 14, 339, 768, 26781, 6107, 1451, 26, 6380, 1015, 402, 6107, 666, 12, 370, 506, 1202, 315, 2295, 14, 272, 768, 466, 6107, 1451, 26, 445, 91, 513, 93, 272, 408, 339, 347, 485, 396, 7676, 8, 277, 12, 1324, 1296, 12, 6222, 304, 267, 408, 267, 11642, 511, 1083, 370, 511, 6391, 1511, 367, 282, 730, 14, 398, 768, 635, 1324, 1296, 26, 282, 2690, 1324, 367, 314, 730, 14, 267, 768, 635, 1324, 1296, 26, 445, 91, 513, 93, 398, 768, 635, 6222, 26, 6222, 5148, 367, 314, 730, 14, 267, 768, 466, 6222, 26, 445, 91, 495, 93, 267, 408, 267, 286, 275, 1335, 29051, 14, 74, 29051, 8, 1210, 1296, 9, 267, 307, 2311, 275, 1335, 29051, 14, 7676, 4558, 342, 267, 307, 2311, 14, 3306, 6845, 4100, 342, 267, 327, 4885, 849, 12, 652, 1077, 17961, 267, 1335, 29051, 14, 324, 74, 29051, 8, 67, 12, 307, 2311, 9, 267, 307, 2311, 14, 6541, 4100, 14, 1935, 8, 4188, 9, 267, 327, 11017, 652, 1077, 746, 376, 1919, 1380, 30994, 267, 291, 14, 1855, 8, 74, 29051, 14, 607, 7817, 42, 29051, 12, 1335, 29051, 14, 324, 74, 29051, 12, 286, 12, 307, 2311, 9, 2378, 347, 511, 63, 765, 12887, 10193, 8, 277, 304, 267, 282, 275, 437, 342, 267, 330, 275, 699, 342, 267, 282, 14, 66, 765, 275, 330, 14, 66, 765, 267, 330, 14, 65, 275, 282, 267, 3416, 63, 275, 1335, 29051, 14, 324, 74, 29051, 8, 74, 29051, 14, 74, 29051, 8, 66, 4992, 65, 14, 66, 765, 267, 291, 14, 2947, 8, 1017, 3754, 1017, 63, 533, 12, 3416, 3754, 1017, 63, 277, 855, 533, 3368, 2378, 347, 511, 63, 2474, 1763, 12887, 10193, 8, 277, 304, 267, 408, 267, 982, 282, 1021, 1570, 2410, 376, 1256, 965, 2757, 2737, 12, 491, 91, 74, 29051, 14, 324, 74, 29051, 93, 267, 930, 1181, 746, 282, 445, 91, 4333, 93, 1380, 9936, 370, 625, 74, 29051, 314, 1256, 14, 267, 408, 267, 282, 275, 437, 342, 267, 330, 275, 699, 342, 267, 286, 275, 445, 342, 267, 282, 14, 66, 765, 275, 286, 14, 67, 765, 267, 330, 14, 65, 275, 282, 267, 3354, 67, 765, 275, 445, 14, 67, 765, 267, 2150, 445, 14, 67, 765, 267, 862, 26, 288, 291, 14, 1855, 8, 4333, 12, 1335, 29051, 14, 324, 74, 29051, 12, 1335, 29051, 14, 74, 29051, 8, 66, 430, 267, 3753, 26, 288, 445, 14, 67, 765, 275, 3354, 67, 765, 2378, 347, 511, 63, 1222, 6609, 8, 277, 304, 267, 302, 275, 577, 342, 267, 302, 14, 88, 275, 413, 267, 302, 18, 275, 577, 342, 267, 302, 14, 78, 18, 275, 302, 18, 267, 302, 14, 78, 19, 275, 302, 18, 267, 286, 275, 1335, 29051, 14, 74, 29051, 8, 78, 9, 267, 333, 275, 1335, 29051, 14, 324, 74, 29051, 8, 67, 9, 267, 291, 14, 6926, 8, 77, 12, 577, 9, 267, 291, 14, 479, 22469, 8, 77, 14, 78, 18, 12, 333, 14, 78, 19, 9, 2378, 347, 511, 63, 1222, 6609, 3007, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
chipaca/snapcraft
tests/os_release.py
2
1612
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- # # Copyright (C) 2018 Canonical Ltd # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License 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 contextlib from typing import Dict, Optional # noqa: F401 _ID_TO_UBUNTU_CODENAME = { "17.10": "artful", "17.04": "zesty", "16.04": "xenial", "14.04": "trusty", } def get_version_codename() -> Optional[str]: """Return the OS version codename This first tries to use the VERSION_CODENAME. If that's missing, it tries to use the VERSION_ID to figure out the codename on its own. """ os_release = {} # type: Dict[str, str] with contextlib.suppress(FileNotFoundError): with open("/etc/os-release") as f: for line in f: entry = line.rstrip().split("=") if len(entry) == 2: os_release[entry[0]] = entry[1].strip('"') with contextlib.suppress(KeyError): return os_release["VERSION_CODENAME"] with contextlib.suppress(KeyError): return _ID_TO_UBUNTU_CODENAME[os_release["VERSION_ID"]] return None
gpl-3.0
[ 3, 1882, 4900, 26, 4718, 27, 4363, 13, 8741, 13, 632, 26, 20613, 27, 5174, 13, 2063, 26, 20, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 14894, 6855, 7174, 12126, 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, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 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, 15502, 199, 504, 14090, 492, 7448, 12, 4879, 221, 327, 8151, 26, 481, 8854, 199, 199, 63, 998, 63, 2566, 63, 2533, 17252, 53, 63, 12592, 11536, 275, 469, 272, 298, 1196, 14, 709, 582, 298, 580, 1893, 401, 272, 298, 1196, 14, 966, 582, 298, 90, 597, 89, 401, 272, 298, 975, 14, 966, 582, 298, 13615, 2380, 401, 272, 298, 1079, 14, 966, 582, 298, 15756, 89, 401, 199, 93, 421, 199, 318, 664, 63, 1023, 63, 11879, 342, 1035, 4879, 59, 495, 2189, 272, 408, 1767, 314, 4403, 1015, 29754, 339, 961, 1642, 11275, 370, 675, 314, 15945, 63, 12592, 11536, 14, 982, 626, 1159, 4124, 12, 652, 272, 11275, 370, 675, 314, 15945, 63, 998, 370, 9658, 734, 314, 29754, 641, 2399, 5705, 14, 339, 408, 272, 747, 63, 3221, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 620, 61, 272, 543, 15502, 14, 17381, 8, 1173, 10870, 304, 267, 543, 1551, 4769, 6839, 15, 736, 13, 3221, 531, 465, 289, 26, 288, 367, 1004, 315, 289, 26, 355, 2397, 275, 1004, 14, 6735, 1252, 1294, 480, 23758, 355, 340, 822, 8, 2373, 9, 508, 499, 26, 490, 747, 63, 3221, 59, 2373, 59, 16, 2677, 275, 2397, 59, 17, 1055, 1913, 25441, 339, 543, 15502, 14, 17381, 8, 10230, 304, 267, 372, 747, 63, 3221, 905, 4612, 63, 12592, 11536, 937, 339, 543, 15502, 14, 17381, 8, 10230, 304, 267, 372, 485, 998, 63, 2566, 63, 2533, 17252, 53, 63, 12592, 11536, 59, 736, 63, 3221, 905, 4612, 63, 998, 15261, 339, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 4900, 26, 4718, 27, 4363, 13, 8741, 13, 632, 26, 20613, 27, 5174, 13, 2063, 26, 20, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 14894, 6855, 7174, 12126, 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, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 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, 15502, 199, 504, 14090, 492, 7448, 12, 4879, 221, 327, 8151, 26, 481, 8854, 199, 199, 63, 998, 63, 2566, 63, 2533, 17252, 53, 63, 12592, 11536, 275, 469, 272, 298, 1196, 14, 709, 582, 298, 580, 1893, 401, 272, 298, 1196, 14, 966, 582, 298, 90, 597, 89, 401, 272, 298, 975, 14, 966, 582, 298, 13615, 2380, 401, 272, 298, 1079, 14, 966, 582, 298, 15756, 89, 401, 199, 93, 421, 199, 318, 664, 63, 1023, 63, 11879, 342, 1035, 4879, 59, 495, 2189, 272, 408, 1767, 314, 4403, 1015, 29754, 339, 961, 1642, 11275, 370, 675, 314, 15945, 63, 12592, 11536, 14, 982, 626, 1159, 4124, 12, 652, 272, 11275, 370, 675, 314, 15945, 63, 998, 370, 9658, 734, 314, 29754, 641, 2399, 5705, 14, 339, 408, 272, 747, 63, 3221, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 620, 61, 272, 543, 15502, 14, 17381, 8, 1173, 10870, 304, 267, 543, 1551, 4769, 6839, 15, 736, 13, 3221, 531, 465, 289, 26, 288, 367, 1004, 315, 289, 26, 355, 2397, 275, 1004, 14, 6735, 1252, 1294, 480, 23758, 355, 340, 822, 8, 2373, 9, 508, 499, 26, 490, 747, 63, 3221, 59, 2373, 59, 16, 2677, 275, 2397, 59, 17, 1055, 1913, 25441, 339, 543, 15502, 14, 17381, 8, 10230, 304, 267, 372, 747, 63, 3221, 905, 4612, 63, 12592, 11536, 937, 339, 543, 15502, 14, 17381, 8, 10230, 304, 267, 372, 485, 998, 63, 2566, 63, 2533, 17252, 53, 63, 12592, 11536, 59, 736, 63, 3221, 905, 4612, 63, 998, 15261, 339, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
TW314/tw314Web
persistence/EmpresaPersistence.py
2
4143
from pip._vendor import requests from form.EmpresaForm import EmpresaForm def cadastra(empresa): form = EmpresaForm(empresa) if form.is_valid(): ramo_atividade = form.cleaned_data['ramo_atividade'] numero_cnpj = form.cleaned_data["numero_cnpj"] nome_fantasia = form.cleaned_data['nome_fantasia'] razao_social = form.cleaned_data['razao_social'] status_ativacao = form.cleaned_data['status_ativacao'] cep = form.cleaned_data['cep'] logradouro = form.cleaned_data['logradouro'] numero_logradouro = form.cleaned_data['numero_logradouro'] bairro = form.cleaned_data['bairro'] cidade = form.cleaned_data['cidade'] uf = form.cleaned_data['uf'] email = form.cleaned_data['email'] telefone = form.cleaned_data['telefone'] nome_responsavel = form.cleaned_data['nome_responsavel'] cargo_responsavel = form.cleaned_data['cargo_responsavel'] cpf_responsavel = form.cleaned_data['cpf_responsavel'] data = monta_json(nome_fantasia, razao_social, numero_cnpj, logradouro, numero_logradouro, bairro, cidade, uf, cep, telefone, email, nome_responsavel, cargo_responsavel, cpf_responsavel, ramo_atividade, status_ativacao) try: form = requests.post('http://localhost:3000/empresa', json=data) except requests.exceptions.ConnectionError: # verificar se funciona form = "Erro ao tentar conectar com WebService" else: form = "Campos de Empresa nao preenchidos corretamente" return form def atualiza(empresa_novo, empresa, pk): form = EmpresaForm(empresa_novo) if form.is_valid(): ramo_atividade = form.cleaned_data['ramo_atividade'] numero_cnpj = form.cleaned_data["numero_cnpj"] # todo: remover da edicao nome_fantasia = form.cleaned_data['nome_fantasia'] razao_social = form.cleaned_data['razao_social'] status_ativacao = empresa['status_ativacao'] cep = form.cleaned_data['cep'] logradouro = form.cleaned_data['logradouro'] numero_logradouro = form.cleaned_data['numero_logradouro'] bairro = form.cleaned_data['bairro'] cidade = form.cleaned_data['cidade'] uf = form.cleaned_data['uf'] email = form.cleaned_data['email'] telefone = form.cleaned_data['telefone'] nome_responsavel = form.cleaned_data['nome_responsavel'] cargo_responsavel = form.cleaned_data['cargo_responsavel'] cpf_responsavel = form.cleaned_data['cpf_responsavel'] data = monta_json(nome_fantasia, razao_social, numero_cnpj, logradouro, numero_logradouro, bairro, cidade, uf, cep, telefone, email, nome_responsavel, cargo_responsavel, cpf_responsavel, ramo_atividade, status_ativacao) try: form = requests.put('http://localhost:3000/empresa/' + pk, json=data) except requests.exceptions.ConnectionError: # verificar se funciona form = "<h3>Erro ao tentar conectar com WebService</h3>" else: form = "<h3>Campos de Empresa nao preenchidos corretamente</h3>" return form def lista(): empresa = requests.get('http://localhost:3000/empresa').json() return empresa def busca_por_cnpj(cnpj): empresa = requests.get('http://localhost:3000/empresa/' + cnpj).json() return empresa def empresa_por_id(id): return requests.get('http://localhost:3000/empresa/' + str(id)).json() def monta_json(nome_fantasia, razao_social, numero_cnpj, logradouro, numero_logradouro, bairro, cidade, uf, cep, telefone, email, nome_responsavel, cargo_responsavel, cpf_responsavel, ramo_atividade, status_ativacao): data = {'nome_fantasia': nome_fantasia, 'razao_social': razao_social, 'numero_cnpj': numero_cnpj, 'logradouro': logradouro, 'numero_logradouro': numero_logradouro, 'bairro': bairro, 'cidade': cidade, 'uf': uf, 'cep': cep, 'telefone': telefone, 'email': email, 'nome_responsavel': nome_responsavel, 'cargo_responsavel': cargo_responsavel, 'cpf_responsavel': cpf_responsavel, 'ramoAtividadeId': ramo_atividade, 'status_ativacao': status_ativacao} return data
gpl-3.0
[ 504, 7305, 423, 9884, 492, 4145, 199, 199, 504, 1824, 14, 37, 311, 470, 65, 2821, 492, 662, 311, 470, 65, 2821, 421, 199, 318, 286, 350, 1810, 345, 8, 2109, 470, 65, 304, 272, 1824, 275, 662, 311, 470, 65, 2821, 8, 2109, 470, 65, 9, 339, 340, 1824, 14, 374, 63, 1078, 837, 267, 660, 573, 63, 2159, 5017, 9587, 275, 1824, 14, 8275, 63, 576, 459, 345, 573, 63, 2159, 5017, 9587, 418, 267, 10330, 293, 63, 67, 1590, 74, 275, 1824, 14, 8275, 63, 576, 905, 10563, 293, 63, 67, 1590, 74, 937, 267, 949, 278, 63, 70, 867, 305, 4674, 275, 1824, 14, 8275, 63, 576, 459, 29897, 63, 70, 867, 305, 4674, 418, 267, 660, 90, 8035, 63, 13574, 275, 1824, 14, 8275, 63, 576, 459, 345, 90, 8035, 63, 13574, 418, 267, 2004, 63, 2159, 15367, 8035, 275, 1824, 14, 8275, 63, 576, 459, 1205, 63, 2159, 15367, 8035, 418, 267, 286, 1545, 275, 1824, 14, 8275, 63, 576, 459, 28448, 418, 267, 560, 6017, 810, 293, 275, 1824, 14, 8275, 63, 576, 459, 793, 9525, 810, 293, 418, 267, 10330, 293, 63, 793, 9525, 810, 293, 275, 1824, 14, 8275, 63, 576, 459, 10563, 293, 63, 793, 9525, 810, 293, 418, 267, 330, 8387, 293, 275, 1824, 14, 8275, 63, 576, 459, 2470, 723, 293, 418, 267, 12229, 9587, 275, 1824, 14, 8275, 63, 576, 459, 7504, 9587, 418, 267, 399, 70, 275, 1824, 14, 8275, 63, 576, 459, 1286, 418, 267, 3031, 275, 1824, 14, 8275, 63, 576, 459, 2123, 418, 267, 14001, 70, 368, 275, 1824, 14, 8275, 63, 576, 459, 15253, 70, 368, 418, 267, 949, 278, 63, 3853, 2231, 1090, 275, 1824, 14, 8275, 63, 576, 459, 29897, 63, 3853, 2231, 1090, 418, 267, 286, 16308, 63, 3853, 2231, 1090, 275, 1824, 14, 8275, 63, 576, 459, 67, 16308, 63, 3853, 2231, 1090, 418, 267, 7667, 70, 63, 3853, 2231, 1090, 275, 1824, 14, 8275, 63, 576, 459, 1850, 70, 63, 3853, 2231, 1090, 418, 398, 666, 275, 3485, 502, 63, 1001, 8, 29897, 63, 70, 867, 305, 4674, 12, 660, 90, 8035, 63, 13574, 12, 10330, 293, 63, 67, 1590, 74, 12, 560, 6017, 810, 293, 12, 10330, 293, 63, 793, 9525, 810, 293, 12, 330, 8387, 293, 12, 12229, 9587, 12, 399, 70, 12, 286, 1545, 12, 14001, 70, 368, 12, 3031, 12, 949, 278, 63, 3853, 2231, 1090, 12, 286, 16308, 63, 3853, 2231, 1090, 12, 7667, 70, 63, 3853, 2231, 1090, 12, 660, 573, 63, 2159, 5017, 9587, 12, 2004, 63, 2159, 15367, 8035, 9, 267, 862, 26, 288, 1824, 275, 4145, 14, 1932, 360, 1014, 921, 5967, 26, 19962, 15, 2109, 470, 65, 297, 2022, 29, 576, 9, 267, 871, 4145, 14, 3924, 14, 20349, 26, 327, 809, 12061, 285, 542, 9627, 9718, 65, 288, 1824, 275, 298, 539, 293, 282, 79, 221, 767, 285, 286, 368, 319, 285, 2414, 6001, 3167, 2, 272, 587, 26, 267, 1824, 275, 298, 3630, 311, 736, 477, 662, 311, 470, 65, 302, 8035, 876, 5368, 344, 736, 1970, 3292, 313, 78, 266, 2, 272, 372, 1824, 421, 199, 318, 737, 1061, 565, 65, 8, 2109, 470, 65, 63, 889, 2392, 12, 9052, 470, 65, 12, 3803, 304, 339, 1824, 275, 662, 311, 470, 65, 2821, 8, 2109, 470, 65, 63, 889, 2392, 9, 339, 340, 1824, 14, 374, 63, 1078, 837, 267, 660, 573, 63, 2159, 5017, 9587, 275, 1824, 14, 8275, 63, 576, 459, 345, 573, 63, 2159, 5017, 9587, 418, 267, 10330, 293, 63, 67, 1590, 74, 275, 1824, 14, 8275, 63, 576, 905, 10563, 293, 63, 67, 1590, 74, 937, 221, 327, 11386, 26, 32178, 422, 12927, 7860, 696, 79, 267, 949, 278, 63, 70, 867, 305, 4674, 275, 1824, 14, 8275, 63, 576, 459, 29897, 63, 70, 867, 305, 4674, 418, 267, 660, 90, 8035, 63, 13574, 275, 1824, 14, 8275, 63, 576, 459, 345, 90, 8035, 63, 13574, 418, 267, 2004, 63, 2159, 15367, 8035, 275, 9052, 470, 65, 459, 1205, 63, 2159, 15367, 8035, 418, 267, 286, 1545, 275, 1824, 14, 8275, 63, 576, 459, 28448, 418, 267, 560, 6017, 810, 293, 275, 1824, 14, 8275, 63, 576, 459, 793, 9525, 810, 293, 418, 267, 10330, 293, 63, 793, 9525, 810, 293, 275, 1824, 14, 8275, 63, 576, 459, 10563, 293, 63, 793, 9525, 810, 293, 418, 267, 330, 8387, 293, 275, 1824, 14, 8275, 63, 576, 459, 2470, 723, 293, 418, 267, 12229, 9587, 275, 1824, 14, 8275, 63, 576, 459, 7504, 9587, 418, 267, 399, 70, 275, 1824, 14, 8275, 63, 576, 459, 1286, 418, 267, 3031, 275, 1824, 14, 8275, 63, 576, 459, 2123, 418, 267, 14001, 70, 368, 275, 1824, 14, 8275, 63, 576, 459, 15253, 70, 368, 418, 267, 949, 278, 63, 3853, 2231, 1090, 275, 1824, 14, 8275, 63, 576, 459, 29897, 63, 3853, 2231, 1090, 418, 267, 286, 16308, 63, 3853, 2231, 1090, 275, 1824, 14, 8275, 63, 576, 459, 67, 16308, 63, 3853, 2231, 1090, 418, 267, 7667, 70, 63, 3853, 2231, 1090, 275, 1824, 14, 8275, 63, 576, 459, 1850, 70, 63, 3853, 2231, 1090, 418, 398, 666, 275, 3485, 502, 63, 1001, 8, 29897, 63, 70, 867, 305, 4674, 12, 660, 90, 8035, 63, 13574, 12, 10330, 293, 63, 67, 1590, 74, 12, 560, 6017, 810, 293, 12, 10330, 293, 63, 793, 9525, 810, 293, 12, 330, 8387, 293, 12, 12229, 9587, 12, 399, 70, 12, 286, 1545, 12, 14001, 70, 368, 12, 3031, 12, 949, 278, 63, 3853, 2231, 1090, 12, 286, 16308, 63, 3853, 2231, 1090, 12, 7667, 70, 63, 3853, 2231, 1090, 12, 660, 573, 63, 2159, 5017, 9587, 12, 2004, 63, 2159, 15367, 8035, 9, 398, 862, 26, 288, 1824, 275, 4145, 14, 524, 360, 1014, 921, 5967, 26, 19962, 15, 2109, 470, 65, 4805, 435, 3803, 12, 2022, 29, 576, 9, 398, 871, 4145, 14, 3924, 14, 20349, 26, 221, 327, 809, 12061, 285, 542, 9627, 9718, 65, 288, 1824, 275, 3886, 72, 19, 30, 539, 293, 282, 79, 221, 767, 285, 286, 368, 319, 285, 2414, 6001, 3167, 1108, 72, 19, 4335, 272, 587, 26, 267, 1824, 275 ]
[ 7305, 423, 9884, 492, 4145, 199, 199, 504, 1824, 14, 37, 311, 470, 65, 2821, 492, 662, 311, 470, 65, 2821, 421, 199, 318, 286, 350, 1810, 345, 8, 2109, 470, 65, 304, 272, 1824, 275, 662, 311, 470, 65, 2821, 8, 2109, 470, 65, 9, 339, 340, 1824, 14, 374, 63, 1078, 837, 267, 660, 573, 63, 2159, 5017, 9587, 275, 1824, 14, 8275, 63, 576, 459, 345, 573, 63, 2159, 5017, 9587, 418, 267, 10330, 293, 63, 67, 1590, 74, 275, 1824, 14, 8275, 63, 576, 905, 10563, 293, 63, 67, 1590, 74, 937, 267, 949, 278, 63, 70, 867, 305, 4674, 275, 1824, 14, 8275, 63, 576, 459, 29897, 63, 70, 867, 305, 4674, 418, 267, 660, 90, 8035, 63, 13574, 275, 1824, 14, 8275, 63, 576, 459, 345, 90, 8035, 63, 13574, 418, 267, 2004, 63, 2159, 15367, 8035, 275, 1824, 14, 8275, 63, 576, 459, 1205, 63, 2159, 15367, 8035, 418, 267, 286, 1545, 275, 1824, 14, 8275, 63, 576, 459, 28448, 418, 267, 560, 6017, 810, 293, 275, 1824, 14, 8275, 63, 576, 459, 793, 9525, 810, 293, 418, 267, 10330, 293, 63, 793, 9525, 810, 293, 275, 1824, 14, 8275, 63, 576, 459, 10563, 293, 63, 793, 9525, 810, 293, 418, 267, 330, 8387, 293, 275, 1824, 14, 8275, 63, 576, 459, 2470, 723, 293, 418, 267, 12229, 9587, 275, 1824, 14, 8275, 63, 576, 459, 7504, 9587, 418, 267, 399, 70, 275, 1824, 14, 8275, 63, 576, 459, 1286, 418, 267, 3031, 275, 1824, 14, 8275, 63, 576, 459, 2123, 418, 267, 14001, 70, 368, 275, 1824, 14, 8275, 63, 576, 459, 15253, 70, 368, 418, 267, 949, 278, 63, 3853, 2231, 1090, 275, 1824, 14, 8275, 63, 576, 459, 29897, 63, 3853, 2231, 1090, 418, 267, 286, 16308, 63, 3853, 2231, 1090, 275, 1824, 14, 8275, 63, 576, 459, 67, 16308, 63, 3853, 2231, 1090, 418, 267, 7667, 70, 63, 3853, 2231, 1090, 275, 1824, 14, 8275, 63, 576, 459, 1850, 70, 63, 3853, 2231, 1090, 418, 398, 666, 275, 3485, 502, 63, 1001, 8, 29897, 63, 70, 867, 305, 4674, 12, 660, 90, 8035, 63, 13574, 12, 10330, 293, 63, 67, 1590, 74, 12, 560, 6017, 810, 293, 12, 10330, 293, 63, 793, 9525, 810, 293, 12, 330, 8387, 293, 12, 12229, 9587, 12, 399, 70, 12, 286, 1545, 12, 14001, 70, 368, 12, 3031, 12, 949, 278, 63, 3853, 2231, 1090, 12, 286, 16308, 63, 3853, 2231, 1090, 12, 7667, 70, 63, 3853, 2231, 1090, 12, 660, 573, 63, 2159, 5017, 9587, 12, 2004, 63, 2159, 15367, 8035, 9, 267, 862, 26, 288, 1824, 275, 4145, 14, 1932, 360, 1014, 921, 5967, 26, 19962, 15, 2109, 470, 65, 297, 2022, 29, 576, 9, 267, 871, 4145, 14, 3924, 14, 20349, 26, 327, 809, 12061, 285, 542, 9627, 9718, 65, 288, 1824, 275, 298, 539, 293, 282, 79, 221, 767, 285, 286, 368, 319, 285, 2414, 6001, 3167, 2, 272, 587, 26, 267, 1824, 275, 298, 3630, 311, 736, 477, 662, 311, 470, 65, 302, 8035, 876, 5368, 344, 736, 1970, 3292, 313, 78, 266, 2, 272, 372, 1824, 421, 199, 318, 737, 1061, 565, 65, 8, 2109, 470, 65, 63, 889, 2392, 12, 9052, 470, 65, 12, 3803, 304, 339, 1824, 275, 662, 311, 470, 65, 2821, 8, 2109, 470, 65, 63, 889, 2392, 9, 339, 340, 1824, 14, 374, 63, 1078, 837, 267, 660, 573, 63, 2159, 5017, 9587, 275, 1824, 14, 8275, 63, 576, 459, 345, 573, 63, 2159, 5017, 9587, 418, 267, 10330, 293, 63, 67, 1590, 74, 275, 1824, 14, 8275, 63, 576, 905, 10563, 293, 63, 67, 1590, 74, 937, 221, 327, 11386, 26, 32178, 422, 12927, 7860, 696, 79, 267, 949, 278, 63, 70, 867, 305, 4674, 275, 1824, 14, 8275, 63, 576, 459, 29897, 63, 70, 867, 305, 4674, 418, 267, 660, 90, 8035, 63, 13574, 275, 1824, 14, 8275, 63, 576, 459, 345, 90, 8035, 63, 13574, 418, 267, 2004, 63, 2159, 15367, 8035, 275, 9052, 470, 65, 459, 1205, 63, 2159, 15367, 8035, 418, 267, 286, 1545, 275, 1824, 14, 8275, 63, 576, 459, 28448, 418, 267, 560, 6017, 810, 293, 275, 1824, 14, 8275, 63, 576, 459, 793, 9525, 810, 293, 418, 267, 10330, 293, 63, 793, 9525, 810, 293, 275, 1824, 14, 8275, 63, 576, 459, 10563, 293, 63, 793, 9525, 810, 293, 418, 267, 330, 8387, 293, 275, 1824, 14, 8275, 63, 576, 459, 2470, 723, 293, 418, 267, 12229, 9587, 275, 1824, 14, 8275, 63, 576, 459, 7504, 9587, 418, 267, 399, 70, 275, 1824, 14, 8275, 63, 576, 459, 1286, 418, 267, 3031, 275, 1824, 14, 8275, 63, 576, 459, 2123, 418, 267, 14001, 70, 368, 275, 1824, 14, 8275, 63, 576, 459, 15253, 70, 368, 418, 267, 949, 278, 63, 3853, 2231, 1090, 275, 1824, 14, 8275, 63, 576, 459, 29897, 63, 3853, 2231, 1090, 418, 267, 286, 16308, 63, 3853, 2231, 1090, 275, 1824, 14, 8275, 63, 576, 459, 67, 16308, 63, 3853, 2231, 1090, 418, 267, 7667, 70, 63, 3853, 2231, 1090, 275, 1824, 14, 8275, 63, 576, 459, 1850, 70, 63, 3853, 2231, 1090, 418, 398, 666, 275, 3485, 502, 63, 1001, 8, 29897, 63, 70, 867, 305, 4674, 12, 660, 90, 8035, 63, 13574, 12, 10330, 293, 63, 67, 1590, 74, 12, 560, 6017, 810, 293, 12, 10330, 293, 63, 793, 9525, 810, 293, 12, 330, 8387, 293, 12, 12229, 9587, 12, 399, 70, 12, 286, 1545, 12, 14001, 70, 368, 12, 3031, 12, 949, 278, 63, 3853, 2231, 1090, 12, 286, 16308, 63, 3853, 2231, 1090, 12, 7667, 70, 63, 3853, 2231, 1090, 12, 660, 573, 63, 2159, 5017, 9587, 12, 2004, 63, 2159, 15367, 8035, 9, 398, 862, 26, 288, 1824, 275, 4145, 14, 524, 360, 1014, 921, 5967, 26, 19962, 15, 2109, 470, 65, 4805, 435, 3803, 12, 2022, 29, 576, 9, 398, 871, 4145, 14, 3924, 14, 20349, 26, 221, 327, 809, 12061, 285, 542, 9627, 9718, 65, 288, 1824, 275, 3886, 72, 19, 30, 539, 293, 282, 79, 221, 767, 285, 286, 368, 319, 285, 2414, 6001, 3167, 1108, 72, 19, 4335, 272, 587, 26, 267, 1824, 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, 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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 ]
dirn/ansible
contrib/inventory/ovirt.py
65
9521
#!/usr/bin/env python # Copyright 2015 IIX 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/>. """ ovirt external inventory script ================================= Generates inventory that Ansible can understand by making API requests to oVirt via the ovirt-engine-sdk-python library. When run against a specific host, this script returns the following variables based on the data obtained from the ovirt_sdk Node object: - ovirt_uuid - ovirt_id - ovirt_image - ovirt_machine_type - ovirt_ips - ovirt_name - ovirt_description - ovirt_status - ovirt_zone - ovirt_tags - ovirt_stats When run in --list mode, instances are grouped by the following categories: - zone: zone group name. - instance tags: An entry is created for each tag. For example, if you have two instances with a common tag called 'foo', they will both be grouped together under the 'tag_foo' name. - network name: the name of the network is appended to 'network_' (e.g. the 'default' network will result in a group named 'network_default') - running status: group name prefixed with 'status_' (e.g. status_up, status_down,..) Examples: Execute uname on all instances in the us-central1-a zone $ ansible -i ovirt.py us-central1-a -m shell -a "/bin/uname -a" Use the ovirt inventory script to print out instance specific information $ contrib/inventory/ovirt.py --host my_instance Author: Josha Inglis <jinglis@iix.net> based on the gce.py by Eric Johnson <erjohnso@google.com> Version: 0.0.1 """ USER_AGENT_PRODUCT = "Ansible-ovirt_inventory_plugin" USER_AGENT_VERSION = "v1" import sys import os import argparse import ConfigParser from collections import defaultdict try: import json except ImportError: # noinspection PyUnresolvedReferences,PyPackageRequirements import simplejson as json try: # noinspection PyUnresolvedReferences from ovirtsdk.api import API # noinspection PyUnresolvedReferences from ovirtsdk.xml import params except ImportError: print("ovirt inventory script requires ovirt-engine-sdk-python") sys.exit(1) class OVirtInventory(object): def __init__(self): # Read settings and parse CLI arguments self.args = self.parse_cli_args() self.driver = self.get_ovirt_driver() # Just display data for specific host if self.args.host: print self.json_format_dict( self.node_to_dict(self.get_instance(self.args.host)), pretty=self.args.pretty ) sys.exit(0) # Otherwise, assume user wants all instances grouped print( self.json_format_dict( data=self.group_instances(), pretty=self.args.pretty ) ) sys.exit(0) @staticmethod def get_ovirt_driver(): """ Determine the ovirt authorization settings and return a ovirt_sdk driver. :rtype : ovirtsdk.api.API """ kwargs = {} ovirt_ini_default_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), "ovirt.ini") ovirt_ini_path = os.environ.get('OVIRT_INI_PATH', ovirt_ini_default_path) # Create a ConfigParser. # This provides empty defaults to each key, so that environment # variable configuration (as opposed to INI configuration) is able # to work. config = ConfigParser.SafeConfigParser(defaults={ 'ovirt_url': '', 'ovirt_username': '', 'ovirt_password': '', 'ovirt_api_secrets': '', }) if 'ovirt' not in config.sections(): config.add_section('ovirt') config.read(ovirt_ini_path) # Attempt to get ovirt params from a configuration file, if one # exists. secrets_path = config.get('ovirt', 'ovirt_api_secrets') secrets_found = False try: # noinspection PyUnresolvedReferences,PyPackageRequirements import secrets kwargs = getattr(secrets, 'OVIRT_KEYWORD_PARAMS', {}) secrets_found = True except ImportError: pass if not secrets_found and secrets_path: if not secrets_path.endswith('secrets.py'): err = "Must specify ovirt_sdk secrets file as /absolute/path/to/secrets.py" print(err) sys.exit(1) sys.path.append(os.path.dirname(secrets_path)) try: # noinspection PyUnresolvedReferences,PyPackageRequirements import secrets kwargs = getattr(secrets, 'OVIRT_KEYWORD_PARAMS', {}) except ImportError: pass if not secrets_found: kwargs = { 'url': config.get('ovirt', 'ovirt_url'), 'username': config.get('ovirt', 'ovirt_username'), 'password': config.get('ovirt', 'ovirt_password'), } # If the appropriate environment variables are set, they override # other configuration; process those into our args and kwargs. kwargs['url'] = os.environ.get('OVIRT_URL') kwargs['username'] = os.environ.get('OVIRT_EMAIL') kwargs['password'] = os.environ.get('OVIRT_PASS') # Retrieve and return the ovirt driver. return API(insecure=True, **kwargs) @staticmethod def parse_cli_args(): """ Command line argument processing :rtype : argparse.Namespace """ parser = argparse.ArgumentParser(description='Produce an Ansible Inventory file based on ovirt') parser.add_argument('--list', action='store_true', default=True, help='List instances (default: True)') parser.add_argument('--host', action='store', help='Get all information about an instance') parser.add_argument('--pretty', action='store_true', default=False, help='Pretty format (default: False)') return parser.parse_args() def node_to_dict(self, inst): """ :type inst: params.VM """ if inst is None: return {} inst.get_custom_properties() ips = [ip.get_address() for ip in inst.get_guest_info().get_ips().get_ip()] \ if inst.get_guest_info() is not None else [] stats = {} for stat in inst.get_statistics().list(): stats[stat.get_name()] = stat.get_values().get_value()[0].get_datum() return { 'ovirt_uuid': inst.get_id(), 'ovirt_id': inst.get_id(), 'ovirt_image': inst.get_os().get_type(), 'ovirt_machine_type': inst.get_instance_type(), 'ovirt_ips': ips, 'ovirt_name': inst.get_name(), 'ovirt_description': inst.get_description(), 'ovirt_status': inst.get_status().get_state(), 'ovirt_zone': inst.get_cluster().get_id(), 'ovirt_tags': self.get_tags(inst), 'ovirt_stats': stats, # Hosts don't have a public name, so we add an IP 'ansible_ssh_host': ips[0] if len(ips) > 0 else None } @staticmethod def get_tags(inst): """ :type inst: params.VM """ return [x.get_name() for x in inst.get_tags().list()] # noinspection PyBroadException,PyUnusedLocal def get_instance(self, instance_name): """Gets details about a specific instance """ try: return self.driver.vms.get(name=instance_name) except Exception as e: return None def group_instances(self): """Group all instances""" groups = defaultdict(list) meta = {"hostvars": {}} for node in self.driver.vms.list(): assert isinstance(node, params.VM) name = node.get_name() meta["hostvars"][name] = self.node_to_dict(node) zone = node.get_cluster().get_name() groups[zone].append(name) tags = self.get_tags(node) for t in tags: tag = 'tag_%s' % t groups[tag].append(name) nets = [x.get_name() for x in node.get_nics().list()] for net in nets: net = 'network_%s' % net groups[net].append(name) status = node.get_status().get_state() stat = 'status_%s' % status.lower() if stat in groups: groups[stat].append(name) else: groups[stat] = [name] groups["_meta"] = meta return groups @staticmethod def json_format_dict(data, pretty=False): """ Converts a dict to a JSON object and dumps it as a formatted string """ if pretty: return json.dumps(data, sort_keys=True, indent=2) else: return json.dumps(data) # Run the script OVirtInventory()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 6900, 473, 3867, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 199, 23334, 5957, 8200, 2884, 199, 2486, 29, 199, 199, 20551, 8200, 626, 2622, 883, 20647, 701, 10663, 3261, 4145, 370, 199, 79, 17146, 4799, 314, 21353, 13, 3908, 13, 9277, 13, 1548, 3555, 14, 199, 199, 11423, 1255, 6169, 282, 2488, 1591, 12, 642, 2884, 2529, 314, 2569, 2860, 199, 6788, 641, 314, 666, 15884, 687, 314, 21353, 63, 9277, 5013, 909, 26, 199, 446, 21353, 63, 2580, 199, 446, 21353, 63, 344, 199, 446, 21353, 63, 1569, 199, 446, 21353, 63, 6744, 63, 466, 199, 446, 21353, 63, 6142, 199, 446, 21353, 63, 354, 199, 446, 21353, 63, 1802, 199, 446, 21353, 63, 1205, 199, 446, 21353, 63, 2619, 199, 446, 21353, 63, 2969, 199, 446, 21353, 63, 3200, 199, 199, 11423, 1255, 315, 1553, 513, 818, 12, 4454, 787, 16251, 701, 314, 2569, 9695, 26, 421, 446, 5718, 26, 2043, 5718, 1572, 536, 14, 199, 446, 1256, 3762, 26, 2043, 1626, 2397, 365, 2737, 367, 1924, 1947, 14, 221, 2104, 2893, 12, 340, 1265, 1172, 2877, 4454, 2043, 543, 282, 2863, 1947, 2797, 283, 1421, 297, 2985, 911, 3865, 506, 16251, 10451, 1334, 2043, 314, 283, 1450, 63, 1421, 7, 536, 14, 199, 446, 2784, 536, 26, 2043, 314, 536, 402, 314, 2784, 365, 11544, 370, 283, 1200, 8650, 334, 69, 14, 71, 14, 314, 283, 885, 7, 2043, 2784, 911, 754, 315, 282, 1572, 4310, 283, 1200, 63, 885, 358, 199, 446, 3879, 2004, 26, 2043, 1572, 536, 18239, 543, 283, 1205, 8650, 334, 69, 14, 71, 14, 2004, 63, 384, 12, 2004, 63, 2110, 12, 703, 9, 199, 199, 22787, 26, 523, 17009, 28179, 641, 1006, 4454, 315, 314, 2739, 13, 16067, 17, 13, 65, 5718, 523, 2672, 3242, 446, 73, 21353, 14, 647, 2739, 13, 16067, 17, 13, 65, 446, 77, 5218, 446, 65, 3286, 1393, 15, 16040, 446, 65, 2, 819, 3645, 314, 21353, 8200, 2884, 370, 870, 734, 1256, 2488, 2556, 523, 2672, 5914, 15, 7212, 15, 23334, 14, 647, 1553, 1102, 3002, 63, 842, 199, 199, 5949, 26, 7135, 4835, 1010, 71, 14392, 665, 74, 316, 14392, 32, 73, 1148, 14, 846, 30, 4079, 641, 314, 21319, 14, 647, 701, 662, 1567, 7135, 25338, 265, 665, 281, 743, 25338, 79, 32, 3098, 14, 957, 30, 199, 3353, 26, 378, 14, 16, 14, 17, 199, 624, 199, 199, 3791, 63, 14565, 63, 14853, 275, 298, 10047, 13, 23334, 63, 7212, 63, 2718, 2, 199, 3791, 63, 14565, 63, 4612, 275, 298, 86, 17, 2, 199, 199, 646, 984, 199, 646, 747, 199, 646, 7534, 199, 646, 14196, 199, 504, 5055, 492, 10018, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 327, 30870, 1611, 1358, 13697, 15242, 12, 2713, 8599, 13902, 1470, 272, 492, 13804, 465, 2022, 199, 199, 893, 26, 272, 327, 30870, 1611, 1358, 13697, 15242, 272, 687, 312, 1042, 1086, 6341, 14, 1246, 492, 3261, 272, 327, 30870, 1611, 1358, 13697, 15242, 272, 687, 312, 1042, 1086, 6341, 14, 1652, 492, 1862, 199, 2590, 3545, 26, 272, 870, 480, 23334, 8200, 2884, 5074, 21353, 13, 3908, 13, 9277, 13, 1548, 531, 272, 984, 14, 2224, 8, 17, 9, 421, 199, 533, 593, 17146, 19304, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 327, 5574, 2202, 436, 2198, 14214, 2368, 267, 291, 14, 589, 275, 291, 14, 1122, 63, 2764, 63, 589, 342, 267, 291, 14, 3090, 275, 291, 14, 362, 63, 23334, 63, 3090, 342, 398, 327, 13870, 2929, 666, 367, 2488, 1591, 267, 340, 291, 14, 589, 14, 1102, 26, 288, 870, 291, 14, 1001, 63, 908, 63, 807, 8, 355, 291, 14, 932, 63, 475, 63, 807, 8, 277, 14, 362, 63, 842, 8, 277, 14, 589, 14, 1102, 1826, 355, 7268, 29, 277, 14, 589, 14, 9118, 288, 776, 288, 984, 14, 2224, 8, 16, 9, 398, 327, 6630, 12, 5534, 922, 15061, 1006, 4454, 16251, 267, 870, 8, 288, 291, 14, 1001, 63, 908, 63, 807, 8, 355, 666, 29, 277, 14, 923, 63, 5990, 1062, 355, 7268, 29, 277, 14, 589, 14, 9118, 288, 776, 267, 776, 267, 984, 14, 2224, 8, 16, 9, 339, 768, 4639, 272, 347, 664, 63, 23334, 63, 3090, 837, 267, 408, 267, 14703, 314, 21353, 13448, 2202, 436, 372, 282, 21353, 63, 9277, 5253, 14, 398, 520, 4500, 520, 312, 1042, 1086, 6341, 14, 1246, 14, 3735, 267, 408, 267, 2074, 275, 1052, 398, 21353, 63, 2730, 63, 885, 63, 515, 275, 747, 14, 515, 14, 904, 8, 288, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 22159, 298, 23334, 14, 2730, 531, 267, 21353, 63, 2730, 63, 515, 275, 747, 14, 2314, 14, 362, 360, 47, 18228, 63, 568, 41, 63, 3243, 297, 21353, 63, 2730, 63, 885, 63, 515, 9, 398, 327, 2790, 282, 14196, 14, 267, 327, 961, 6571, 2701, 4243, 370, 1924, 790, 12, 880, 626, 3734, 267, 327, 1750, 2897, 334, 305, 25068, 370, 1621, 41, 2897, 9, 365, 7688, 267, 327, 370, 1736, 14, 267, 1101, 275, 14196, 14, 11090, 15218, 8, 4322, 3126, 288, 283, 23334, 63, 633 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 6900, 473, 3867, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 199, 23334, 5957, 8200, 2884, 199, 2486, 29, 199, 199, 20551, 8200, 626, 2622, 883, 20647, 701, 10663, 3261, 4145, 370, 199, 79, 17146, 4799, 314, 21353, 13, 3908, 13, 9277, 13, 1548, 3555, 14, 199, 199, 11423, 1255, 6169, 282, 2488, 1591, 12, 642, 2884, 2529, 314, 2569, 2860, 199, 6788, 641, 314, 666, 15884, 687, 314, 21353, 63, 9277, 5013, 909, 26, 199, 446, 21353, 63, 2580, 199, 446, 21353, 63, 344, 199, 446, 21353, 63, 1569, 199, 446, 21353, 63, 6744, 63, 466, 199, 446, 21353, 63, 6142, 199, 446, 21353, 63, 354, 199, 446, 21353, 63, 1802, 199, 446, 21353, 63, 1205, 199, 446, 21353, 63, 2619, 199, 446, 21353, 63, 2969, 199, 446, 21353, 63, 3200, 199, 199, 11423, 1255, 315, 1553, 513, 818, 12, 4454, 787, 16251, 701, 314, 2569, 9695, 26, 421, 446, 5718, 26, 2043, 5718, 1572, 536, 14, 199, 446, 1256, 3762, 26, 2043, 1626, 2397, 365, 2737, 367, 1924, 1947, 14, 221, 2104, 2893, 12, 340, 1265, 1172, 2877, 4454, 2043, 543, 282, 2863, 1947, 2797, 283, 1421, 297, 2985, 911, 3865, 506, 16251, 10451, 1334, 2043, 314, 283, 1450, 63, 1421, 7, 536, 14, 199, 446, 2784, 536, 26, 2043, 314, 536, 402, 314, 2784, 365, 11544, 370, 283, 1200, 8650, 334, 69, 14, 71, 14, 314, 283, 885, 7, 2043, 2784, 911, 754, 315, 282, 1572, 4310, 283, 1200, 63, 885, 358, 199, 446, 3879, 2004, 26, 2043, 1572, 536, 18239, 543, 283, 1205, 8650, 334, 69, 14, 71, 14, 2004, 63, 384, 12, 2004, 63, 2110, 12, 703, 9, 199, 199, 22787, 26, 523, 17009, 28179, 641, 1006, 4454, 315, 314, 2739, 13, 16067, 17, 13, 65, 5718, 523, 2672, 3242, 446, 73, 21353, 14, 647, 2739, 13, 16067, 17, 13, 65, 446, 77, 5218, 446, 65, 3286, 1393, 15, 16040, 446, 65, 2, 819, 3645, 314, 21353, 8200, 2884, 370, 870, 734, 1256, 2488, 2556, 523, 2672, 5914, 15, 7212, 15, 23334, 14, 647, 1553, 1102, 3002, 63, 842, 199, 199, 5949, 26, 7135, 4835, 1010, 71, 14392, 665, 74, 316, 14392, 32, 73, 1148, 14, 846, 30, 4079, 641, 314, 21319, 14, 647, 701, 662, 1567, 7135, 25338, 265, 665, 281, 743, 25338, 79, 32, 3098, 14, 957, 30, 199, 3353, 26, 378, 14, 16, 14, 17, 199, 624, 199, 199, 3791, 63, 14565, 63, 14853, 275, 298, 10047, 13, 23334, 63, 7212, 63, 2718, 2, 199, 3791, 63, 14565, 63, 4612, 275, 298, 86, 17, 2, 199, 199, 646, 984, 199, 646, 747, 199, 646, 7534, 199, 646, 14196, 199, 504, 5055, 492, 10018, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 327, 30870, 1611, 1358, 13697, 15242, 12, 2713, 8599, 13902, 1470, 272, 492, 13804, 465, 2022, 199, 199, 893, 26, 272, 327, 30870, 1611, 1358, 13697, 15242, 272, 687, 312, 1042, 1086, 6341, 14, 1246, 492, 3261, 272, 327, 30870, 1611, 1358, 13697, 15242, 272, 687, 312, 1042, 1086, 6341, 14, 1652, 492, 1862, 199, 2590, 3545, 26, 272, 870, 480, 23334, 8200, 2884, 5074, 21353, 13, 3908, 13, 9277, 13, 1548, 531, 272, 984, 14, 2224, 8, 17, 9, 421, 199, 533, 593, 17146, 19304, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 327, 5574, 2202, 436, 2198, 14214, 2368, 267, 291, 14, 589, 275, 291, 14, 1122, 63, 2764, 63, 589, 342, 267, 291, 14, 3090, 275, 291, 14, 362, 63, 23334, 63, 3090, 342, 398, 327, 13870, 2929, 666, 367, 2488, 1591, 267, 340, 291, 14, 589, 14, 1102, 26, 288, 870, 291, 14, 1001, 63, 908, 63, 807, 8, 355, 291, 14, 932, 63, 475, 63, 807, 8, 277, 14, 362, 63, 842, 8, 277, 14, 589, 14, 1102, 1826, 355, 7268, 29, 277, 14, 589, 14, 9118, 288, 776, 288, 984, 14, 2224, 8, 16, 9, 398, 327, 6630, 12, 5534, 922, 15061, 1006, 4454, 16251, 267, 870, 8, 288, 291, 14, 1001, 63, 908, 63, 807, 8, 355, 666, 29, 277, 14, 923, 63, 5990, 1062, 355, 7268, 29, 277, 14, 589, 14, 9118, 288, 776, 267, 776, 267, 984, 14, 2224, 8, 16, 9, 339, 768, 4639, 272, 347, 664, 63, 23334, 63, 3090, 837, 267, 408, 267, 14703, 314, 21353, 13448, 2202, 436, 372, 282, 21353, 63, 9277, 5253, 14, 398, 520, 4500, 520, 312, 1042, 1086, 6341, 14, 1246, 14, 3735, 267, 408, 267, 2074, 275, 1052, 398, 21353, 63, 2730, 63, 885, 63, 515, 275, 747, 14, 515, 14, 904, 8, 288, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 22159, 298, 23334, 14, 2730, 531, 267, 21353, 63, 2730, 63, 515, 275, 747, 14, 2314, 14, 362, 360, 47, 18228, 63, 568, 41, 63, 3243, 297, 21353, 63, 2730, 63, 885, 63, 515, 9, 398, 327, 2790, 282, 14196, 14, 267, 327, 961, 6571, 2701, 4243, 370, 1924, 790, 12, 880, 626, 3734, 267, 327, 1750, 2897, 334, 305, 25068, 370, 1621, 41, 2897, 9, 365, 7688, 267, 327, 370, 1736, 14, 267, 1101, 275, 14196, 14, 11090, 15218, 8, 4322, 3126, 288, 283, 23334, 63, 633, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
DoubleNegativeVisualEffects/cortex
contrib/for_review/MayaOp/publishCamera-1.py
12
2773
import os import subprocess import IECore class MayaOp( IECore.Op ) : def __init__( self, description ) : IECore.Op.__init__( self, description, IECore.IntParameter( "result", "The return status.", 0 ) ) if self.mayaModule() is None : self.parameters().addParameters( [ IECore.FileNameParameter( name = "mayaFile", description = "The file to perform the publish from", defaultValue = "", check = IECore.FileNameParameter.CheckType.MustExist, extensions = "ma mb", ) ] ) def doOperation( self, args ) : if self.mayaModule() is None : # really we'd expect a maya wrapper to take care of this, # but just in case it isn't, make sure maya doesn't get # launched with the wrong version of python. env = os.environ.copy() del env["PYTHONHOME"] serialisedArgs = IECore.ParameterParser().serialise( self.parameters() ) # remove the mayaFile argument del serialisedArgs[:2] pythonCommands = [ "import IECore", "op = IECore.ClassLoader.defaultLoader( 'IECORE_OP_PATHS' ).load( '%s', %d )" % ( self.path, self.version ), "opInstance = op()", "IECore.ParameterParser().parse( %s, opInstance.parameters() )" % str( serialisedArgs ), "opInstance()", ] melCommand = ";\n".join( [ "python( \"%s\" )" % c for c in pythonCommands ] ) melCommand += ";\nquit -force;" f = open( "/tmp/test.mel", "w" ) f.write( melCommand + "\n" ) f.close() subprocess.check_call( [ "/software/maya/linux.centos6.x86_64/2012/bin/maya", "-batch", "-file", args["mayaFile"].value, "-script", "/tmp/test.mel" ], env = env ) return IECore.IntData( 0 ) else : return self.doMayaOperation( args ) def doMayaOperation( self, args ) : raise NotImplementedError __mayaModule = False @classmethod def mayaModule( cls ) : if cls.__mayaModule is False : try : cls.__mayaModule = __import__( "maya" ) except ImportError : cls.__mayaModule = None return cls.__mayaModule IECore.registerRunTimeTyped( MayaOp ) class publishCamera( MayaOp ) : def __init__( self ) : MayaOp.__init__( self, "I publish cameras" ) self.parameters().addParameters( [ IECore.FileNameParameter( name = "outputFile", description = "Where the camera will be published", defaultValue = "", allowEmptyString = False, ), ] ) def doMayaOperation( self, args ) : maya = self.mayaModule() camera = maya.cmds.ls( type="camera" ) maya.cmds.select( camera, replace=True ) maya.cmds.file( args["outputFile"].value, exportSelected=True, typ="mayaAscii" ) return IECore.IntData( 0 ) IECore.registerRunTimeTyped( publishCamera )
bsd-3-clause
[ 646, 747, 199, 646, 3873, 199, 199, 646, 14707, 199, 199, 533, 10162, 65, 4619, 8, 14707, 14, 4619, 776, 520, 421, 198, 318, 636, 826, 721, 291, 12, 1369, 776, 520, 28550, 198, 41, 13682, 14, 4619, 855, 826, 721, 291, 12, 1369, 12, 14707, 14, 3241, 4720, 8, 298, 1099, 401, 298, 1918, 372, 2004, 4765, 378, 221, 776, 776, 9068, 198, 692, 291, 14, 7551, 65, 2377, 342, 365, 488, 520, 26140, 198, 277, 14, 3214, 1252, 525, 5976, 8, 1585, 1585, 198, 59, 1871, 1871, 198, 41, 13682, 14, 7733, 4720, 8, 4671, 198, 354, 275, 298, 7551, 65, 1173, 401, 4671, 198, 1802, 275, 298, 1918, 570, 370, 5147, 314, 2780, 687, 401, 4671, 198, 28744, 275, 4873, 4671, 198, 1074, 275, 14707, 14, 7733, 4720, 14, 1799, 804, 14, 13757, 6439, 12, 4671, 198, 5359, 275, 298, 391, 21187, 401, 1871, 198, 9, 4671, 1585, 198, 61, 686, 198, 9, 8299, 198, 318, 886, 6044, 8, 291, 12, 1249, 776, 520, 28550, 198, 692, 291, 14, 7551, 65, 2377, 342, 365, 488, 520, 686, 686, 198, 3, 7710, 781, 5121, 4282, 282, 1443, 65, 4975, 370, 5452, 10296, 402, 642, 12, 686, 198, 3, 1325, 2951, 315, 1930, 652, 5712, 1133, 12, 1852, 3238, 1443, 65, 3181, 1133, 664, 686, 198, 3, 27725, 543, 314, 6835, 1015, 402, 2366, 14, 686, 198, 1813, 275, 747, 14, 2314, 14, 1574, 342, 686, 198, 2264, 2589, 905, 11720, 9524, 937, 686, 686, 198, 2171, 9096, 6213, 275, 14707, 14, 4720, 2842, 1252, 2171, 572, 8, 291, 14, 3214, 342, 776, 686, 198, 3, 2813, 314, 1443, 65, 1173, 1423, 686, 198, 2264, 3012, 9096, 6213, 1491, 18, 61, 686, 686, 198, 1548, 14680, 275, 359, 28932, 198, 2, 646, 14707, 401, 1585, 198, 2, 411, 275, 14707, 14, 2543, 5455, 14, 885, 5455, 8, 283, 41, 4220, 5788, 63, 1938, 63, 20202, 7, 7092, 912, 8, 1543, 83, 297, 450, 68, 776, 2, 450, 334, 291, 14, 515, 12, 291, 14, 1023, 2318, 1585, 198, 2, 411, 3244, 275, 1687, 24017, 1585, 198, 2, 41, 13682, 14, 4720, 2842, 1252, 1122, 8, 450, 83, 12, 1687, 3244, 14, 3214, 342, 776, 2, 450, 620, 8, 3012, 9096, 6213, 2318, 1585, 198, 2, 411, 3244, 24017, 686, 198, 61, 26140, 198, 26908, 3110, 275, 26243, 78, 1674, 904, 8, 359, 298, 1548, 8, 18321, 83, 4451, 776, 2, 450, 286, 367, 286, 315, 2366, 14680, 1622, 776, 686, 198, 26908, 3110, 847, 26243, 78, 10589, 446, 3990, 9426, 26140, 198, 70, 275, 1551, 8, 3286, 2791, 15, 396, 14, 26908, 401, 298, 87, 2, 776, 686, 198, 70, 14, 952, 8, 562, 76, 3110, 435, 1867, 78, 2, 776, 686, 198, 70, 14, 1600, 342, 26140, 198, 5781, 14, 1074, 63, 1250, 8, 359, 3286, 15619, 15, 7551, 65, 15, 5135, 14, 2497, 14543, 22, 14, 88, 1184, 63, 772, 15, 7409, 15, 1393, 15, 7551, 65, 401, 3905, 2912, 401, 3905, 493, 401, 1249, 905, 7551, 65, 1173, 4140, 585, 12, 3905, 1579, 401, 3286, 2791, 15, 396, 14, 26908, 2, 2156, 2589, 275, 2589, 776, 686, 686, 198, 1107, 14707, 14, 3241, 1451, 8, 378, 776, 1585, 507, 198, 2836, 520, 686, 686, 198, 1107, 291, 14, 1117, 15586, 65, 6044, 8, 1249, 776, 1585, 199, 198, 318, 886, 15586, 65, 6044, 8, 291, 12, 1249, 776, 520, 28550, 198, 3730, 4279, 18118, 198, 363, 7551, 65, 2377, 275, 756, 199, 198, 32, 3744, 199, 198, 318, 1443, 65, 2377, 8, 843, 776, 520, 28550, 198, 692, 843, 855, 7551, 65, 2377, 365, 756, 520, 686, 198, 893, 520, 1585, 198, 1886, 855, 7551, 65, 2377, 275, 636, 646, 721, 298, 7551, 65, 2, 776, 686, 198, 2590, 3545, 520, 1585, 198, 1886, 855, 7551, 65, 2377, 275, 488, 1871, 507, 198, 1107, 843, 855, 7551, 65, 2377, 199, 199, 41, 13682, 14, 2683, 2540, 1366, 22193, 8, 10162, 65, 4619, 776, 17344, 421, 199, 533, 2780, 18425, 8, 10162, 65, 4619, 776, 520, 421, 198, 318, 636, 826, 721, 291, 776, 520, 28550, 198, 15586, 65, 4619, 855, 826, 721, 291, 12, 298, 41, 2780, 20382, 6360, 2, 776, 9068, 198, 277, 14, 3214, 1252, 525, 5976, 8, 686, 686, 198, 59, 1585, 1585, 198, 41, 13682, 14, 7733, 4720, 8, 1871, 198, 354, 275, 298, 1199, 1173, 401, 1871, 198, 1802, 275, 298, 26493, 314, 15177, 911, 506, 3267, 401, 1871, 198, 28744, 275, 4873, 1871, 198, 3306, 4699, 1558, 275, 756, 12, 1585, 198, 395, 686, 686, 198, 61, 1585, 507, 198, 9, 18118, 198, 318, 886, 15586, 65, 6044, 8, 291, 12, 1249, 776, 520, 28550, 198, 7551, 65, 275, 291, 14, 7551, 65, 2377, 342, 507, 198, 11928, 275, 1443, 65, 14, 12975, 14, 478, 8, 730, 628, 11928, 2, 776, 507, 198, 7551, 65, 14, 12975, 14, 2416, 8, 15177, 12, 3350, 29, 549, 776, 507, 198, 7551, 65, 14, 12975, 14, 493, 8, 1249, 905, 1199, 1173, 4140, 585, 12, 4843, 12461, 29, 549, 12, 6211, 628, 7551, 65, 11129, 2, 776, 9068, 198, 1107, 14707, 14, 3241, 1451, 8, 378, 776, 686, 199, 41, 13682, 14, 2683, 2540, 1366, 22193, 8, 2780, 18425, 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 ]
[ 747, 199, 646, 3873, 199, 199, 646, 14707, 199, 199, 533, 10162, 65, 4619, 8, 14707, 14, 4619, 776, 520, 421, 198, 318, 636, 826, 721, 291, 12, 1369, 776, 520, 28550, 198, 41, 13682, 14, 4619, 855, 826, 721, 291, 12, 1369, 12, 14707, 14, 3241, 4720, 8, 298, 1099, 401, 298, 1918, 372, 2004, 4765, 378, 221, 776, 776, 9068, 198, 692, 291, 14, 7551, 65, 2377, 342, 365, 488, 520, 26140, 198, 277, 14, 3214, 1252, 525, 5976, 8, 1585, 1585, 198, 59, 1871, 1871, 198, 41, 13682, 14, 7733, 4720, 8, 4671, 198, 354, 275, 298, 7551, 65, 1173, 401, 4671, 198, 1802, 275, 298, 1918, 570, 370, 5147, 314, 2780, 687, 401, 4671, 198, 28744, 275, 4873, 4671, 198, 1074, 275, 14707, 14, 7733, 4720, 14, 1799, 804, 14, 13757, 6439, 12, 4671, 198, 5359, 275, 298, 391, 21187, 401, 1871, 198, 9, 4671, 1585, 198, 61, 686, 198, 9, 8299, 198, 318, 886, 6044, 8, 291, 12, 1249, 776, 520, 28550, 198, 692, 291, 14, 7551, 65, 2377, 342, 365, 488, 520, 686, 686, 198, 3, 7710, 781, 5121, 4282, 282, 1443, 65, 4975, 370, 5452, 10296, 402, 642, 12, 686, 198, 3, 1325, 2951, 315, 1930, 652, 5712, 1133, 12, 1852, 3238, 1443, 65, 3181, 1133, 664, 686, 198, 3, 27725, 543, 314, 6835, 1015, 402, 2366, 14, 686, 198, 1813, 275, 747, 14, 2314, 14, 1574, 342, 686, 198, 2264, 2589, 905, 11720, 9524, 937, 686, 686, 198, 2171, 9096, 6213, 275, 14707, 14, 4720, 2842, 1252, 2171, 572, 8, 291, 14, 3214, 342, 776, 686, 198, 3, 2813, 314, 1443, 65, 1173, 1423, 686, 198, 2264, 3012, 9096, 6213, 1491, 18, 61, 686, 686, 198, 1548, 14680, 275, 359, 28932, 198, 2, 646, 14707, 401, 1585, 198, 2, 411, 275, 14707, 14, 2543, 5455, 14, 885, 5455, 8, 283, 41, 4220, 5788, 63, 1938, 63, 20202, 7, 7092, 912, 8, 1543, 83, 297, 450, 68, 776, 2, 450, 334, 291, 14, 515, 12, 291, 14, 1023, 2318, 1585, 198, 2, 411, 3244, 275, 1687, 24017, 1585, 198, 2, 41, 13682, 14, 4720, 2842, 1252, 1122, 8, 450, 83, 12, 1687, 3244, 14, 3214, 342, 776, 2, 450, 620, 8, 3012, 9096, 6213, 2318, 1585, 198, 2, 411, 3244, 24017, 686, 198, 61, 26140, 198, 26908, 3110, 275, 26243, 78, 1674, 904, 8, 359, 298, 1548, 8, 18321, 83, 4451, 776, 2, 450, 286, 367, 286, 315, 2366, 14680, 1622, 776, 686, 198, 26908, 3110, 847, 26243, 78, 10589, 446, 3990, 9426, 26140, 198, 70, 275, 1551, 8, 3286, 2791, 15, 396, 14, 26908, 401, 298, 87, 2, 776, 686, 198, 70, 14, 952, 8, 562, 76, 3110, 435, 1867, 78, 2, 776, 686, 198, 70, 14, 1600, 342, 26140, 198, 5781, 14, 1074, 63, 1250, 8, 359, 3286, 15619, 15, 7551, 65, 15, 5135, 14, 2497, 14543, 22, 14, 88, 1184, 63, 772, 15, 7409, 15, 1393, 15, 7551, 65, 401, 3905, 2912, 401, 3905, 493, 401, 1249, 905, 7551, 65, 1173, 4140, 585, 12, 3905, 1579, 401, 3286, 2791, 15, 396, 14, 26908, 2, 2156, 2589, 275, 2589, 776, 686, 686, 198, 1107, 14707, 14, 3241, 1451, 8, 378, 776, 1585, 507, 198, 2836, 520, 686, 686, 198, 1107, 291, 14, 1117, 15586, 65, 6044, 8, 1249, 776, 1585, 199, 198, 318, 886, 15586, 65, 6044, 8, 291, 12, 1249, 776, 520, 28550, 198, 3730, 4279, 18118, 198, 363, 7551, 65, 2377, 275, 756, 199, 198, 32, 3744, 199, 198, 318, 1443, 65, 2377, 8, 843, 776, 520, 28550, 198, 692, 843, 855, 7551, 65, 2377, 365, 756, 520, 686, 198, 893, 520, 1585, 198, 1886, 855, 7551, 65, 2377, 275, 636, 646, 721, 298, 7551, 65, 2, 776, 686, 198, 2590, 3545, 520, 1585, 198, 1886, 855, 7551, 65, 2377, 275, 488, 1871, 507, 198, 1107, 843, 855, 7551, 65, 2377, 199, 199, 41, 13682, 14, 2683, 2540, 1366, 22193, 8, 10162, 65, 4619, 776, 17344, 421, 199, 533, 2780, 18425, 8, 10162, 65, 4619, 776, 520, 421, 198, 318, 636, 826, 721, 291, 776, 520, 28550, 198, 15586, 65, 4619, 855, 826, 721, 291, 12, 298, 41, 2780, 20382, 6360, 2, 776, 9068, 198, 277, 14, 3214, 1252, 525, 5976, 8, 686, 686, 198, 59, 1585, 1585, 198, 41, 13682, 14, 7733, 4720, 8, 1871, 198, 354, 275, 298, 1199, 1173, 401, 1871, 198, 1802, 275, 298, 26493, 314, 15177, 911, 506, 3267, 401, 1871, 198, 28744, 275, 4873, 1871, 198, 3306, 4699, 1558, 275, 756, 12, 1585, 198, 395, 686, 686, 198, 61, 1585, 507, 198, 9, 18118, 198, 318, 886, 15586, 65, 6044, 8, 291, 12, 1249, 776, 520, 28550, 198, 7551, 65, 275, 291, 14, 7551, 65, 2377, 342, 507, 198, 11928, 275, 1443, 65, 14, 12975, 14, 478, 8, 730, 628, 11928, 2, 776, 507, 198, 7551, 65, 14, 12975, 14, 2416, 8, 15177, 12, 3350, 29, 549, 776, 507, 198, 7551, 65, 14, 12975, 14, 493, 8, 1249, 905, 1199, 1173, 4140, 585, 12, 4843, 12461, 29, 549, 12, 6211, 628, 7551, 65, 11129, 2, 776, 9068, 198, 1107, 14707, 14, 3241, 1451, 8, 378, 776, 686, 199, 41, 13682, 14, 2683, 2540, 1366, 22193, 8, 2780, 18425, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
debugger06/MiroX
tv/lib/frontends/widgets/removefeeds.py
3
5512
# Miro - an RSS based video player application # Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 # Participatory Culture Foundation # # 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 St, Fifth Floor, Boston, MA 02110-1301 USA # # In addition, as a special exception, the copyright holders give # permission to link the code of portions of this program with the OpenSSL # library. # # You must obey the GNU General Public License in all respects for all of # the code used other than OpenSSL. If you modify file(s) with this # exception, you may extend this exception to your version of the file(s), # but you are not obligated to do so. If you do not wish to do so, delete # this exception statement from your version. If you delete this exception # statement from all source files in the program, then also delete it here. """Defines the "remove feeds" dialog.""" import logging from miro import app from miro import prefs from miro import util from miro.plat.frontends.widgets import widgetset from miro.frontends.widgets import widgetutil from miro.frontends.widgets.dialogs import MainDialog from miro.dialogs import BUTTON_CANCEL, BUTTON_REMOVE from miro.gtcache import gettext as _ from miro.gtcache import ngettext KEEP_ITEMS = "keep_items" def run_dialog(channel_infos, downloaded_items, downloading_items, has_watched_feeds): """Displays the remove feeds dialog. """ title = ngettext('Remove Podcast', 'Remove Podcasts', len(channel_infos)) rc_window = MainDialog(title) try: try: v = widgetset.VBox(spacing=5) lab = widgetset.Label(ngettext( "Are you sure you want to remove this podcast:", "Are you sure you want to remove these podcasts:", len(channel_infos) )) lab.set_wrap(True) v.pack_start(widgetutil.align_left(lab)) v2 = widgetset.VBox() lab_height = None for mem in channel_infos: lab_mem = widgetset.Label(util.clamp_text(mem.name, 40)) if lab_height is None: dummy, lab_height = lab_mem.get_size_request() v2.pack_start(widgetutil.align_left(lab_mem, left_pad=15)) if len(channel_infos) > 5: scroller = widgetset.Scroller(False, True) scroller.set_has_borders(True) scroller.add(v2) scroller_width, scroller_height = scroller.get_size_request() if scroller_height == 0: scroller.set_size_request(scroller_width, 5 * (lab_height + 1)) v2 = scroller v.pack_start(v2, padding=10) cbx_downloaded = None if downloaded_items: cbx_downloaded = widgetset.Checkbox(_( "Keep items that have been downloaded in my library.")) v.pack_start(widgetutil.align_left( cbx_downloaded, bottom_pad=5)) if has_watched_feeds: lab = widgetset.Label(_( "Watched folders will be removed from the sidebar but " "their contents will still appear in your library. " "You can stop watching watched folders completely " "in the %(appname)s preference panel.", {"appname": app.config.get(prefs.SHORT_APP_NAME)} )) lab.set_wrap(True) lab.set_size_request(390, -1) v.pack_start(widgetutil.align_left(lab, bottom_pad=5)) if downloading_items: lab_downloading = widgetset.Label(ngettext( "Are you sure you want to remove this podcast? " "The downloads currently in progress will be canceled.", "Are you sure you want to remove these podcasts? " "The downloads currently in progress will be canceled.", len(channel_infos) )) lab_downloading.set_wrap(True) lab_downloading.set_size_request(390, -1) v.pack_start(widgetutil.align_left(lab_downloading)) rc_window.set_extra_widget(v) rc_window.add_button(BUTTON_REMOVE.text) rc_window.add_button(BUTTON_CANCEL.text) ret = rc_window.run() if ret == 0: # this is silly, but it sets us up for adding additional # bits later. ret = {KEEP_ITEMS: False} if downloaded_items: ret[KEEP_ITEMS] = cbx_downloaded.get_checked() return ret except StandardError: logging.exception("removefeeds threw exception.") finally: rc_window.destroy()
gpl-2.0
[ 3, 603, 14352, 446, 376, 30331, 4079, 3991, 7748, 4223, 199, 3, 1898, 334, 35, 9, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 12, 7760, 199, 3, 2235, 10479, 8658, 445, 427, 608, 2752, 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, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 8217, 199, 3, 199, 3, 1010, 10234, 12, 465, 282, 4539, 1919, 12, 314, 4248, 31976, 8120, 199, 3, 4983, 370, 2142, 314, 1233, 402, 12468, 402, 642, 2240, 543, 314, 14296, 199, 3, 3555, 14, 199, 3, 199, 3, 2047, 1471, 312, 32236, 314, 1664, 1696, 1684, 844, 315, 1006, 14021, 83, 367, 1006, 402, 199, 3, 314, 1233, 1202, 1163, 2419, 14296, 14, 982, 1265, 2811, 570, 8, 83, 9, 543, 642, 199, 3, 1919, 12, 1265, 1443, 12247, 642, 1919, 370, 2195, 1015, 402, 314, 570, 8, 83, 395, 199, 3, 1325, 1265, 787, 440, 2607, 17506, 972, 370, 886, 880, 14, 982, 1265, 886, 440, 13809, 370, 886, 880, 12, 3145, 199, 3, 642, 1919, 5164, 687, 2195, 1015, 14, 982, 1265, 3145, 642, 1919, 199, 3, 5164, 687, 1006, 1350, 1584, 315, 314, 2240, 12, 2066, 2597, 3145, 652, 2348, 14, 199, 199, 624, 23891, 314, 298, 2168, 22295, 2, 9592, 1041, 199, 199, 646, 2050, 199, 199, 504, 10684, 293, 492, 1145, 199, 504, 10684, 293, 492, 28516, 199, 504, 10684, 293, 492, 4884, 199, 504, 10684, 293, 14, 14156, 14, 70, 2641, 724, 795, 14, 8583, 492, 3938, 409, 199, 504, 10684, 293, 14, 70, 2641, 724, 795, 14, 8583, 492, 3938, 1974, 199, 504, 10684, 293, 14, 70, 2641, 724, 795, 14, 8583, 14, 328, 18238, 492, 11298, 5619, 199, 504, 10684, 293, 14, 328, 18238, 492, 5400, 12143, 63, 20707, 12, 5400, 12143, 63, 25856, 199, 504, 10684, 293, 14, 3308, 1637, 492, 9796, 465, 485, 199, 504, 10684, 293, 14, 3308, 1637, 492, 29793, 199, 199, 32162, 63, 10439, 51, 275, 298, 3250, 63, 1744, 2, 199, 199, 318, 1255, 63, 7196, 8, 2775, 63, 14195, 12, 13557, 63, 1744, 12, 25937, 63, 1744, 12, 2049, 965, 63, 6821, 379, 63, 11522, 304, 272, 408, 2825, 20591, 314, 2813, 22295, 9592, 14, 272, 408, 272, 2538, 275, 29793, 360, 5587, 510, 364, 2931, 297, 283, 5587, 510, 364, 2931, 83, 297, 822, 8, 2775, 63, 14195, 430, 339, 4819, 63, 3806, 275, 11298, 5619, 8, 1213, 9, 272, 862, 26, 267, 862, 26, 288, 373, 275, 3938, 409, 14, 54, 3532, 8, 15880, 29, 21, 9, 953, 19888, 275, 3938, 409, 14, 4314, 8, 28234, 8, 355, 298, 17683, 1265, 3238, 1265, 2934, 370, 2813, 642, 15329, 2931, 6783, 355, 298, 17683, 1265, 3238, 1265, 2934, 370, 2813, 3520, 15329, 2931, 83, 6783, 355, 822, 8, 2775, 63, 14195, 9, 288, 5082, 288, 19888, 14, 409, 63, 3823, 8, 549, 9, 288, 373, 14, 1389, 63, 928, 8, 3440, 1974, 14, 5743, 63, 3039, 8, 5561, 430, 953, 373, 18, 275, 3938, 409, 14, 54, 3532, 342, 288, 19888, 63, 3333, 275, 488, 288, 367, 7573, 315, 3623, 63, 14195, 26, 355, 19888, 63, 5286, 275, 3938, 409, 14, 4314, 8, 1974, 14, 3995, 311, 63, 505, 8, 5286, 14, 354, 12, 6335, 430, 355, 340, 19888, 63, 3333, 365, 488, 26, 490, 7283, 12, 19888, 63, 3333, 275, 19888, 63, 5286, 14, 362, 63, 890, 63, 1069, 342, 355, 373, 18, 14, 1389, 63, 928, 8, 3440, 1974, 14, 5743, 63, 3039, 8, 5561, 63, 5286, 12, 3602, 63, 6226, 29, 1046, 430, 953, 340, 822, 8, 2775, 63, 14195, 9, 690, 959, 26, 355, 4061, 8459, 1435, 275, 3938, 409, 14, 7181, 8459, 1435, 8, 797, 12, 715, 9, 355, 4061, 8459, 1435, 14, 409, 63, 1989, 63, 8665, 83, 8, 549, 9, 355, 4061, 8459, 1435, 14, 525, 8, 86, 18, 9, 355, 4061, 8459, 1435, 63, 2063, 12, 4061, 8459, 1435, 63, 3333, 275, 4061, 8459, 1435, 14, 362, 63, 890, 63, 1069, 342, 355, 340, 4061, 8459, 1435, 63, 3333, 508, 378, 26, 490, 4061, 8459, 1435, 14, 409, 63, 890, 63, 1069, 8, 551, 8459, 1435, 63, 2063, 12, 6343, 959, 627, 334, 5561, 63, 3333, 435, 413, 430, 355, 373, 18, 275, 4061, 8459, 1435, 288, 373, 14, 1389, 63, 928, 8, 86, 18, 12, 6273, 29, 709, 9, 953, 7434, 88, 63, 19385, 275, 488, 288, 340, 13557, 63, 1744, 26, 355, 7434, 88, 63, 19385, 275, 3938, 409, 14, 26366, 27594, 717, 298, 18567, 2974, 626, 1172, 2757, 13557, 315, 3002, 3555, 13853, 355, 373, 14, 1389, 63, 928, 8, 3440, 1974, 14, 5743, 63, 3039, 8, 717, 7434, 88, 63, 19385, 12, 9048, 63, 6226, 29, 21, 430, 953, 340, 965, 63, 6821, 379, 63, 11522, 26, 355, 19888, 275, 3938, 409, 14, 4314, 27594, 490, 298, 13978, 379, 16533, 911, 506, 4829, 687, 314, 18437, 1325, 298, 490, 298, 1589, 723, 4072, 911, 5139, 7468, 315, 2195, 3555, 14, 221, 298, 490, 298, 5556, 883, 3631, 9626, 316, 9626, 379, 16533, 14793, 298, 490, 298, 262, 314, 2818, 21653, 9, 83, 16705, 12748, 4765, 490, 2420, 21653, 582, 1145, 14, 888, 14, 362, 8, 17253, 14, 13003, 63, 7121, 63, 2339, 6769, 355, 5082, 355, 19888, 14, 409, 63, 3823, 8, 549 ]
[ 603, 14352, 446, 376, 30331, 4079, 3991, 7748, 4223, 199, 3, 1898, 334, 35, 9, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 12, 7760, 199, 3, 2235, 10479, 8658, 445, 427, 608, 2752, 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, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 8217, 199, 3, 199, 3, 1010, 10234, 12, 465, 282, 4539, 1919, 12, 314, 4248, 31976, 8120, 199, 3, 4983, 370, 2142, 314, 1233, 402, 12468, 402, 642, 2240, 543, 314, 14296, 199, 3, 3555, 14, 199, 3, 199, 3, 2047, 1471, 312, 32236, 314, 1664, 1696, 1684, 844, 315, 1006, 14021, 83, 367, 1006, 402, 199, 3, 314, 1233, 1202, 1163, 2419, 14296, 14, 982, 1265, 2811, 570, 8, 83, 9, 543, 642, 199, 3, 1919, 12, 1265, 1443, 12247, 642, 1919, 370, 2195, 1015, 402, 314, 570, 8, 83, 395, 199, 3, 1325, 1265, 787, 440, 2607, 17506, 972, 370, 886, 880, 14, 982, 1265, 886, 440, 13809, 370, 886, 880, 12, 3145, 199, 3, 642, 1919, 5164, 687, 2195, 1015, 14, 982, 1265, 3145, 642, 1919, 199, 3, 5164, 687, 1006, 1350, 1584, 315, 314, 2240, 12, 2066, 2597, 3145, 652, 2348, 14, 199, 199, 624, 23891, 314, 298, 2168, 22295, 2, 9592, 1041, 199, 199, 646, 2050, 199, 199, 504, 10684, 293, 492, 1145, 199, 504, 10684, 293, 492, 28516, 199, 504, 10684, 293, 492, 4884, 199, 504, 10684, 293, 14, 14156, 14, 70, 2641, 724, 795, 14, 8583, 492, 3938, 409, 199, 504, 10684, 293, 14, 70, 2641, 724, 795, 14, 8583, 492, 3938, 1974, 199, 504, 10684, 293, 14, 70, 2641, 724, 795, 14, 8583, 14, 328, 18238, 492, 11298, 5619, 199, 504, 10684, 293, 14, 328, 18238, 492, 5400, 12143, 63, 20707, 12, 5400, 12143, 63, 25856, 199, 504, 10684, 293, 14, 3308, 1637, 492, 9796, 465, 485, 199, 504, 10684, 293, 14, 3308, 1637, 492, 29793, 199, 199, 32162, 63, 10439, 51, 275, 298, 3250, 63, 1744, 2, 199, 199, 318, 1255, 63, 7196, 8, 2775, 63, 14195, 12, 13557, 63, 1744, 12, 25937, 63, 1744, 12, 2049, 965, 63, 6821, 379, 63, 11522, 304, 272, 408, 2825, 20591, 314, 2813, 22295, 9592, 14, 272, 408, 272, 2538, 275, 29793, 360, 5587, 510, 364, 2931, 297, 283, 5587, 510, 364, 2931, 83, 297, 822, 8, 2775, 63, 14195, 430, 339, 4819, 63, 3806, 275, 11298, 5619, 8, 1213, 9, 272, 862, 26, 267, 862, 26, 288, 373, 275, 3938, 409, 14, 54, 3532, 8, 15880, 29, 21, 9, 953, 19888, 275, 3938, 409, 14, 4314, 8, 28234, 8, 355, 298, 17683, 1265, 3238, 1265, 2934, 370, 2813, 642, 15329, 2931, 6783, 355, 298, 17683, 1265, 3238, 1265, 2934, 370, 2813, 3520, 15329, 2931, 83, 6783, 355, 822, 8, 2775, 63, 14195, 9, 288, 5082, 288, 19888, 14, 409, 63, 3823, 8, 549, 9, 288, 373, 14, 1389, 63, 928, 8, 3440, 1974, 14, 5743, 63, 3039, 8, 5561, 430, 953, 373, 18, 275, 3938, 409, 14, 54, 3532, 342, 288, 19888, 63, 3333, 275, 488, 288, 367, 7573, 315, 3623, 63, 14195, 26, 355, 19888, 63, 5286, 275, 3938, 409, 14, 4314, 8, 1974, 14, 3995, 311, 63, 505, 8, 5286, 14, 354, 12, 6335, 430, 355, 340, 19888, 63, 3333, 365, 488, 26, 490, 7283, 12, 19888, 63, 3333, 275, 19888, 63, 5286, 14, 362, 63, 890, 63, 1069, 342, 355, 373, 18, 14, 1389, 63, 928, 8, 3440, 1974, 14, 5743, 63, 3039, 8, 5561, 63, 5286, 12, 3602, 63, 6226, 29, 1046, 430, 953, 340, 822, 8, 2775, 63, 14195, 9, 690, 959, 26, 355, 4061, 8459, 1435, 275, 3938, 409, 14, 7181, 8459, 1435, 8, 797, 12, 715, 9, 355, 4061, 8459, 1435, 14, 409, 63, 1989, 63, 8665, 83, 8, 549, 9, 355, 4061, 8459, 1435, 14, 525, 8, 86, 18, 9, 355, 4061, 8459, 1435, 63, 2063, 12, 4061, 8459, 1435, 63, 3333, 275, 4061, 8459, 1435, 14, 362, 63, 890, 63, 1069, 342, 355, 340, 4061, 8459, 1435, 63, 3333, 508, 378, 26, 490, 4061, 8459, 1435, 14, 409, 63, 890, 63, 1069, 8, 551, 8459, 1435, 63, 2063, 12, 6343, 959, 627, 334, 5561, 63, 3333, 435, 413, 430, 355, 373, 18, 275, 4061, 8459, 1435, 288, 373, 14, 1389, 63, 928, 8, 86, 18, 12, 6273, 29, 709, 9, 953, 7434, 88, 63, 19385, 275, 488, 288, 340, 13557, 63, 1744, 26, 355, 7434, 88, 63, 19385, 275, 3938, 409, 14, 26366, 27594, 717, 298, 18567, 2974, 626, 1172, 2757, 13557, 315, 3002, 3555, 13853, 355, 373, 14, 1389, 63, 928, 8, 3440, 1974, 14, 5743, 63, 3039, 8, 717, 7434, 88, 63, 19385, 12, 9048, 63, 6226, 29, 21, 430, 953, 340, 965, 63, 6821, 379, 63, 11522, 26, 355, 19888, 275, 3938, 409, 14, 4314, 27594, 490, 298, 13978, 379, 16533, 911, 506, 4829, 687, 314, 18437, 1325, 298, 490, 298, 1589, 723, 4072, 911, 5139, 7468, 315, 2195, 3555, 14, 221, 298, 490, 298, 5556, 883, 3631, 9626, 316, 9626, 379, 16533, 14793, 298, 490, 298, 262, 314, 2818, 21653, 9, 83, 16705, 12748, 4765, 490, 2420, 21653, 582, 1145, 14, 888, 14, 362, 8, 17253, 14, 13003, 63, 7121, 63, 2339, 6769, 355, 5082, 355, 19888, 14, 409, 63, 3823, 8, 549, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
elventear/txamqp
src/txamqp/test/test_queue.py
4
11353
# # 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. # from txamqp.client import Closed from txamqp.content import Content from txamqp.testlib import TestBase, supportedBrokers, QPID, OPENAMQ from twisted.internet.defer import inlineCallbacks class QueueTests(TestBase): """Tests for 'methods' on the amqp queue 'class'""" @supportedBrokers(QPID, OPENAMQ) @inlineCallbacks def test_purge(self): """ Test that the purge method removes messages from the queue """ channel = self.channel #setup, declare a queue and add some messages to it: yield channel.exchange_declare(exchange="test-exchange", type="direct") yield channel.queue_declare(queue="test-queue", exclusive=True) yield channel.queue_bind(queue="test-queue", exchange="test-exchange", routing_key="key") channel.basic_publish(exchange="test-exchange", routing_key="key", content=Content("one")) channel.basic_publish(exchange="test-exchange", routing_key="key", content=Content("two")) channel.basic_publish(exchange="test-exchange", routing_key="key", content=Content("three")) #check that the queue now reports 3 messages: reply = yield channel.queue_declare(queue="test-queue") self.assertEqual(3, reply.message_count) #now do the purge, then test that three messages are purged and the count drops to 0 reply = yield channel.queue_purge(queue="test-queue"); self.assertEqual(3, reply.message_count) reply = yield channel.queue_declare(queue="test-queue") self.assertEqual(0, reply.message_count) #send a further message and consume it, ensuring that the other messages are really gone channel.basic_publish(exchange="test-exchange", routing_key="key", content=Content("four")) reply = yield channel.basic_consume(queue="test-queue", no_ack=True) queue = yield self.client.queue(reply.consumer_tag) msg = yield queue.get(timeout=1) self.assertEqual("four", msg.content.body) #check error conditions (use new channels): channel = yield self.client.channel(2) yield channel.channel_open() try: #queue specified but doesn't exist: yield channel.queue_purge(queue="invalid-queue") self.fail("Expected failure when purging non-existent queue") except Closed, e: self.assertChannelException(404, e.args[0]) channel = yield self.client.channel(3) yield channel.channel_open() try: #queue not specified and none previously declared for channel: yield channel.queue_purge() self.fail("Expected failure when purging unspecified queue") except Closed, e: self.assertConnectionException(530, e.args[0]) #cleanup other = yield self.connect() channel = yield other.channel(1) yield channel.channel_open() yield channel.exchange_delete(exchange="test-exchange") @inlineCallbacks def test_declare_exclusive(self): """ Test that the exclusive field is honoured in queue.declare """ # TestBase.setUp has already opened channel(1) c1 = self.channel # Here we open a second separate connection: other = yield self.connect() c2 = yield other.channel(1) yield c2.channel_open() #declare an exclusive queue: yield c1.queue_declare(queue="exclusive-queue", exclusive="True") try: #other connection should not be allowed to declare this: yield c2.queue_declare(queue="exclusive-queue", exclusive="True") self.fail("Expected second exclusive queue_declare to raise a channel exception") except Closed, e: self.assertChannelException(405, e.args[0]) @inlineCallbacks def test_declare_passive(self): """ Test that the passive field is honoured in queue.declare """ channel = self.channel #declare an exclusive queue: yield channel.queue_declare(queue="passive-queue-1", exclusive="True") yield channel.queue_declare(queue="passive-queue-1", passive="True") try: #other connection should not be allowed to declare this: yield channel.queue_declare(queue="passive-queue-2", passive="True") self.fail("Expected passive declaration of non-existant queue to raise a channel exception") except Closed, e: self.assertChannelException(404, e.args[0]) @inlineCallbacks def test_bind(self): """ Test various permutations of the queue.bind method """ channel = self.channel yield channel.queue_declare(queue="queue-1", exclusive="True") #straightforward case, both exchange & queue exist so no errors expected: yield channel.queue_bind(queue="queue-1", exchange="amq.direct", routing_key="key1") #bind the default queue for the channel (i.e. last one declared): yield channel.queue_bind(exchange="amq.direct", routing_key="key2") #use the queue name where neither routing key nor queue are specified: yield channel.queue_bind(exchange="amq.direct") #try and bind to non-existant exchange try: yield channel.queue_bind(queue="queue-1", exchange="an-invalid-exchange", routing_key="key1") self.fail("Expected bind to non-existant exchange to fail") except Closed, e: self.assertChannelException(404, e.args[0]) #need to reopen a channel: channel = yield self.client.channel(2) yield channel.channel_open() #try and bind non-existant queue: try: yield channel.queue_bind(queue="queue-2", exchange="amq.direct", routing_key="key1") self.fail("Expected bind of non-existant queue to fail") except Closed, e: self.assertChannelException(404, e.args[0]) @inlineCallbacks def test_delete_simple(self): """ Test basic queue deletion """ channel = self.channel #straight-forward case: yield channel.queue_declare(queue="delete-me") channel.basic_publish(routing_key="delete-me", content=Content("a")) channel.basic_publish(routing_key="delete-me", content=Content("b")) channel.basic_publish(routing_key="delete-me", content=Content("c")) reply = yield channel.queue_delete(queue="delete-me") self.assertEqual(3, reply.message_count) #check that it has gone be declaring passively try: yield channel.queue_declare(queue="delete-me", passive="True") self.fail("Queue has not been deleted") except Closed, e: self.assertChannelException(404, e.args[0]) #check attempted deletion of non-existant queue is handled correctly: channel = yield self.client.channel(2) yield channel.channel_open() try: yield channel.queue_delete(queue="i-dont-exist", if_empty="True") self.fail("Expected delete of non-existant queue to fail") except Closed, e: self.assertChannelException(404, e.args[0]) @inlineCallbacks def test_delete_ifempty(self): """ Test that if_empty field of queue_delete is honoured """ channel = self.channel #create a queue and add a message to it (use default binding): yield channel.queue_declare(queue="delete-me-2") yield channel.queue_declare(queue="delete-me-2", passive="True") channel.basic_publish(routing_key="delete-me-2", content=Content("message")) #try to delete, but only if empty: try: yield channel.queue_delete(queue="delete-me-2", if_empty="True") self.fail("Expected delete if_empty to fail for non-empty queue") except Closed, e: self.assertChannelException(406, e.args[0]) #need new channel now: channel = yield self.client.channel(2) yield channel.channel_open() #empty queue: reply = yield channel.basic_consume(queue="delete-me-2", no_ack=True) queue = yield self.client.queue(reply.consumer_tag) msg = yield queue.get(timeout=1) self.assertEqual("message", msg.content.body) yield channel.basic_cancel(consumer_tag=reply.consumer_tag) #retry deletion on empty queue: yield channel.queue_delete(queue="delete-me-2", if_empty="True") #check that it has gone by declaring passively: try: yield channel.queue_declare(queue="delete-me-2", passive="True") self.fail("Queue has not been deleted") except Closed, e: self.assertChannelException(404, e.args[0]) @inlineCallbacks def test_delete_ifunused(self): """ Test that if_unused field of queue_delete is honoured """ channel = self.channel #create a queue and register a consumer: yield channel.queue_declare(queue="delete-me-3") yield channel.queue_declare(queue="delete-me-3", passive="True") reply = yield channel.basic_consume(queue="delete-me-3", no_ack=True) #need new channel now: channel2 = yield self.client.channel(2) yield channel2.channel_open() #try to delete, but only if empty: try: yield channel2.queue_delete(queue="delete-me-3", if_unused="True") self.fail("Expected delete if_unused to fail for queue with existing consumer") except Closed, e: self.assertChannelException(406, e.args[0]) yield channel.basic_cancel(consumer_tag=reply.consumer_tag) yield channel.queue_delete(queue="delete-me-3", if_unused="True") #check that it has gone by declaring passively: try: yield channel.queue_declare(queue="delete-me-3", passive="True") self.fail("Queue has not been deleted") except Closed, e: self.assertChannelException(404, e.args[0]) @inlineCallbacks def test_close_queue(self): from txamqp.queue import Closed as QueueClosed channel = self.channel reply = yield channel.queue_declare(queue="test-queue") reply = yield channel.basic_consume(queue="test-queue") queue = yield self.client.queue(reply.consumer_tag) d = self.assertFailure(queue.get(timeout=1), QueueClosed) self.client.close(None) yield d
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 504, 4773, 455, 15202, 14, 1258, 492, 5980, 939, 199, 504, 4773, 455, 15202, 14, 1317, 492, 6646, 199, 504, 4773, 455, 15202, 14, 396, 773, 492, 1379, 1563, 12, 3748, 34, 29275, 1192, 12, 1413, 16098, 12, 24164, 1156, 49, 199, 199, 504, 7390, 14, 4901, 14, 11610, 492, 8308, 17958, 199, 199, 533, 10703, 2925, 8, 14440, 304, 272, 408, 2925, 367, 283, 2474, 7, 641, 314, 8140, 15202, 4126, 283, 533, 26555, 339, 768, 4946, 34, 29275, 1192, 8, 49, 16098, 12, 24164, 1156, 49, 9, 272, 768, 24813, 272, 347, 511, 63, 18254, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 18503, 1083, 14185, 3788, 687, 314, 4126, 267, 408, 267, 3623, 275, 291, 14, 2775, 267, 327, 2758, 12, 20771, 282, 4126, 436, 1050, 2005, 3788, 370, 652, 26, 267, 1995, 3623, 14, 14197, 63, 16536, 8, 14197, 628, 396, 13, 14197, 401, 730, 628, 2275, 531, 267, 1995, 3623, 14, 1825, 63, 16536, 8, 1825, 628, 396, 13, 1825, 401, 13914, 29, 549, 9, 267, 1995, 3623, 14, 1825, 63, 3409, 8, 1825, 628, 396, 13, 1825, 401, 15343, 628, 396, 13, 14197, 401, 14870, 63, 498, 628, 498, 531, 267, 3623, 14, 4316, 63, 4763, 8, 14197, 628, 396, 13, 14197, 401, 14870, 63, 498, 628, 498, 401, 1564, 29, 2714, 480, 368, 2237, 267, 3623, 14, 4316, 63, 4763, 8, 14197, 628, 396, 13, 14197, 401, 14870, 63, 498, 628, 498, 401, 1564, 29, 2714, 480, 5601, 2237, 267, 3623, 14, 4316, 63, 4763, 8, 14197, 628, 396, 13, 14197, 401, 14870, 63, 498, 628, 498, 401, 1564, 29, 2714, 480, 10480, 2237, 398, 327, 1074, 626, 314, 4126, 3063, 13924, 650, 3788, 26, 267, 9351, 275, 1995, 3623, 14, 1825, 63, 16536, 8, 1825, 628, 396, 13, 1825, 531, 267, 291, 14, 629, 8, 19, 12, 9351, 14, 1188, 63, 835, 9, 398, 327, 2131, 886, 314, 18503, 12, 2066, 511, 626, 7795, 3788, 787, 5861, 3046, 436, 314, 2338, 366, 26307, 370, 378, 267, 9351, 275, 1995, 3623, 14, 1825, 63, 18254, 8, 1825, 628, 396, 13, 1825, 3547, 267, 291, 14, 629, 8, 19, 12, 9351, 14, 1188, 63, 835, 9, 267, 9351, 275, 1995, 3623, 14, 1825, 63, 16536, 8, 1825, 628, 396, 13, 1825, 531, 267, 291, 14, 629, 8, 16, 12, 9351, 14, 1188, 63, 835, 9, 398, 327, 2254, 282, 9848, 1245, 436, 9451, 652, 12, 12889, 4039, 626, 314, 1163, 3788, 787, 7710, 21737, 267, 3623, 14, 4316, 63, 4763, 8, 14197, 628, 396, 13, 14197, 401, 14870, 63, 498, 628, 498, 401, 1564, 29, 2714, 480, 13672, 2237, 267, 9351, 275, 1995, 3623, 14, 4316, 63, 10235, 8, 1825, 628, 396, 13, 1825, 401, 949, 63, 564, 29, 549, 9, 267, 4126, 275, 1995, 291, 14, 1258, 14, 1825, 8, 8102, 14, 8542, 63, 1450, 9, 267, 1499, 275, 1995, 4126, 14, 362, 8, 2593, 29, 17, 9, 267, 291, 14, 629, 480, 13672, 401, 1499, 14, 1317, 14, 2030, 9, 398, 327, 1074, 1125, 3704, 334, 1180, 892, 9245, 304, 267, 3623, 275, 1995, 291, 14, 1258, 14, 2775, 8, 18, 9, 267, 1995, 3623, 14, 2775, 63, 1490, 342, 267, 862, 26, 288, 327, 1825, 2013, 1325, 3181, 1133, 2187, 26, 288, 1995, 3623, 14, 1825, 63, 18254, 8, 1825, 628, 3197, 13, 1825, 531, 288, 291, 14, 1633, 480, 6964, 5988, 1380, 5861, 1540, 2222, 13, 15025, 4126, 531, 267, 871, 5980, 939, 12, 325, 26, 288, 291, 14, 479, 5358, 1726, 8, 5188, 12, 325, 14, 589, 59, 16, 566, 398, 3623, 275, 1995, 291, 14, 1258, 14, 2775, 8, 19, 9, 267, 1995, 3623, 14, 2775, 63, 1490, 342, 267, 862, 26, 288, 327, 1825, 440, 2013, 436, 7179, 10889, 14290, 367, 3623, 26, 288, 1995, 3623, 14, 1825, 63, 18254, 342, 288, 291, 14, 1633, 480, 6964, 5988, 1380, 5861, 1540, 21994, 4126, 531, 267, 871, 5980, 939, 12, 325, 26, 288, 291, 14, 479, 3225, 1726, 8, 27030, 12, 325, 14, 589, 59, 16, 566, 398, 327, 7661, 267, 1163, 275, 1995, 291, 14, 2242, 342, 267, 3623, 275, 1995, 1163, 14, 2775, 8, 17, 9, 267, 1995, 3623, 14, 2775, 63, 1490, 342, 267, 1995, 3623, 14, 14197, 63, 1807, 8, 14197, 628, 396, 13, 14197, 531, 339, 768, 24813, 272, 347, 511, 63, 16536, 63, 12730, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 13914, 901, 365, 394, 265, 810, 581, 315, 4126, 14, 16536, 267, 408, 267, 327, 1379, 1563, 14, 5996, 965, 2575, 12123, 3623, 8, 17, 9, 267, 286, 17, 275, 291, 14, 2775, 267, 327, 11842, 781, 1551, 282, 3499, 7396, 1950, 26, 267, 1163, 275, 1995, 291, 14, 2242, 342, 267, 286, 18, 275, 1995, 1163, 14, 2775, 8, 17, 9, 267, 1995, 286, 18, 14, 2775, 63, 1490, 342, 398, 327, 16536, 376, 13914, 4126, 26, 267, 1995, 286, 17, 14, 1825, 63, 16536, 8, 1825, 628, 12730, 13, 1825, 401, 13914, 628, 549, 531, 267, 862, 26, 288, 327, 1848, 1950, 1077, 440, 506 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 504, 4773, 455, 15202, 14, 1258, 492, 5980, 939, 199, 504, 4773, 455, 15202, 14, 1317, 492, 6646, 199, 504, 4773, 455, 15202, 14, 396, 773, 492, 1379, 1563, 12, 3748, 34, 29275, 1192, 12, 1413, 16098, 12, 24164, 1156, 49, 199, 199, 504, 7390, 14, 4901, 14, 11610, 492, 8308, 17958, 199, 199, 533, 10703, 2925, 8, 14440, 304, 272, 408, 2925, 367, 283, 2474, 7, 641, 314, 8140, 15202, 4126, 283, 533, 26555, 339, 768, 4946, 34, 29275, 1192, 8, 49, 16098, 12, 24164, 1156, 49, 9, 272, 768, 24813, 272, 347, 511, 63, 18254, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 18503, 1083, 14185, 3788, 687, 314, 4126, 267, 408, 267, 3623, 275, 291, 14, 2775, 267, 327, 2758, 12, 20771, 282, 4126, 436, 1050, 2005, 3788, 370, 652, 26, 267, 1995, 3623, 14, 14197, 63, 16536, 8, 14197, 628, 396, 13, 14197, 401, 730, 628, 2275, 531, 267, 1995, 3623, 14, 1825, 63, 16536, 8, 1825, 628, 396, 13, 1825, 401, 13914, 29, 549, 9, 267, 1995, 3623, 14, 1825, 63, 3409, 8, 1825, 628, 396, 13, 1825, 401, 15343, 628, 396, 13, 14197, 401, 14870, 63, 498, 628, 498, 531, 267, 3623, 14, 4316, 63, 4763, 8, 14197, 628, 396, 13, 14197, 401, 14870, 63, 498, 628, 498, 401, 1564, 29, 2714, 480, 368, 2237, 267, 3623, 14, 4316, 63, 4763, 8, 14197, 628, 396, 13, 14197, 401, 14870, 63, 498, 628, 498, 401, 1564, 29, 2714, 480, 5601, 2237, 267, 3623, 14, 4316, 63, 4763, 8, 14197, 628, 396, 13, 14197, 401, 14870, 63, 498, 628, 498, 401, 1564, 29, 2714, 480, 10480, 2237, 398, 327, 1074, 626, 314, 4126, 3063, 13924, 650, 3788, 26, 267, 9351, 275, 1995, 3623, 14, 1825, 63, 16536, 8, 1825, 628, 396, 13, 1825, 531, 267, 291, 14, 629, 8, 19, 12, 9351, 14, 1188, 63, 835, 9, 398, 327, 2131, 886, 314, 18503, 12, 2066, 511, 626, 7795, 3788, 787, 5861, 3046, 436, 314, 2338, 366, 26307, 370, 378, 267, 9351, 275, 1995, 3623, 14, 1825, 63, 18254, 8, 1825, 628, 396, 13, 1825, 3547, 267, 291, 14, 629, 8, 19, 12, 9351, 14, 1188, 63, 835, 9, 267, 9351, 275, 1995, 3623, 14, 1825, 63, 16536, 8, 1825, 628, 396, 13, 1825, 531, 267, 291, 14, 629, 8, 16, 12, 9351, 14, 1188, 63, 835, 9, 398, 327, 2254, 282, 9848, 1245, 436, 9451, 652, 12, 12889, 4039, 626, 314, 1163, 3788, 787, 7710, 21737, 267, 3623, 14, 4316, 63, 4763, 8, 14197, 628, 396, 13, 14197, 401, 14870, 63, 498, 628, 498, 401, 1564, 29, 2714, 480, 13672, 2237, 267, 9351, 275, 1995, 3623, 14, 4316, 63, 10235, 8, 1825, 628, 396, 13, 1825, 401, 949, 63, 564, 29, 549, 9, 267, 4126, 275, 1995, 291, 14, 1258, 14, 1825, 8, 8102, 14, 8542, 63, 1450, 9, 267, 1499, 275, 1995, 4126, 14, 362, 8, 2593, 29, 17, 9, 267, 291, 14, 629, 480, 13672, 401, 1499, 14, 1317, 14, 2030, 9, 398, 327, 1074, 1125, 3704, 334, 1180, 892, 9245, 304, 267, 3623, 275, 1995, 291, 14, 1258, 14, 2775, 8, 18, 9, 267, 1995, 3623, 14, 2775, 63, 1490, 342, 267, 862, 26, 288, 327, 1825, 2013, 1325, 3181, 1133, 2187, 26, 288, 1995, 3623, 14, 1825, 63, 18254, 8, 1825, 628, 3197, 13, 1825, 531, 288, 291, 14, 1633, 480, 6964, 5988, 1380, 5861, 1540, 2222, 13, 15025, 4126, 531, 267, 871, 5980, 939, 12, 325, 26, 288, 291, 14, 479, 5358, 1726, 8, 5188, 12, 325, 14, 589, 59, 16, 566, 398, 3623, 275, 1995, 291, 14, 1258, 14, 2775, 8, 19, 9, 267, 1995, 3623, 14, 2775, 63, 1490, 342, 267, 862, 26, 288, 327, 1825, 440, 2013, 436, 7179, 10889, 14290, 367, 3623, 26, 288, 1995, 3623, 14, 1825, 63, 18254, 342, 288, 291, 14, 1633, 480, 6964, 5988, 1380, 5861, 1540, 21994, 4126, 531, 267, 871, 5980, 939, 12, 325, 26, 288, 291, 14, 479, 3225, 1726, 8, 27030, 12, 325, 14, 589, 59, 16, 566, 398, 327, 7661, 267, 1163, 275, 1995, 291, 14, 2242, 342, 267, 3623, 275, 1995, 1163, 14, 2775, 8, 17, 9, 267, 1995, 3623, 14, 2775, 63, 1490, 342, 267, 1995, 3623, 14, 14197, 63, 1807, 8, 14197, 628, 396, 13, 14197, 531, 339, 768, 24813, 272, 347, 511, 63, 16536, 63, 12730, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 13914, 901, 365, 394, 265, 810, 581, 315, 4126, 14, 16536, 267, 408, 267, 327, 1379, 1563, 14, 5996, 965, 2575, 12123, 3623, 8, 17, 9, 267, 286, 17, 275, 291, 14, 2775, 267, 327, 11842, 781, 1551, 282, 3499, 7396, 1950, 26, 267, 1163, 275, 1995, 291, 14, 2242, 342, 267, 286, 18, 275, 1995, 1163, 14, 2775, 8, 17, 9, 267, 1995, 286, 18, 14, 2775, 63, 1490, 342, 398, 327, 16536, 376, 13914, 4126, 26, 267, 1995, 286, 17, 14, 1825, 63, 16536, 8, 1825, 628, 12730, 13, 1825, 401, 13914, 628, 549, 531, 267, 862, 26, 288, 327, 1848, 1950, 1077, 440, 506, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
chessco/cursus
modules/data_source_providers/synchronous_providers.py
7
20506
# Copyright 2012 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS-IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Provide data sources performing synchronous (non-paginated) reads.""" __author__ = 'Sean Lip (sll@google.com)' import logging import urlparse from common import safe_dom from models import courses from models import data_sources from models import jobs from models import progress from models import transforms from models import utils as models_utils from models.models import EventEntity from models.models import Student from models.models import StudentPropertyEntity class StudentEnrollmentAndScoresGenerator(jobs.DurableJob): """A job that computes student statistics.""" @staticmethod def get_description(): return 'student enrollment and scores' class ScoresAggregator(object): """Aggregates scores statistics.""" def __init__(self): # We store all data as tuples keyed by the assessment type name. # Each tuple keeps: # (student_count, sum(score)) self.name_to_tuple = {} def visit(self, student): if student.scores: scores = transforms.loads(student.scores) for key in scores.keys(): if key in self.name_to_tuple: count = self.name_to_tuple[key][0] score_sum = self.name_to_tuple[key][1] else: count = 0 score_sum = 0 self.name_to_tuple[key] = ( count + 1, score_sum + float(scores[key])) class EnrollmentAggregator(object): """Aggregates enrollment statistics.""" def __init__(self): self.enrolled = 0 self.unenrolled = 0 def visit(self, student): if student.is_enrolled: self.enrolled += 1 else: self.unenrolled += 1 def run(self): """Computes student statistics.""" enrollment = self.EnrollmentAggregator() scores = self.ScoresAggregator() mapper = models_utils.QueryMapper( Student.all(), batch_size=500, report_every=1000) def map_fn(student): enrollment.visit(student) scores.visit(student) mapper.run(map_fn) data = { 'enrollment': { 'enrolled': enrollment.enrolled, 'unenrolled': enrollment.unenrolled}, 'scores': scores.name_to_tuple} return data class StudentEnrollmentAndScoresSource(data_sources.SynchronousQuery): """Shows student enrollment analytics on the dashboard.""" @staticmethod def required_generators(): return [StudentEnrollmentAndScoresGenerator] @staticmethod def fill_values(app_context, template_values, job): stats = transforms.loads(job.output) template_values['enrolled'] = stats['enrollment']['enrolled'] template_values['unenrolled'] = stats['enrollment']['unenrolled'] scores = [] total_records = 0 for key, value in stats['scores'].items(): total_records += value[0] avg = round(value[1] / value[0], 1) if value[0] else 0 scores.append({'key': key, 'completed': value[0], 'avg': avg}) template_values['scores'] = scores template_values['total_records'] = total_records class StudentProgressStatsGenerator(jobs.DurableJob): """A job that computes student progress statistics.""" @staticmethod def get_description(): return 'student progress' class ProgressAggregator(object): """Aggregates student progress statistics.""" def __init__(self, course): self.progress_data = {} self._tracker = progress.UnitLessonCompletionTracker(course) def visit(self, student_property): if student_property.value: entity_scores = transforms.loads(student_property.value) for entity in entity_scores: entity_score = self.progress_data.get( entity, {'progress': 0, 'completed': 0}) if self._tracker.determine_if_composite_entity(entity): if (entity_scores[entity] == self._tracker.IN_PROGRESS_STATE): entity_score['progress'] += 1 elif (entity_scores[entity] == self._tracker.COMPLETED_STATE): entity_score['completed'] += 1 else: if entity_scores[entity] != 0: entity_score['completed'] += 1 self.progress_data[entity] = entity_score def __init__(self, app_context): super(StudentProgressStatsGenerator, self).__init__(app_context) self._course = courses.Course(None, app_context) def run(self): """Computes student progress statistics.""" student_progress = self.ProgressAggregator(self._course) mapper = models_utils.QueryMapper( StudentPropertyEntity.all(), batch_size=500, report_every=1000) mapper.run(student_progress.visit) return student_progress.progress_data class StudentProgressStatsSource(data_sources.SynchronousQuery): """Shows student progress analytics on the dashboard.""" @staticmethod def required_generators(): return [StudentProgressStatsGenerator] @staticmethod def fill_values(app_context, template_values, job): course = courses.Course(None, app_context=app_context) template_values['entity_codes'] = transforms.dumps( progress.UnitLessonCompletionTracker.EVENT_CODE_MAPPING.values()) value = transforms.loads(job.output) if value: value = transforms.dumps(value) else: value = None template_values['progress'] = value try: template_values['content'] = transforms.dumps( progress.ProgressStats(course).compute_entity_dict( 'course', [])) except IOError: template_values['update_message'] = safe_dom.Text( 'This feature is supported by CB 1.3 and up.') class QuestionStatsGenerator(jobs.DurableJob): """A job that computes stats for student submissions to questions.""" @staticmethod def get_description(): return 'question analysis' class MultipleChoiceQuestionAggregator(object): """Class that aggregates submissions for multiple-choice questions.""" ATTEMPT_ACTIVITY = 'attempt-activity' TAG_ASSESSMENT = 'tag-assessment' ATTEMPT_LESSON = 'attempt-lesson' SUBMIT_ASSESSMENT = 'submit-assessment' ATTEMPT_ASSESSMENT = 'attempt-assessment' MC_QUESTION = 'McQuestion' QUESTION_GROUP = 'QuestionGroup' ACTIVITY_CHOICE = 'activity-choice' ACTIVITY_GROUP = 'activity-group' def __init__(self, course): self._course = course self.id_to_questions_dict = progress.UnitLessonCompletionTracker( course).get_id_to_questions_dict() self.id_to_assessments_dict = progress.UnitLessonCompletionTracker( course).get_id_to_assessments_dict() def _get_course(self): return self._course def _append_data(self, summarized_question, dict_to_update): # Validate the structure and content of summarized_question dict. if set(summarized_question.keys()) != {'id', 'score', 'answers'}: return if not isinstance(summarized_question['score'], (int, float)): return if not isinstance(summarized_question['answers'], list): return if any(not isinstance(answer, int) for answer in ( summarized_question['answers'])): return if summarized_question['id'] not in dict_to_update: return if max(summarized_question['answers']) >= len( dict_to_update[summarized_question['id']]['answer_counts']): return # Add the summarized_question to the aggregating dict. q_dict = dict_to_update[summarized_question['id']] q_dict['score'] += summarized_question['score'] q_dict['num_attempts'] += 1 for choice_index in summarized_question['answers']: q_dict['answer_counts'][choice_index] += 1 def _get_unit_and_lesson_id_from_url(self, url): url_components = urlparse.urlparse(url) query_dict = urlparse.parse_qs(url_components.query) if 'unit' not in query_dict: return None, None unit_id = query_dict['unit'][0] lesson_id = None if 'lesson' in query_dict: lesson_id = query_dict['lesson'][0] else: lessons = self._get_course().get_lessons(unit_id) lesson_id = lessons[0].lesson_id if lessons else None return unit_id, lesson_id def _summarize_multiple_questions(self, data, id_prefix): """Helper method that summarizes events from a list of questions. Args: data: data dict from event_entity['data']. id_prefix: str. Questions in lessons have 'u.#.l.#' formatted prefix representing the unit and lesson id, and questions in assessments have 's.#' formatted prefix representing the assessment id. Returns: A list of dicts. Each of the dicts in the output list has the following keys: ['id', 'score', 'answers']. """ type_info_dict = data['containedTypes'] questions_list = [] for instanceid, type_info in type_info_dict.iteritems(): if isinstance(type_info, list): # This is a question group. mc_indices = [i for i in xrange(len(type_info)) if type_info[i] == self.MC_QUESTION] questions_list += [{ 'id': '%s.c.%s.i.%s' % (id_prefix, instanceid, index), 'score': data['individualScores'][instanceid][index], 'answers': data['answers'][instanceid][index] } for index in mc_indices if ( data['answers'][instanceid][index])] elif (type_info == self.MC_QUESTION and data['answers'][instanceid]): # This is an individual multiple-choice question. questions_list += [{ 'id': '%s.c.%s' % (id_prefix, instanceid), 'score': data['individualScores'][instanceid], 'answers': data['answers'][instanceid] }] return questions_list def _get_questions_from_attempt_activity(self, event_data): """Summarizes activity event data into a list of dicts. Args: event_data: data dict from event_entity['data']. Returns: List of dicts. Each of the dicts in the output list has the following keys: ['id', 'score', 'answers']. """ unit_id, lesson_id = self._get_unit_and_lesson_id_from_url( event_data['location']) if unit_id is None or lesson_id is None: return [] if (event_data['type'] == self.ACTIVITY_CHOICE and event_data['value'] is not None): return [{ 'id': 'u.%s.l.%s.b.%s' % ( unit_id, lesson_id, event_data['index']), 'score': 1.0 if event_data['correct'] else 0.0, 'answers': [event_data['value']] }] elif event_data['type'] == self.ACTIVITY_GROUP: block_id = event_data['index'] return [{ 'id': 'u.%s.l.%s.b.%s.i.%s' % ( unit_id, lesson_id, block_id, answer['index']), 'score': 1.0 if answer['correct'] else 0.0, 'answers': answer['value'] } for answer in event_data['values'] if answer['value']] else: return [] def _get_questions_from_tag_assessment(self, event_data): """Summarizes assessment tag event data into a list of dicts. Args: event_data: data dict from event_entity['data']. Returns: List of dicts. Each of the dicts in the output list has the following keys: ['id', 'score', 'answers']. """ unit_id, lesson_id = self._get_unit_and_lesson_id_from_url( event_data['location']) if unit_id is None or lesson_id is None: return [] if event_data['type'] == self.QUESTION_GROUP: mc_indices = [ i for i in xrange(len(event_data['containedTypes'])) if event_data['containedTypes'][i] == self.MC_QUESTION] return [{ 'id': 'u.%s.l.%s.c.%s.i.%s' % ( unit_id, lesson_id, event_data['instanceid'], index), 'score': event_data['individualScores'][index], 'answers': event_data['answer'][index] } for index in mc_indices if event_data['answer'][index]] elif (event_data['type'] == self.MC_QUESTION and event_data['answer']): # This is a single multiple-choice question. return [{ 'id': 'u.%s.l.%s.c.%s' % ( unit_id, lesson_id, event_data['instanceid']), 'score': event_data['score'], 'answers': event_data['answer'] }] else: return [] def _get_questions_from_attempt_lesson(self, event_data): """Summarizes lesson attempt event data into a list of dicts. Args: event_data: data dict from event_entity['data']. Returns: List of dicts. Each of the dicts in the output list has the following keys: ['id', 'score', 'answers']. """ unit_id, lesson_id = self._get_unit_and_lesson_id_from_url( event_data['location']) if unit_id is None or lesson_id is None: return [] return self._summarize_multiple_questions( event_data, 'u.%s.l.%s' % (unit_id, lesson_id)) def _get_questions_from_submit_and_attempt_assessment(self, event_data): """Summarizes assessment submission event data into a list of dicts. Args: event_data: data dict from event_entity['data']. Returns: List of dicts. Each of the dicts in the output list has the following keys: ['id', 'score', 'answers']. """ if not event_data['type'].startswith('assessment-'): return [] assessment_id = event_data['type'][len('assessment-'):] values = event_data['values'] if isinstance(values, list): # This is a v1.4 (or older) assessment. mc_indices = [i for i in xrange(len(values)) if values[i]['type'] == 'choices'] return [{ 'id': 's.%s.i.%s' % (assessment_id, index), 'score': 1.0 if values[index]['correct'] else 0.0, 'answers': [values[index]['value']] } for index in mc_indices if values[index]['value'] is not None] elif isinstance(values, dict): # This is a v1.5 assessment. return self._summarize_multiple_questions( values, 's.%s' % assessment_id) else: return [] def _process_event(self, source, data): """Returns a list of questions that correspond to the event.""" question_list = [] try: if source == self.ATTEMPT_ACTIVITY: question_list = self._get_questions_from_attempt_activity( data) elif source == self.TAG_ASSESSMENT: question_list = self._get_questions_from_tag_assessment( data) elif source == self.ATTEMPT_LESSON: question_list = self._get_questions_from_attempt_lesson( data) elif (source == self.SUBMIT_ASSESSMENT or source == self.ATTEMPT_ASSESSMENT): question_list = ( self._get_questions_from_submit_and_attempt_assessment( data)) except Exception as e: # pylint: disable=broad-except logging.error( 'Failed to process question analytics event: ' 'source %s, data %s, error %s', source, data, e) return question_list def visit(self, event_entity): """Records question data from given event_entity.""" if not event_entity or not event_entity.source: return try: data = transforms.loads(event_entity.data) except Exception: # pylint: disable=broad-except return # A list of dicts. Each dict represents a question instance and has # the following keys: ['id', 'score', 'answers']. Note that a # single event may correspond to multiple question instance dicts. question_list = self._process_event(event_entity.source, data) # Update the correct dict according to the event source. if (event_entity.source == self.SUBMIT_ASSESSMENT or event_entity.source == self.ATTEMPT_ASSESSMENT): dict_to_update = self.id_to_assessments_dict else: dict_to_update = self.id_to_questions_dict for summarized_question in question_list: self._append_data(summarized_question, dict_to_update) def __init__(self, app_context): super(QuestionStatsGenerator, self).__init__(app_context) self._course = courses.Course(None, app_context) def run(self): """Computes submitted question answers statistics.""" question_stats = self.MultipleChoiceQuestionAggregator(self._course) mapper = models_utils.QueryMapper( EventEntity.all(), batch_size=500, report_every=1000) mapper.run(question_stats.visit) return (question_stats.id_to_questions_dict, question_stats.id_to_assessments_dict) class QuestionStatsSource(data_sources.SynchronousQuery): """Shows statistics on the dashboard for students' answers to questions.""" @staticmethod def required_generators(): return [QuestionStatsGenerator] @staticmethod def fill_values(app_context, template_values, job): accumulated_question_answers, accumulated_assessment_answers = ( transforms.loads(job.output)) template_values['accumulated_question_answers'] = transforms.dumps( accumulated_question_answers) template_values['accumulated_assessment_answers'] = transforms.dumps( accumulated_assessment_answers)
apache-2.0
[ 3, 1898, 6029, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 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, 25107, 666, 5274, 19203, 24248, 334, 2865, 13, 28030, 9, 11597, 1041, 199, 199, 363, 2502, 363, 275, 283, 1513, 290, 491, 711, 334, 83, 914, 32, 3098, 14, 957, 3171, 199, 199, 646, 2050, 199, 646, 7097, 199, 199, 504, 2863, 492, 5048, 63, 4556, 199, 504, 1709, 492, 13588, 199, 504, 1709, 492, 666, 63, 4553, 199, 504, 1709, 492, 9643, 199, 504, 1709, 492, 6696, 199, 504, 1709, 492, 18501, 199, 504, 1709, 492, 3778, 465, 1709, 63, 1208, 199, 504, 1709, 14, 992, 492, 6763, 7302, 199, 504, 1709, 14, 992, 492, 17246, 199, 504, 1709, 14, 992, 492, 17246, 3697, 7302, 421, 199, 533, 17246, 13842, 3325, 29654, 7599, 8, 6920, 14, 36, 15684, 6694, 304, 272, 408, 33, 3906, 626, 21445, 6474, 11076, 1041, 339, 768, 4639, 272, 347, 664, 63, 1802, 837, 267, 372, 283, 5500, 14869, 436, 9342, 7, 339, 1021, 428, 4630, 23933, 8, 785, 304, 267, 408, 8073, 2335, 9342, 11076, 1041, 398, 347, 636, 826, 721, 277, 304, 288, 327, 2136, 3877, 1006, 666, 465, 6346, 19272, 701, 314, 28273, 730, 536, 14, 288, 327, 7048, 2008, 18578, 26, 288, 327, 258, 334, 5500, 63, 835, 12, 3089, 8, 3397, 430, 288, 291, 14, 354, 63, 475, 63, 2960, 275, 1052, 398, 347, 5684, 8, 277, 12, 6474, 304, 288, 340, 6474, 14, 7107, 26, 355, 9342, 275, 18501, 14, 3640, 8, 5500, 14, 7107, 9, 355, 367, 790, 315, 9342, 14, 1612, 837, 490, 340, 790, 315, 291, 14, 354, 63, 475, 63, 2960, 26, 717, 2338, 275, 291, 14, 354, 63, 475, 63, 2960, 59, 498, 1527, 16, 61, 717, 5396, 63, 1838, 275, 291, 14, 354, 63, 475, 63, 2960, 59, 498, 1527, 17, 61, 490, 587, 26, 717, 2338, 275, 378, 717, 5396, 63, 1838, 275, 378, 490, 291, 14, 354, 63, 475, 63, 2960, 59, 498, 61, 275, 334, 717, 2338, 435, 413, 12, 5396, 63, 1838, 435, 2069, 8, 7107, 59, 498, 2459, 339, 1021, 3447, 6764, 23933, 8, 785, 304, 267, 408, 8073, 2335, 14869, 11076, 1041, 398, 347, 636, 826, 721, 277, 304, 288, 291, 14, 22428, 275, 378, 288, 291, 14, 324, 22428, 275, 378, 398, 347, 5684, 8, 277, 12, 6474, 304, 288, 340, 6474, 14, 374, 63, 22428, 26, 355, 291, 14, 22428, 847, 413, 288, 587, 26, 355, 291, 14, 324, 22428, 847, 413, 339, 347, 1255, 8, 277, 304, 267, 408, 22594, 6474, 11076, 1041, 267, 14869, 275, 291, 14, 13842, 23933, 342, 267, 9342, 275, 291, 14, 29654, 23933, 342, 267, 7796, 275, 1709, 63, 1208, 14, 3227, 11880, 8, 288, 17246, 14, 452, 1062, 3522, 63, 890, 29, 5783, 12, 3622, 63, 14287, 29, 5279, 9, 398, 347, 2341, 63, 2324, 8, 5500, 304, 288, 14869, 14, 5427, 8, 5500, 9, 288, 9342, 14, 5427, 8, 5500, 9, 398, 7796, 14, 1065, 8, 1130, 63, 2324, 9, 398, 666, 275, 469, 288, 283, 12214, 356, 469, 355, 283, 22428, 356, 14869, 14, 22428, 12, 355, 283, 324, 22428, 356, 14869, 14, 324, 22428, 1386, 288, 283, 7107, 356, 9342, 14, 354, 63, 475, 63, 2960, 93, 398, 372, 666, 421, 199, 533, 17246, 13842, 3325, 29654, 2980, 8, 576, 63, 4553, 14, 51, 9865, 3227, 304, 272, 408, 6824, 83, 6474, 14869, 30159, 641, 314, 17216, 1041, 339, 768, 4639, 272, 347, 1415, 63, 20748, 837, 267, 372, 359, 18086, 13842, 3325, 29654, 7599, 61, 339, 768, 4639, 272, 347, 5554, 63, 1459, 8, 571, 63, 1100, 12, 1978, 63, 1459, 12, 3906, 304, 267, 5020, 275, 18501, 14, 3640, 8, 2423, 14, 1199, 9, 398, 1978, 63, 1459, 459, 22428, 418, 275, 5020, 459, 12214, 2545, 22428, 418, 267, 1978, 63, 1459, 459, 324, 22428, 418, 275, 5020, 459, 12214, 2545, 324, 22428, 418, 267, 9342, 275, 942, 267, 3141, 63, 6502, 275, 378, 267, 367, 790, 12, 574, 315, 5020, 459, 7107, 2278, 1744, 837, 288, 3141, 63, 6502, 847, 574, 59, 16, 61, 288, 12402, 275, 6168, 8, 585, 59, 17, 61, 1182, 574, 59, 16, 467, 413, 9, 340, 574, 59, 16, 61, 587, 378, 288, 9342, 14, 740, 3252, 498, 356, 790, 12, 283, 12634, 356, 574, 59, 16, 467, 2574, 283, 8595, 356, 12402, 1552, 267, 1978, 63, 1459, 459, 7107, 418, 275, 9342, 267, 1978, 63, 1459, 459, 2923, 63, 6502, 418, 275, 3141, 63, 6502, 421, 199, 533, 17246, 11504, 8257, 7599, 8, 6920, 14, 36, 15684, 6694, 304, 272, 408, 33, 3906, 626, 21445, 6474, 6696, 11076, 1041, 339, 768, 4639, 272, 347, 664, 63, 1802, 837, 267, 372, 283, 5500, 6696, 7, 339, 1021, 21211, 23933, 8, 785, 304, 267, 408, 8073, 2335, 6474, 6696, 11076, 1041, 398, 347, 636, 826, 721, 277, 12, 2518, 304, 288, 291, 14, 5734, 63, 576, 275, 1052, 288, 291, 423, 8877, 275, 6696, 14, 5072, 10958, 265, 19741, 13652, 8, 1972, 9, 398, 347, 5684, 8, 277, 12, 6474, 63, 1829, 304, 288, 340, 6474, 63, 1829, 14, 585, 26, 355, 4642, 63, 7107, 275, 18501, 14, 3640, 8, 5500, 63, 1829, 14, 585, 9, 355, 367, 4642, 315, 4642, 63, 7107, 26, 490, 4642, 63, 3397, 275, 291, 14, 5734, 63, 576, 14, 362, 8, 717, 4642, 12, 791, 5734, 356, 378, 12, 283, 12634 ]
[ 1898, 6029, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 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, 25107, 666, 5274, 19203, 24248, 334, 2865, 13, 28030, 9, 11597, 1041, 199, 199, 363, 2502, 363, 275, 283, 1513, 290, 491, 711, 334, 83, 914, 32, 3098, 14, 957, 3171, 199, 199, 646, 2050, 199, 646, 7097, 199, 199, 504, 2863, 492, 5048, 63, 4556, 199, 504, 1709, 492, 13588, 199, 504, 1709, 492, 666, 63, 4553, 199, 504, 1709, 492, 9643, 199, 504, 1709, 492, 6696, 199, 504, 1709, 492, 18501, 199, 504, 1709, 492, 3778, 465, 1709, 63, 1208, 199, 504, 1709, 14, 992, 492, 6763, 7302, 199, 504, 1709, 14, 992, 492, 17246, 199, 504, 1709, 14, 992, 492, 17246, 3697, 7302, 421, 199, 533, 17246, 13842, 3325, 29654, 7599, 8, 6920, 14, 36, 15684, 6694, 304, 272, 408, 33, 3906, 626, 21445, 6474, 11076, 1041, 339, 768, 4639, 272, 347, 664, 63, 1802, 837, 267, 372, 283, 5500, 14869, 436, 9342, 7, 339, 1021, 428, 4630, 23933, 8, 785, 304, 267, 408, 8073, 2335, 9342, 11076, 1041, 398, 347, 636, 826, 721, 277, 304, 288, 327, 2136, 3877, 1006, 666, 465, 6346, 19272, 701, 314, 28273, 730, 536, 14, 288, 327, 7048, 2008, 18578, 26, 288, 327, 258, 334, 5500, 63, 835, 12, 3089, 8, 3397, 430, 288, 291, 14, 354, 63, 475, 63, 2960, 275, 1052, 398, 347, 5684, 8, 277, 12, 6474, 304, 288, 340, 6474, 14, 7107, 26, 355, 9342, 275, 18501, 14, 3640, 8, 5500, 14, 7107, 9, 355, 367, 790, 315, 9342, 14, 1612, 837, 490, 340, 790, 315, 291, 14, 354, 63, 475, 63, 2960, 26, 717, 2338, 275, 291, 14, 354, 63, 475, 63, 2960, 59, 498, 1527, 16, 61, 717, 5396, 63, 1838, 275, 291, 14, 354, 63, 475, 63, 2960, 59, 498, 1527, 17, 61, 490, 587, 26, 717, 2338, 275, 378, 717, 5396, 63, 1838, 275, 378, 490, 291, 14, 354, 63, 475, 63, 2960, 59, 498, 61, 275, 334, 717, 2338, 435, 413, 12, 5396, 63, 1838, 435, 2069, 8, 7107, 59, 498, 2459, 339, 1021, 3447, 6764, 23933, 8, 785, 304, 267, 408, 8073, 2335, 14869, 11076, 1041, 398, 347, 636, 826, 721, 277, 304, 288, 291, 14, 22428, 275, 378, 288, 291, 14, 324, 22428, 275, 378, 398, 347, 5684, 8, 277, 12, 6474, 304, 288, 340, 6474, 14, 374, 63, 22428, 26, 355, 291, 14, 22428, 847, 413, 288, 587, 26, 355, 291, 14, 324, 22428, 847, 413, 339, 347, 1255, 8, 277, 304, 267, 408, 22594, 6474, 11076, 1041, 267, 14869, 275, 291, 14, 13842, 23933, 342, 267, 9342, 275, 291, 14, 29654, 23933, 342, 267, 7796, 275, 1709, 63, 1208, 14, 3227, 11880, 8, 288, 17246, 14, 452, 1062, 3522, 63, 890, 29, 5783, 12, 3622, 63, 14287, 29, 5279, 9, 398, 347, 2341, 63, 2324, 8, 5500, 304, 288, 14869, 14, 5427, 8, 5500, 9, 288, 9342, 14, 5427, 8, 5500, 9, 398, 7796, 14, 1065, 8, 1130, 63, 2324, 9, 398, 666, 275, 469, 288, 283, 12214, 356, 469, 355, 283, 22428, 356, 14869, 14, 22428, 12, 355, 283, 324, 22428, 356, 14869, 14, 324, 22428, 1386, 288, 283, 7107, 356, 9342, 14, 354, 63, 475, 63, 2960, 93, 398, 372, 666, 421, 199, 533, 17246, 13842, 3325, 29654, 2980, 8, 576, 63, 4553, 14, 51, 9865, 3227, 304, 272, 408, 6824, 83, 6474, 14869, 30159, 641, 314, 17216, 1041, 339, 768, 4639, 272, 347, 1415, 63, 20748, 837, 267, 372, 359, 18086, 13842, 3325, 29654, 7599, 61, 339, 768, 4639, 272, 347, 5554, 63, 1459, 8, 571, 63, 1100, 12, 1978, 63, 1459, 12, 3906, 304, 267, 5020, 275, 18501, 14, 3640, 8, 2423, 14, 1199, 9, 398, 1978, 63, 1459, 459, 22428, 418, 275, 5020, 459, 12214, 2545, 22428, 418, 267, 1978, 63, 1459, 459, 324, 22428, 418, 275, 5020, 459, 12214, 2545, 324, 22428, 418, 267, 9342, 275, 942, 267, 3141, 63, 6502, 275, 378, 267, 367, 790, 12, 574, 315, 5020, 459, 7107, 2278, 1744, 837, 288, 3141, 63, 6502, 847, 574, 59, 16, 61, 288, 12402, 275, 6168, 8, 585, 59, 17, 61, 1182, 574, 59, 16, 467, 413, 9, 340, 574, 59, 16, 61, 587, 378, 288, 9342, 14, 740, 3252, 498, 356, 790, 12, 283, 12634, 356, 574, 59, 16, 467, 2574, 283, 8595, 356, 12402, 1552, 267, 1978, 63, 1459, 459, 7107, 418, 275, 9342, 267, 1978, 63, 1459, 459, 2923, 63, 6502, 418, 275, 3141, 63, 6502, 421, 199, 533, 17246, 11504, 8257, 7599, 8, 6920, 14, 36, 15684, 6694, 304, 272, 408, 33, 3906, 626, 21445, 6474, 6696, 11076, 1041, 339, 768, 4639, 272, 347, 664, 63, 1802, 837, 267, 372, 283, 5500, 6696, 7, 339, 1021, 21211, 23933, 8, 785, 304, 267, 408, 8073, 2335, 6474, 6696, 11076, 1041, 398, 347, 636, 826, 721, 277, 12, 2518, 304, 288, 291, 14, 5734, 63, 576, 275, 1052, 288, 291, 423, 8877, 275, 6696, 14, 5072, 10958, 265, 19741, 13652, 8, 1972, 9, 398, 347, 5684, 8, 277, 12, 6474, 63, 1829, 304, 288, 340, 6474, 63, 1829, 14, 585, 26, 355, 4642, 63, 7107, 275, 18501, 14, 3640, 8, 5500, 63, 1829, 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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 ]
cesarmarinhorj/phantomjs
src/qt/qtwebkit/Tools/Scripts/webkitpy/common/watchlist/watchlistrule.py
132
2153
# 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. class WatchListRule: '''A rule with instructions to do when the rule is satisified.''' def __init__(self, complex_definition, instructions): self.definitions_to_match = complex_definition.split('|') self._instructions = instructions def match(self, matching_definitions): for test_definition in self.definitions_to_match: if test_definition in matching_definitions: return True return False def instructions(self): return self._instructions def remove_instruction(self, instruction): self._instructions.remove(instruction)
bsd-3-clause
[ 3, 1898, 334, 35, 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, 421, 199, 533, 29075, 1296, 5065, 26, 272, 1449, 33, 2332, 543, 15794, 370, 886, 1380, 314, 2332, 365, 308, 2159, 338, 1290, 10595, 272, 347, 636, 826, 721, 277, 12, 6114, 63, 7463, 12, 15794, 304, 267, 291, 14, 15388, 63, 475, 63, 1431, 275, 6114, 63, 7463, 14, 1294, 20137, 358, 267, 291, 423, 20718, 275, 15794, 339, 347, 1336, 8, 277, 12, 4877, 63, 15388, 304, 267, 367, 511, 63, 7463, 315, 291, 14, 15388, 63, 475, 63, 1431, 26, 288, 340, 511, 63, 7463, 315, 4877, 63, 15388, 26, 355, 372, 715, 267, 372, 756, 339, 347, 15794, 8, 277, 304, 267, 372, 291, 423, 20718, 339, 347, 2813, 63, 22880, 8, 277, 12, 16329, 304, 267, 291, 423, 20718, 14, 2168, 8, 22880, 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 ]
[ 1898, 334, 35, 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, 421, 199, 533, 29075, 1296, 5065, 26, 272, 1449, 33, 2332, 543, 15794, 370, 886, 1380, 314, 2332, 365, 308, 2159, 338, 1290, 10595, 272, 347, 636, 826, 721, 277, 12, 6114, 63, 7463, 12, 15794, 304, 267, 291, 14, 15388, 63, 475, 63, 1431, 275, 6114, 63, 7463, 14, 1294, 20137, 358, 267, 291, 423, 20718, 275, 15794, 339, 347, 1336, 8, 277, 12, 4877, 63, 15388, 304, 267, 367, 511, 63, 7463, 315, 291, 14, 15388, 63, 475, 63, 1431, 26, 288, 340, 511, 63, 7463, 315, 4877, 63, 15388, 26, 355, 372, 715, 267, 372, 756, 339, 347, 15794, 8, 277, 304, 267, 372, 291, 423, 20718, 339, 347, 2813, 63, 22880, 8, 277, 12, 16329, 304, 267, 291, 423, 20718, 14, 2168, 8, 22880, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
0xGiddi/pymbr
pymbr/bootcode.py
1
1582
""" pymbr A python module to manipulate and create MBRs. :copyright: (c) 2017 by Gideon S. (0xGiddi) :license: GPLv3, see LICENSE file for more details. """ __all__ = ['Bootcode'] class Bootcode: """ Common bootcodes used by various OSes """ ZERO = [0x00] ZOIDBERG = [0xB8, 0xC0, 0x07, 0x05, 0x20, 0x01, 0x8E, 0xD0, 0xBC, 0x00, 0x10, 0xB8, 0xC0, 0x07, 0x8E, 0xD8, 0xE8, 0x8E, 0x00, 0xE8, 0xA3, 0x00, 0xBE, 0x2A, 0x00, 0xE8, 0x70, 0x00, 0xBE, 0x45, 0x00, 0xE8, 0x6A, 0x00, 0xBE, 0x6B, 0x00, 0xE8, 0x64, 0x00, 0xEB, 0xFE, 0x4E, 0x65, 0x65, 0x64, 0x20, 0x4D, 0x42, 0x52, 0x20, 0x70, 0x61, 0x72, 0x73, 0x69, 0x6E, 0x67, 0x20, 0x6D, 0x6F, 0x64, 0x75, 0x6C, 0x65, 0x3F, 0x0A, 0x0D, 0x00, 0x57, 0x68, 0x79, 0x20, 0x6E, 0x6F, 0x74, 0x20, 0x5A, 0x6F, 0x69, 0x64, 0x62, 0x65, 0x72, 0x67, 0x3F, 0x20, 0x28, 0x56, 0x56, 0x29, 0x28, 0xA7, 0x2C, 0x2C, 0x2C, 0xA7, 0x29, 0x28, 0x56, 0x56, 0x29, 0x0A, 0x0D, 0x0A, 0x0D, 0x00, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3A, 0x2F, 0x2F, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2E, 0x63, 0x6F, 0x6D, 0x2F, 0x30, 0x78, 0x47, 0x69, 0x64, 0x64, 0x69, 0x2F, 0x70, 0x79, 0x6D, 0x62, 0x72, 0x00, 0xB4, 0x0E, 0xAC, 0x3C, 0x00, 0x74, 0x04, 0xCD, 0x10, 0xEB, 0xF7, 0xC3, 0x60, 0xB7, 0x00, 0xB4, 0x02, 0xCD, 0x10, 0x61, 0xC3, 0x60, 0xBA, 0x00, 0x00, 0xE8, 0xF0, 0xFF, 0xB4, 0x06, 0xB0, 0x00, 0xB7, 0x0C, 0xB9, 0x00, 0x00, 0xB6, 0x18, 0xB2, 0x4F, 0xCD, 0x10, 0x61, 0xC3, 0x60, 0xB5, 0x20, 0xB4, 0x01, 0xB0, 0x03, 0xCD, 0x10, 0x61, 0xC3] # TODO: Add here popular OSes MBRs
gpl-3.0
[ 624, 272, 1134, 887, 82, 2286, 437, 2366, 859, 370, 27232, 436, 1218, 603, 7184, 83, 14, 272, 520, 7307, 26, 334, 67, 9, 9708, 701, 598, 2655, 265, 428, 14, 334, 16, 88, 39, 344, 328, 9, 272, 520, 1682, 26, 14629, 86, 19, 12, 1937, 5113, 570, 367, 1655, 2436, 14, 199, 624, 199, 199, 363, 452, 363, 275, 788, 17989, 600, 418, 199, 199, 533, 27324, 600, 26, 199, 198, 624, 13964, 8498, 6021, 1202, 701, 7750, 221, 4403, 397, 408, 421, 198, 24655, 275, 359, 16, 88, 383, 61, 421, 198, 58, 16337, 12003, 39, 275, 359, 16, 8094, 24, 12, 378, 8163, 16, 12, 378, 88, 1780, 12, 378, 88, 1717, 12, 378, 88, 1165, 12, 378, 88, 614, 12, 378, 88, 24, 37, 12, 378, 8313, 16, 12, 378, 88, 6265, 12, 378, 88, 383, 12, 378, 88, 709, 12, 378, 8094, 24, 12, 378, 8163, 16, 12, 378, 88, 1780, 12, 378, 88, 24, 37, 12, 378, 8313, 24, 12, 15075, 378, 6991, 24, 12, 378, 88, 24, 37, 12, 378, 88, 383, 12, 378, 6991, 24, 12, 378, 7471, 19, 12, 378, 88, 383, 12, 378, 88, 6773, 12, 378, 88, 18, 33, 12, 378, 88, 383, 12, 378, 6991, 24, 12, 378, 88, 2760, 12, 378, 88, 383, 12, 378, 88, 6773, 12, 378, 88, 2322, 12, 378, 88, 383, 12, 378, 6991, 24, 12, 15075, 378, 88, 22, 33, 12, 378, 88, 383, 12, 378, 88, 6773, 12, 378, 88, 22, 34, 12, 378, 88, 383, 12, 378, 6991, 24, 12, 378, 88, 772, 12, 378, 88, 383, 12, 378, 6991, 34, 12, 378, 20981, 12, 378, 88, 20, 37, 12, 378, 88, 2182, 12, 378, 88, 2182, 12, 378, 88, 772, 12, 378, 88, 1165, 12, 378, 88, 20, 36, 12, 15075, 378, 88, 2260, 12, 378, 88, 2528, 12, 378, 88, 1165, 12, 378, 88, 2760, 12, 378, 88, 2976, 12, 378, 88, 2819, 12, 378, 88, 2898, 12, 378, 88, 1876, 12, 378, 88, 22, 37, 12, 378, 88, 1822, 12, 378, 88, 1165, 12, 378, 88, 22, 36, 12, 378, 88, 22, 38, 12, 378, 88, 772, 12, 378, 88, 2194, 12, 378, 88, 22, 35, 12, 15075, 378, 88, 2182, 12, 378, 88, 19, 38, 12, 378, 88, 16, 33, 12, 378, 88, 16, 36, 12, 378, 88, 383, 12, 378, 88, 1641, 12, 378, 88, 2333, 12, 378, 88, 1965, 12, 378, 88, 1165, 12, 378, 88, 22, 37, 12, 378, 88, 22, 38, 12, 378, 88, 1342, 12, 378, 88, 1165, 12, 378, 88, 21, 33, 12, 378, 88, 22, 38, 12, 378, 88, 1876, 12, 15075, 378, 88, 772, 12, 378, 88, 2789, 12, 378, 88, 2182, 12, 378, 88, 2819, 12, 378, 88, 1822, 12, 378, 88, 19, 38, 12, 378, 88, 1165, 12, 378, 88, 1651, 12, 378, 88, 1367, 12, 378, 88, 1367, 12, 378, 88, 1398, 12, 378, 88, 1651, 12, 378, 7471, 23, 12, 378, 88, 18, 35, 12, 378, 88, 18, 35, 12, 378, 88, 18, 35, 12, 15075, 378, 7471, 23, 12, 378, 88, 1398, 12, 378, 88, 1651, 12, 378, 88, 1367, 12, 378, 88, 1367, 12, 378, 88, 1398, 12, 378, 88, 16, 33, 12, 378, 88, 16, 36, 12, 378, 88, 16, 33, 12, 378, 88, 16, 36, 12, 378, 88, 383, 12, 378, 88, 2333, 12, 378, 88, 1342, 12, 378, 88, 1342, 12, 378, 88, 2760, 12, 378, 88, 2898, 12, 15075, 378, 88, 19, 33, 12, 378, 88, 18, 38, 12, 378, 88, 18, 38, 12, 378, 88, 1822, 12, 378, 88, 1876, 12, 378, 88, 1342, 12, 378, 88, 2333, 12, 378, 88, 2194, 12, 378, 88, 2789, 12, 378, 88, 18, 37, 12, 378, 88, 2766, 12, 378, 88, 22, 38, 12, 378, 88, 22, 36, 12, 378, 88, 18, 38, 12, 378, 88, 1216, 12, 378, 88, 2277, 12, 15075, 378, 88, 2417, 12, 378, 88, 1876, 12, 378, 88, 772, 12, 378, 88, 772, 12, 378, 88, 1876, 12, 378, 88, 18, 38, 12, 378, 88, 2760, 12, 378, 88, 1965, 12, 378, 88, 22, 36, 12, 378, 88, 2789, 12, 378, 88, 2819, 12, 378, 88, 383, 12, 378, 8094, 20, 12, 378, 88, 16, 37, 12, 378, 88, 1348, 12, 378, 88, 19, 35, 12, 15075, 378, 88, 383, 12, 378, 88, 1342, 12, 378, 88, 966, 12, 378, 88, 7695, 12, 378, 88, 709, 12, 378, 6991, 34, 12, 378, 6287, 23, 12, 378, 8163, 19, 12, 378, 88, 2259, 12, 378, 8094, 23, 12, 378, 88, 383, 12, 378, 8094, 20, 12, 378, 88, 996, 12, 378, 88, 7695, 12, 378, 88, 709, 12, 378, 88, 2976, 12, 15075, 378, 8163, 19, 12, 378, 88, 2259, 12, 378, 88, 4134, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 6991, 24, 12, 378, 6287, 16, 12, 378, 9039, 12, 378, 8094, 20, 12, 378, 88, 1690, 12, 378, 8094, 16, 12, 378, 88, 383, 12, 378, 8094, 23, 12, 378, 88, 16, 35, 12, 378, 8094, 25, 12, 378, 88, 383, 12, 15075, 378, 88, 383, 12, 378, 8094, 22, 12, 378, 88, 1085, 12, 378, 8094, 18, 12, 378, 88, 20, 38, 12, 378, 88, 7695, 12, 378, 88, 709, 12, 378, 88, 2976, 12, 378, 8163, 19, 12, 378, 88, 2259, 12, 378, 8094, 21, 12, 378, 88, 1165, 12, 378, 8094, 20, 12, 378, 88, 614, 12, 378, 8094, 16, 12, 378, 88, 1644, 12, 15075, 378, 88, 7695, 12, 378, 88, 709, 12, 378, 88, 2976, 12, 378, 8163, 19, 61, 421, 198, 3, 3254, 26, 2654, 2348, 4560, 2238, 4403, 397, 603, 7184, 83, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 272, 1134, 887, 82, 2286, 437, 2366, 859, 370, 27232, 436, 1218, 603, 7184, 83, 14, 272, 520, 7307, 26, 334, 67, 9, 9708, 701, 598, 2655, 265, 428, 14, 334, 16, 88, 39, 344, 328, 9, 272, 520, 1682, 26, 14629, 86, 19, 12, 1937, 5113, 570, 367, 1655, 2436, 14, 199, 624, 199, 199, 363, 452, 363, 275, 788, 17989, 600, 418, 199, 199, 533, 27324, 600, 26, 199, 198, 624, 13964, 8498, 6021, 1202, 701, 7750, 221, 4403, 397, 408, 421, 198, 24655, 275, 359, 16, 88, 383, 61, 421, 198, 58, 16337, 12003, 39, 275, 359, 16, 8094, 24, 12, 378, 8163, 16, 12, 378, 88, 1780, 12, 378, 88, 1717, 12, 378, 88, 1165, 12, 378, 88, 614, 12, 378, 88, 24, 37, 12, 378, 8313, 16, 12, 378, 88, 6265, 12, 378, 88, 383, 12, 378, 88, 709, 12, 378, 8094, 24, 12, 378, 8163, 16, 12, 378, 88, 1780, 12, 378, 88, 24, 37, 12, 378, 8313, 24, 12, 15075, 378, 6991, 24, 12, 378, 88, 24, 37, 12, 378, 88, 383, 12, 378, 6991, 24, 12, 378, 7471, 19, 12, 378, 88, 383, 12, 378, 88, 6773, 12, 378, 88, 18, 33, 12, 378, 88, 383, 12, 378, 6991, 24, 12, 378, 88, 2760, 12, 378, 88, 383, 12, 378, 88, 6773, 12, 378, 88, 2322, 12, 378, 88, 383, 12, 378, 6991, 24, 12, 15075, 378, 88, 22, 33, 12, 378, 88, 383, 12, 378, 88, 6773, 12, 378, 88, 22, 34, 12, 378, 88, 383, 12, 378, 6991, 24, 12, 378, 88, 772, 12, 378, 88, 383, 12, 378, 6991, 34, 12, 378, 20981, 12, 378, 88, 20, 37, 12, 378, 88, 2182, 12, 378, 88, 2182, 12, 378, 88, 772, 12, 378, 88, 1165, 12, 378, 88, 20, 36, 12, 15075, 378, 88, 2260, 12, 378, 88, 2528, 12, 378, 88, 1165, 12, 378, 88, 2760, 12, 378, 88, 2976, 12, 378, 88, 2819, 12, 378, 88, 2898, 12, 378, 88, 1876, 12, 378, 88, 22, 37, 12, 378, 88, 1822, 12, 378, 88, 1165, 12, 378, 88, 22, 36, 12, 378, 88, 22, 38, 12, 378, 88, 772, 12, 378, 88, 2194, 12, 378, 88, 22, 35, 12, 15075, 378, 88, 2182, 12, 378, 88, 19, 38, 12, 378, 88, 16, 33, 12, 378, 88, 16, 36, 12, 378, 88, 383, 12, 378, 88, 1641, 12, 378, 88, 2333, 12, 378, 88, 1965, 12, 378, 88, 1165, 12, 378, 88, 22, 37, 12, 378, 88, 22, 38, 12, 378, 88, 1342, 12, 378, 88, 1165, 12, 378, 88, 21, 33, 12, 378, 88, 22, 38, 12, 378, 88, 1876, 12, 15075, 378, 88, 772, 12, 378, 88, 2789, 12, 378, 88, 2182, 12, 378, 88, 2819, 12, 378, 88, 1822, 12, 378, 88, 19, 38, 12, 378, 88, 1165, 12, 378, 88, 1651, 12, 378, 88, 1367, 12, 378, 88, 1367, 12, 378, 88, 1398, 12, 378, 88, 1651, 12, 378, 7471, 23, 12, 378, 88, 18, 35, 12, 378, 88, 18, 35, 12, 378, 88, 18, 35, 12, 15075, 378, 7471, 23, 12, 378, 88, 1398, 12, 378, 88, 1651, 12, 378, 88, 1367, 12, 378, 88, 1367, 12, 378, 88, 1398, 12, 378, 88, 16, 33, 12, 378, 88, 16, 36, 12, 378, 88, 16, 33, 12, 378, 88, 16, 36, 12, 378, 88, 383, 12, 378, 88, 2333, 12, 378, 88, 1342, 12, 378, 88, 1342, 12, 378, 88, 2760, 12, 378, 88, 2898, 12, 15075, 378, 88, 19, 33, 12, 378, 88, 18, 38, 12, 378, 88, 18, 38, 12, 378, 88, 1822, 12, 378, 88, 1876, 12, 378, 88, 1342, 12, 378, 88, 2333, 12, 378, 88, 2194, 12, 378, 88, 2789, 12, 378, 88, 18, 37, 12, 378, 88, 2766, 12, 378, 88, 22, 38, 12, 378, 88, 22, 36, 12, 378, 88, 18, 38, 12, 378, 88, 1216, 12, 378, 88, 2277, 12, 15075, 378, 88, 2417, 12, 378, 88, 1876, 12, 378, 88, 772, 12, 378, 88, 772, 12, 378, 88, 1876, 12, 378, 88, 18, 38, 12, 378, 88, 2760, 12, 378, 88, 1965, 12, 378, 88, 22, 36, 12, 378, 88, 2789, 12, 378, 88, 2819, 12, 378, 88, 383, 12, 378, 8094, 20, 12, 378, 88, 16, 37, 12, 378, 88, 1348, 12, 378, 88, 19, 35, 12, 15075, 378, 88, 383, 12, 378, 88, 1342, 12, 378, 88, 966, 12, 378, 88, 7695, 12, 378, 88, 709, 12, 378, 6991, 34, 12, 378, 6287, 23, 12, 378, 8163, 19, 12, 378, 88, 2259, 12, 378, 8094, 23, 12, 378, 88, 383, 12, 378, 8094, 20, 12, 378, 88, 996, 12, 378, 88, 7695, 12, 378, 88, 709, 12, 378, 88, 2976, 12, 15075, 378, 8163, 19, 12, 378, 88, 2259, 12, 378, 88, 4134, 12, 378, 88, 383, 12, 378, 88, 383, 12, 378, 6991, 24, 12, 378, 6287, 16, 12, 378, 9039, 12, 378, 8094, 20, 12, 378, 88, 1690, 12, 378, 8094, 16, 12, 378, 88, 383, 12, 378, 8094, 23, 12, 378, 88, 16, 35, 12, 378, 8094, 25, 12, 378, 88, 383, 12, 15075, 378, 88, 383, 12, 378, 8094, 22, 12, 378, 88, 1085, 12, 378, 8094, 18, 12, 378, 88, 20, 38, 12, 378, 88, 7695, 12, 378, 88, 709, 12, 378, 88, 2976, 12, 378, 8163, 19, 12, 378, 88, 2259, 12, 378, 8094, 21, 12, 378, 88, 1165, 12, 378, 8094, 20, 12, 378, 88, 614, 12, 378, 8094, 16, 12, 378, 88, 1644, 12, 15075, 378, 88, 7695, 12, 378, 88, 709, 12, 378, 88, 2976, 12, 378, 8163, 19, 61, 421, 198, 3, 3254, 26, 2654, 2348, 4560, 2238, 4403, 397, 603, 7184, 83, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
royc1/gpdb
gpMgmt/bin/gppylib/commands/unix.py
20
31774
#!/usr/bin/env python # # Copyright (c) Greenplum Inc 2008. All Rights Reserved. # """ Set of Classes for executing unix commands. """ import os import psutil import platform import socket import sys import signal from gppylib.gplog import * from gppylib.commands.base import * logger = gplog.get_default_logger() #---------------platforms-------------------- #global variable for our platform SYSTEM="unknown" SUNOS="sunos" LINUX="linux" DARWIN="darwin" FREEBSD="freebsd" platform_list = [SUNOS,LINUX,DARWIN,FREEBSD] curr_platform = platform.uname()[0].lower() GPHOME=os.environ.get('GPHOME', None) #---------------command path-------------------- CMDPATH = ['/usr/kerberos/bin', '/usr/sfw/bin', '/opt/sfw/bin', '/bin', '/usr/local/bin', '/usr/bin', '/sbin', '/usr/sbin', '/usr/ucb', '/sw/bin', '/opt/Navisphere/bin'] if GPHOME: CMDPATH.append(GPHOME) CMD_CACHE = {} #---------------------------------- class CommandNotFoundException(Exception): def __init__(self,cmd,paths): self.cmd=cmd self.paths=paths def __str__(self): return "Could not locate command: '%s' in this set of paths: %s" % (self.cmd,repr(self.paths)) def findCmdInPath(cmd, additionalPaths=[], printError=True): global CMD_CACHE if cmd not in CMD_CACHE: # Search additional paths and don't add to cache. for p in additionalPaths: f = os.path.join(p, cmd) if os.path.exists(f): return f for p in CMDPATH: f = os.path.join(p, cmd) if os.path.exists(f): CMD_CACHE[cmd] = f return f if printError: logger.critical('Command %s not found' % cmd) search_path = CMDPATH[:] search_path.extend(additionalPaths) raise CommandNotFoundException(cmd,search_path) else: return CMD_CACHE[cmd] #For now we'll leave some generic functions outside of the Platform framework def getLocalHostname(): return socket.gethostname().split('.')[0] def getUserName(): return os.environ.get('LOGNAME') or os.environ.get('USER') def check_pid_on_remotehost(pid, host): """ Check For the existence of a unix pid on remote host. """ if pid == 0: return False cmd = Command(name='check pid on remote host', cmdStr='kill -0 %d' % pid, ctxt=REMOTE, remoteHost=host) cmd.run() if cmd.get_results().rc == 0: return True return False def check_pid(pid): """ Check For the existence of a unix pid. """ if pid == 0: return False try: os.kill(int(pid), signal.SIG_DFL) except OSError: return False else: return True """ Given the data directory, port and pid for a segment, kill -9 all the processes associated with that segment. If pid is -1, then the postmaster is already stopped, so we check for any leftover processes for that segment and kill -9 those processes E.g postgres: port 45002, logger process postgres: port 45002, sweeper process postgres: port 45002, checkpoint process """ def kill_9_segment_processes(datadir, port, pid): logger.info('Terminating processes for segment %s' % datadir) pid_list = [] # pid is the pid of the postgres process. # pid can be -1 if the process is down already if pid != -1: pid_list = [pid] cmd = Command('get a list of processes to kill -9', cmdStr='ps ux | grep "[p]ostgres:\s*port\s*%s" | awk \'{print $2}\'' % (port)) try: cmd.run(validateAfter=True) except Exception as e: logger.warning('Unable to get the pid list of processes for segment %s: (%s)' % (datadir, str(e))) return results = cmd.get_results() results = results.stdout.strip().split('\n') for result in results: if result: pid_list.append(int(result)) for pid in pid_list: # Try to kill -9 the process. # We ignore any errors try: os.kill(pid, signal.SIGKILL) except Exception as e: logger.error('Failed to kill processes for segment %s: (%s)' % (datadir, str(e))) def logandkill(pid, sig): msgs = { signal.SIGCONT: "Sending SIGSCONT to %d", signal.SIGTERM: "Sending SIGTERM to %d (smart shutdown)", signal.SIGINT: "Sending SIGINT to %d (fast shutdown)", signal.SIGQUIT: "Sending SIGQUIT to %d (immediate shutdown)", signal.SIGABRT: "Sending SIGABRT to %d" } logger.info(msgs[sig] % pid) os.kill(pid, sig) def kill_sequence(pid): if not check_pid(pid): return # first send SIGCONT in case the process is stopped logandkill(pid, signal.SIGCONT) # next try SIGTERM (smart shutdown) logandkill(pid, signal.SIGTERM) # give process a few seconds to exit for i in range(0,3): time.sleep(1) if not check_pid(pid): return # next try SIGINT (fast shutdown) logandkill(pid, signal.SIGINT) # give process a few more seconds to exit for i in range(0,3): time.sleep(1) if not check_pid(pid): return # next try SIGQUIT (immediate shutdown) logandkill(pid, signal.SIGQUIT) # give process a final few seconds to exit for i in range(0,5): time.sleep(1) if not check_pid(pid): return # all else failed - try SIGABRT logandkill(pid, signal.SIGABRT) #---------------Platform Framework-------------------- """ The following platform framework is used to handle any differences between the platform's we support. The GenericPlatform class is the base class that a supported platform extends from and overrides any of the methods as necessary. TODO: should the platform stuff be broken out to separate module? """ class GenericPlatform(): def getName(self): "unsupported" def getDefaultLocale(self): return 'en_US.utf-8' def get_machine_arch_cmd(self): return 'uname -i' def getPingOnceCmd(self): pass def getDiskFreeCmd(self): return findCmdInPath('df') + " -k" def getTarCmd(self): return findCmdInPath('tar') def getCpCmd(self): return findCmdInPath('cp') def getSadcCmd(self, interval, outfilename): return None def getIfconfigCmd(self): return findCmdInPath('ifconfig') def getMountDevFirst(self): return True class LinuxPlatform(GenericPlatform): def __init__(self): pass def getName(self): return "linux" def getDefaultLocale(self): return 'en_US.utf8' def getDiskFreeCmd(self): # -P is for POSIX formatting. Prevents error # on lines that would wrap return findCmdInPath('df') + " -Pk" def getSadcCmd(self, interval, outfilename): cmd = "/usr/lib64/sa/sadc -F -d " + str(interval) + " " + outfilename return cmd def getMountDevFirst(self): return True def getPing6(self): return findCmdInPath('ping6') class SolarisPlatform(GenericPlatform): def __init__(self): pass def getName(self): return "sunos" def getDefaultLocale(self): return 'en_US.UTF-8' def getDiskFreeCmd(self): return findCmdInPath('df') + " -bk" def getTarCmd(self): return findCmdInPath('gtar') def getSadcCmd(self, interval, outfilename): cmd = "/usr/lib/sa/sadc " + str(interval) + " 100000 " + outfilename return cmd def getIfconfigCmd(self): return findCmdInPath('ifconfig') + ' -a inet' def getMountDevFirst(self): return False class DarwinPlatform(GenericPlatform): def __init__(self): pass def getName(self): return "darwin" def get_machine_arch_cmd(self): return 'uname -m' def getMountDevFirst(self): return True def getPing6(self): return findCmdInPath('ping6') class FreeBsdPlatform(GenericPlatform): def __init__(self): pass def getName(self): return "freebsd" def get_machine_arch_cmd(self): return 'uname -m' def getMountDevFirst(self): return True """ if self.SYSTEM == 'sunos': self.PS_TXT='ef' self.LIB_TYPE='LD_LIBRARY_PATH' self.ZCAT='gzcat' self.PG_METHOD='trust' self.NOLINE_ECHO='/usr/bin/echo' self.MAIL='/bin/mailx' self.PING_TIME='1' self.DF=findCmdInPath('df') self.DU_TXT='-s' elif self.SYSTEM == 'linux': self.PS_TXT='ax' self.LIB_TYPE='LD_LIBRARY_PATH' self.PG_METHOD='ident sameuser' self.NOLINE_ECHO='%s -e' % self.ECHO self.PING_TIME='-c 1' self.DF='%s -P' % findCmdInPath('df') self.DU_TXT='c' elif self.SYSTEM == 'darwin': self.PS_TXT='ax' self.LIB_TYPE='DYLD_LIBRARY_PATH' self.PG_METHOD='ident sameuser' self.NOLINE_ECHO= self.ECHO self.PING_TIME='-c 1' self.DF='%s -P' % findCmdInPath('df') self.DU_TXT='-c' elif self.SYSTEM == 'freebsd': self.PS_TXT='ax' self.LIB_TYPE='LD_LIBRARY_PATH' self.PG_METHOD='ident sameuser' self.NOLINE_ECHO='%s -e' % self.ECHO self.PING_TIME='-c 1' self.DF='%s -P' % findCmdInPath('df') self.DU_TXT='-c' """ #---------------ping-------------------- class Ping(Command): def __init__(self,name,hostToPing,ctxt=LOCAL,remoteHost=None,obj=None): self.hostToPing=hostToPing self.obj=obj pingToUse = findCmdInPath('ping') if curr_platform == LINUX or curr_platform == DARWIN: # Get the family of the address we need to ping. If it's AF_INET6 # we must use ping6 to ping it. addrinfo = socket.getaddrinfo(hostToPing, None) if addrinfo and addrinfo[0] and addrinfo[0][0] == socket.AF_INET6: pingToUse = SYSTEM.getPing6() cmdStr = "%s -c 1 %s" % (pingToUse,hostToPing) Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def ping_list(host_list): for host in host_list: yield Ping("ping",host,ctxt=LOCAL,remoteHost=None) @staticmethod def local(name,hostToPing): p=Ping(name,hostToPing) p.run(validateAfter=True) @staticmethod def remote(name,hostToPing,hostToPingFrom): p=Ping(name,hostToPing,ctxt=REMOTE,remoteHost=hostToPingFrom) p.run(validateAfter=True) #---------------du-------------------- class DiskUsage(Command): def __init__(self,name,directory,ctxt=LOCAL,remoteHost=None): self.directory=directory if remoteHost: cmdStr="ls -l -R %s | %s ^- | %s '{t+=\$5;} END{print t}'" % (directory,findCmdInPath('grep'), findCmdInPath('awk')) else: cmdStr="ls -l -R %s | %s ^- | %s '{t+=$5;} END{print t}'" % (directory,findCmdInPath('grep'), findCmdInPath('awk')) Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def get_size(name,remote_host,directory): duCmd=DiskUsage(name,directory,ctxt=REMOTE,remoteHost=remote_host) duCmd.run(validateAfter=True) return duCmd.get_bytes_used() def get_bytes_used(self): rawIn=self.results.stdout.split('\t')[0].strip() #TODO: revisit this idea of parsing '' and making it a 0. seems dangerous. if rawIn == '': return 0 if rawIn[0] == 'd': raise ExecutionError("du command could not find directory: cmd: %s" "resulted in stdout: '%s' stderr: '%s'" % (self.cmdStr, self.results.stdout, self.results.stderr), self) else: dirBytes=int(rawIn) return dirBytes #-------------df---------------------- class DiskFree(Command): def __init__(self,name,directory,ctxt=LOCAL,remoteHost=None): self.directory=directory cmdStr="%s %s" % (SYSTEM.getDiskFreeCmd(),directory) Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def get_size(name,remote_host,directory): dfCmd=DiskFree(name,directory,ctxt=REMOTE,remoteHost=remote_host) dfCmd.run(validateAfter=True) return dfCmd.get_bytes_free() @staticmethod def get_size_local(name, directory): dfCmd=DiskFree(name,directory) dfCmd.run(validateAfter=True) return dfCmd.get_bytes_free() @staticmethod def get_disk_free_info_local(name, directory): dfCmd = DiskFree(name,directory) dfCmd.run(validateAfter=True) return dfCmd.get_disk_free_output() def get_disk_free_output(self): '''expected output of the form: Filesystem 512-blocks Used Available Capacity Mounted on /dev/disk0s2 194699744 158681544 35506200 82% / Returns data in list format: ['/dev/disk0s2', '194699744', '158681544', '35506200', '82%', '/'] ''' rawIn = self.results.stdout.split('\n')[1] return rawIn.split(); def get_bytes_free(self): disk_free = self.get_disk_free_output() bytesFree = int(disk_free[3])*1024 return bytesFree #-------------mkdir------------------ class MakeDirectory(Command): def __init__(self,name,directory,ctxt=LOCAL,remoteHost=None): self.directory=directory cmdStr="%s -p %s" % (findCmdInPath('mkdir'),directory) Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def local(name,directory): mkdirCmd=MakeDirectory(name,directory) mkdirCmd.run(validateAfter=True) @staticmethod def remote(name,remote_host,directory): mkdirCmd=MakeDirectory(name,directory,ctxt=REMOTE,remoteHost=remote_host) mkdirCmd.run(validateAfter=True) #-------------mv------------------ class MoveDirectory(Command): def __init__(self,name,srcDirectory,dstDirectory,ctxt=LOCAL,remoteHost=None): self.srcDirectory=srcDirectory self.dstDirectory=dstDirectory cmdStr="%s -f %s %s" % (findCmdInPath('mv'),srcDirectory,dstDirectory) Command.__init__(self,name,cmdStr,ctxt,remoteHost) #-------------append------------------ class AppendTextToFile(Command): def __init__(self,name,file,text,ctxt=LOCAL,remoteHost=None): cmdStr="echo '%s' >> %s" % (text, file) Command.__init__(self,name,cmdStr,ctxt,remoteHost) #-------------inline perl replace------ class InlinePerlReplace(Command): def __init__(self, name, fromStr, toStr, file, ctxt=LOCAL,remoteHost=None): cmdStr="%s -pi.bak -e's/%s/%s/g' %s" % (findCmdInPath('perl'), fromStr, toStr, file) Command.__init__(self,name,cmdStr,ctxt,remoteHost) #-------------rmdir------------------ class RemoveDirectory(Command): def __init__(self,name,directory,ctxt=LOCAL,remoteHost=None): self.directory=directory cmdStr="%s %s" % (findCmdInPath('rmdir'),directory) Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def local(name,directory): rmCmd=RemoveDirectory(name,directory) rmCmd.run(validateAfter=True) @staticmethod def remote(name,remote_host,directory): rmCmd=RemoveDirectory(name,directory,ctxt=REMOTE,remoteHost=remote_host) rmCmd.run(validateAfter=True) #-------------rm -rf ------------------ class RemoveFiles(Command): def __init__(self,name,directory,ctxt=LOCAL,remoteHost=None): self.directory=directory cmdStr="%s -rf %s" % (findCmdInPath('rm'),directory) Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def remote(name,remote_host,directory): rmCmd=RemoveFiles(name,directory,ctxt=REMOTE,remoteHost=remote_host) rmCmd.run(validateAfter=True) @staticmethod def local(name,directory): rmCmd=RemoveFiles(name,directory) rmCmd.run(validateAfter=True) #-------------file and dir existence ------------- class PathIsDirectory(Command): def __init__(self,name,directory,ctxt=LOCAL,remoteHost=None): self.directory=directory cmdStr="""python -c "import os; print os.path.isdir('%s')" """ % directory Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def remote(name,remote_host,directory): cmd=PathIsDirectory(name,directory,ctxt=REMOTE,remoteHost=remote_host) cmd.run(validateAfter=True) return cmd.isDir() def isDir(self): return bool (self.results.stdout.strip()) #-------------------------- class FileDirExists(Command): def __init__(self,name,directory,ctxt=LOCAL,remoteHost=None): self.directory=directory cmdStr="""python -c "import os; print os.path.exists('%s')" """ % directory Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def remote(name,remote_host,directory): cmd=FileDirExists(name,directory,ctxt=REMOTE,remoteHost=remote_host) cmd.run(validateAfter=True) return cmd.filedir_exists() def filedir_exists(self): return self.results.stdout.strip().upper()=='TRUE' class CreateDirIfNecessary(Command): def __init__(self,name,directory,ctxt=LOCAL,remoteHost=None): self.directory=directory cmdStr="""python -c "import sys, os, errno; try: os.mkdir('%s') except OSError, ex: if ex.errno != errno.EEXIST: raise " """ % (directory) Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def remote(name,remote_host,directory): cmd=CreateDirIfNecessary(name,directory,ctxt=REMOTE,remoteHost=remote_host) cmd.run(validateAfter=True) class DirectoryIsEmpty(Command): def __init__(self,name,directory,ctxt=LOCAL,remoteHost=None): self.directory=directory cmdStr="""python -c "import os; for root, dirs, files in os.walk('%s'): print (len(dirs) != 0 or len(files) != 0) " """ % self.directory Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def remote(name,remote_host,directory): cmd=DirectoryIsEmpty(name,directory,ctxt=REMOTE,remoteHost=remote_host) cmd.run(validateAfter=True) return cmd.isEmpty() def isEmpty(self): return bool (self.results.stdout.strip()) #-------------scp------------------ # MPP-13617 def canonicalize(addr): if ':' not in addr: return addr if '[' in addr: return addr return '[' + addr + ']' class RemoteCopy(Command): def __init__(self,name,srcDirectory,dstHost,dstDirectory,ctxt=LOCAL,remoteHost=None): self.srcDirectory=srcDirectory self.dstHost=dstHost self.dstDirectory=dstDirectory cmdStr="%s -o 'StrictHostKeyChecking no' -r %s %s:%s" % (findCmdInPath('scp'),srcDirectory,canonicalize(dstHost),dstDirectory) Command.__init__(self,name,cmdStr,ctxt,remoteHost) class Scp(Command): def __init__(self,name,srcFile, dstFile, srcHost=None, dstHost=None,recursive=False,ctxt=LOCAL,remoteHost=None): cmdStr = findCmdInPath('scp') + " " if recursive: cmdStr = cmdStr + "-r " if srcHost: cmdStr = cmdStr + canonicalize(srcHost) + ":" cmdStr = cmdStr + srcFile + " " if dstHost: cmdStr = cmdStr + canonicalize(dstHost) + ":" cmdStr = cmdStr + dstFile Command.__init__(self,name,cmdStr,ctxt,remoteHost) #-------------local copy------------------ class LocalDirCopy(Command): def __init__(self,name,srcDirectory,dstDirectory): # tar is much faster than cp for directories with lots of files self.srcDirectory=srcDirectory self.dstDirectory=dstDirectory tarCmd = SYSTEM.getTarCmd() cmdStr="%s -cf - -C %s . | %s -xf - -C %s" % (tarCmd,srcDirectory,tarCmd,dstDirectory) Command.__init__(self,name,cmdStr,LOCAL, None) #-------------local copy------------------ class LocalCopy(Command): def __init__(self,name,srcFile,dstFile): # tar is much faster than cp for directories with lots of files cpCmd = SYSTEM.getCpCmd() cmdStr="%s %s %s" % (cpCmd,srcFile,dstFile) Command.__init__(self,name,cmdStr,LOCAL, None) #------------ ssh + tar ------------------ #TODO: impl this. #tar czf - srcDir/ | ssh user@dstHost tar xzf - -C dstDir #-------------create tar------------------ class CreateTar(Command): def __init__(self,name,srcDirectory,dstTarFile,ctxt=LOCAL,remoteHost=None): self.srcDirectory=srcDirectory self.dstTarFile=dstTarFile tarCmd = SYSTEM.getTarCmd() cmdStr="%s cvPf %s -C %s ." % (tarCmd, self.dstTarFile,srcDirectory) Command.__init__(self,name,cmdStr,ctxt,remoteHost) #-------------extract tar--------------------- class ExtractTar(Command): def __init__(self,name,srcTarFile,dstDirectory,ctxt=LOCAL,remoteHost=None): self.srcTarFile=srcTarFile self.dstDirectory=dstDirectory tarCmd = SYSTEM.getTarCmd() cmdStr="%s -C %s -xf %s" % (tarCmd, dstDirectory, srcTarFile) Command.__init__(self,name,cmdStr,ctxt,remoteHost) #--------------kill ---------------------- class Kill(Command): def __init__(self,name,pid,signal,ctxt=LOCAL,remoteHost=None): self.pid=pid self.signal=signal cmdStr="%s -s %s %s" % (findCmdInPath('kill'), signal, pid) Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def local(name,pid,signal): cmd=Kill(name,pid,signal) cmd.run(validateAfter=True) @staticmethod def remote(name,pid,signal,remote_host): cmd=Kill(name,pid,signal,ctxt=REMOTE,remoteHost=remote_host) cmd.run(validateAfter=True) #--------------kill children-------------- class KillChildren(Command): def __init__(self,name,pid,signal,ctxt=LOCAL,remoteHost=None): self.pid=pid self.signal=signal cmdStr="%s -%s -P %s" % (findCmdInPath('pkill'), signal, pid) Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def local(name,pid,signal): cmd=KillChildren(name,pid,signal) cmd.run(validateAfter=True) @staticmethod def remote(name,pid,signal,remote_host): cmd=KillChildren(name,pid,signal,ctxt=REMOTE,remoteHost=remote_host) cmd.run(validateAfter=True) #--------------pkill---------------------- class Pkill(Command): def __init__(self,name,processname,signal=signal.SIGTERM,ctxt=LOCAL,remoteHost=None): cmdStr="%s -%s %s" % (findCmdInPath('pkill'), signal, processname) Command.__init__(self,name,cmdStr,ctxt,remoteHost) #--------------sadc----------------------- class Sadc(Command): def __init__(self,name, outfilename, interval=5, background=False, ctxt=LOCAL, remoteHost=None): cmdStr = SYSTEM.getSadcCmd(interval, outfilename) if background: cmdStr = "rm " + outfilename + "; nohup " + cmdStr + " < /dev/null > /dev/null 2>&1 &" Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def local(name, outfilename, interval, background): cmd=Sadc(name, outfilename, interval, background) cmd.run(validateAfter=True) @staticmethod def remote(name, outfilename, interval, background, remote_host): cmd=Sadc(name, outfilename, interval, background, ctxt=REMOTE, remoteHost=remote_host) cmd.run(validateAfter=True) #--------------hostname ---------------------- class Hostname(Command): def __init__(self, name, ctxt=LOCAL, remoteHost=None): self.remotehost=remoteHost Command.__init__(self, name, findCmdInPath('hostname'), ctxt, remoteHost) def get_hostname(self): if not self.results: raise Exception, 'Command not yet executed' return self.results.stdout.strip() class InterfaceAddrs(Command): """Returns list of interface IP Addresses. List does not include loopback.""" def __init__(self, name, ctxt=LOCAL, remoteHost=None): ifconfig = SYSTEM.getIfconfigCmd() grep = findCmdInPath('grep') awk = findCmdInPath('awk') cut = findCmdInPath('cut') cmdStr = '%s|%s "inet "|%s -v "127.0.0"|%s \'{print \$2}\'|%s -d: -f2' % (ifconfig, grep, grep, awk, cut) Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def local(name): cmd=InterfaceAddrs(name) cmd.run(validateAfter=True) return cmd.get_results().stdout.split() @staticmethod def remote(name, remoteHost): cmd=InterfaceAddrs(name, ctxt=REMOTE, remoteHost=remoteHost) cmd.run(validateAfter=True) return cmd.get_results().stdout.split() class FileContainsTerm(Command): def __init__(self, name, search_term, file, ctxt=LOCAL, remoteHost=None): self.search_term=search_term self.file=file cmdStr="%s -c %s %s" % (findCmdInPath('grep'),search_term,file) Command.__init__(self,name,cmdStr,ctxt,remoteHost) def contains_term(self): if not self.results: raise Exception, 'Command not yet executed' count=int(self.results.stdout.strip()) if count == 0: return False else: return True #--------------tcp port is active ----------------------- class PgPortIsActive(Command): def __init__(self,name,port,file,ctxt=LOCAL, remoteHost=None): self.port=port cmdStr="%s -an 2>/dev/null | %s %s | %s '{print $NF}'" %\ (findCmdInPath('netstat'),findCmdInPath('grep'),file,findCmdInPath('awk')) Command.__init__(self,name,cmdStr,ctxt,remoteHost) def contains_port(self): rows=self.results.stdout.strip().split() if len(rows) == 0: return False for r in rows: val = r.split('.') netstatport = int(val[ len(val) - 1 ]) if netstatport == self.port: return True return False @staticmethod def local(name,file,port): cmd=PgPortIsActive(name,port,file) cmd.run(validateAfter=True) return cmd.contains_port() @staticmethod def remote(name,file,port,remoteHost): cmd=PgPortIsActive(name,port,file,ctxt=REMOTE,remoteHost=remoteHost) cmd.run(validateAfter=True) return cmd.contains_port() #--------------chmod ---------------------- class Chmod(Command): def __init__(self, name, dir, perm, ctxt=LOCAL, remoteHost=None): cmdStr = '%s %s %s' % (findCmdInPath('chmod'), perm, dir) Command.__init__(self, name, cmdStr, ctxt, remoteHost) @staticmethod def local(name, dir, perm): cmd=Chmod(name, dir, perm) cmd.run(validateAfter=True) @staticmethod def remote(name, hostname, dir, perm): cmd=Chmod(name, dir, perm, ctxt=REMOTE, remoteHost=hostname) cmd.run(validateAfter=True) #--------------echo ---------------------- class Echo(Command): def __init__(self, name, echoString, ctxt=LOCAL, remoteHost=None): cmdStr = '%s "%s"' % (findCmdInPath('echo'), echoString) Command.__init__(self, name, cmdStr, ctxt, remoteHost) @staticmethod def remote(name, echoString, hostname): cmd = Echo(name, echoString, ctxt=REMOTE, remoteHost=hostname) cmd.run(validateAfter=True) #--------------touch ---------------------- class Touch(Command): def __init__(self, name, file, ctxt=LOCAL, remoteHost=None): cmdStr = '%s %s' % (findCmdInPath('touch'), file) Command.__init__(self, name, cmdStr, ctxt, remoteHost) @staticmethod def remote(name, file, hostname): cmd = Touch(name, file, ctxt=REMOTE, remoteHost=hostname) cmd.run(validateAfter=True) #--------------get user id ---------------------- class UserId(Command): def __init__(self, name, ctxt=LOCAL, remoteHost=None): idCmd = findCmdInPath('id') trCmd = findCmdInPath('tr') awkCmd = findCmdInPath('awk') cmdStr = "%s|%s '(' ' '|%s ')' ' '|%s '{print $2}'" % (idCmd, trCmd, trCmd, awkCmd) Command.__init__(self, name, cmdStr, ctxt, remoteHost) @staticmethod def local(name): cmd=UserId(name) cmd.run(validateAfter=True) return cmd.results.stdout.strip() #-------------- test file for setuid bit ---------------------- class FileTestSuid(Command): def __init__(self,name,filename,ctxt=LOCAL,remoteHost=None): cmdStr="""python -c "import os; import stat; testRes = os.stat('%s'); print (testRes.st_mode & stat.S_ISUID) == stat.S_ISUID" """ % filename Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def remote(name,remote_host,filename): cmd=FileTestSuid(name,filename,ctxt=REMOTE,remoteHost=remote_host) cmd.run(validateAfter=True) return cmd.file_is_suid() def file_is_suid(self): return self.results.stdout.strip().upper()=='TRUE' #-------------- get file owner ---------------------- class FileGetOwnerUid(Command): def __init__(self,name,filename,ctxt=LOCAL,remoteHost=None): cmdStr="""python -c "import os; import stat; testRes = os.stat('%s'); print testRes.st_uid " """ % filename Command.__init__(self,name,cmdStr,ctxt,remoteHost) @staticmethod def remote(name,remote_host,filename): cmd=FileGetOwnerUid(name,filename,ctxt=REMOTE,remoteHost=remote_host) cmd.run(validateAfter=True) return cmd.file_uid() def file_uid(self): return int(self.results.stdout.strip().upper()) #--------------get list of desecendant processes ------------------- def getDescendentProcesses(pid): ''' return all process pids which are descendant from the given processid ''' children_pids = [] for p in psutil.Process(pid).children(recursive=True): if p.is_running(): children_pids.append(p.pid) return children_pids #--------------global variable initialization ---------------------- if curr_platform == SUNOS: SYSTEM = SolarisPlatform() elif curr_platform == LINUX: SYSTEM = LinuxPlatform() elif curr_platform == DARWIN: SYSTEM = DarwinPlatform() elif curr_platform == FREEBSD: SYSTEM = FreeBsdPlatform() else: raise Exception("Platform %s is not supported. Supported platforms are:"\ " %s", SYSTEM, str(platform_list))
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 67, 9, 32585, 1168, 453, 3277, 9079, 14, 2900, 5924, 5702, 14, 221, 199, 3, 199, 624, 199, 1084, 402, 27939, 367, 14043, 16572, 3718, 14, 421, 199, 624, 199, 646, 747, 199, 646, 22214, 199, 646, 4298, 199, 646, 2838, 199, 646, 984, 199, 646, 4673, 199, 199, 504, 15852, 24111, 14, 4927, 793, 492, 627, 199, 504, 15852, 24111, 14, 4405, 14, 1095, 492, 627, 421, 199, 2921, 275, 15852, 793, 14, 362, 63, 885, 63, 2921, 342, 199, 199, 3, 18964, 19601, 777, 375, 199, 3, 2966, 1750, 367, 4154, 4298, 199, 12711, 628, 5187, 2, 199, 199, 23627, 3100, 628, 11846, 736, 2, 199, 26030, 628, 5135, 2, 199, 36, 689, 7941, 628, 13245, 2, 199, 28170, 15400, 628, 29629, 2, 199, 3246, 63, 513, 275, 359, 23627, 3100, 12, 26030, 12, 36, 689, 7941, 12, 28170, 15400, 61, 199, 199, 9808, 63, 3246, 275, 4298, 14, 16040, 3430, 16, 1055, 2325, 342, 199, 199, 8225, 9524, 29, 736, 14, 2314, 14, 362, 360, 8225, 9524, 297, 488, 9, 421, 199, 3, 18964, 1531, 931, 777, 375, 199, 199, 9744, 3243, 275, 18744, 2647, 15, 2570, 23920, 15, 1393, 297, 1994, 2647, 15, 7646, 87, 15, 1393, 297, 1994, 2992, 15, 7646, 87, 15, 1393, 297, 1994, 1393, 297, 1994, 2647, 15, 1832, 15, 1393, 297, 19056, 1994, 2647, 15, 1393, 297, 1994, 21457, 297, 1994, 2647, 15, 21457, 297, 1994, 2647, 15, 9573, 297, 1994, 3519, 15, 1393, 297, 1994, 2992, 15, 31488, 27474, 1681, 15, 1393, 418, 199, 199, 692, 17346, 9524, 26, 272, 25548, 3243, 14, 740, 8, 8225, 9524, 9, 199, 199, 9744, 63, 8677, 275, 1052, 421, 199, 3, 1444, 306, 199, 199, 533, 5817, 22646, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 1760, 12, 3771, 304, 267, 291, 14, 1760, 29, 1760, 267, 291, 14, 3771, 29, 3771, 272, 347, 636, 495, 721, 277, 304, 267, 372, 298, 6531, 440, 16592, 1414, 26, 1543, 83, 7, 315, 642, 663, 402, 3792, 26, 450, 83, 2, 450, 334, 277, 14, 1760, 12, 2722, 8, 277, 14, 3771, 430, 1362, 16872, 199, 318, 2342, 7874, 607, 2042, 8, 1760, 12, 4722, 11804, 6034, 870, 547, 29, 549, 304, 272, 2288, 25548, 63, 8677, 339, 340, 2088, 440, 315, 25548, 63, 8677, 26, 267, 327, 8730, 4722, 3792, 436, 2793, 1133, 1050, 370, 2581, 14, 267, 367, 299, 315, 4722, 11804, 26, 288, 289, 275, 747, 14, 515, 14, 904, 8, 80, 12, 2088, 9, 288, 340, 747, 14, 515, 14, 2444, 8, 70, 304, 355, 372, 289, 10631, 367, 299, 315, 25548, 3243, 26, 288, 289, 275, 747, 14, 515, 14, 904, 8, 80, 12, 2088, 9, 288, 340, 747, 14, 515, 14, 2444, 8, 70, 304, 355, 25548, 63, 8677, 59, 1760, 61, 275, 289, 355, 372, 289, 10631, 340, 870, 547, 26, 288, 2512, 14, 13138, 360, 3110, 450, 83, 440, 1911, 7, 450, 2088, 9, 267, 2754, 63, 515, 275, 25548, 3243, 5873, 267, 2754, 63, 515, 14, 2880, 8, 8460, 11804, 9, 267, 746, 5817, 22646, 8, 1760, 12, 1733, 63, 515, 9, 272, 587, 26, 267, 372, 25548, 63, 8677, 59, 1760, 61, 26339, 199, 3, 1858, 3063, 781, 7171, 10137, 2005, 7809, 3423, 9682, 402, 314, 16078, 10059, 258, 199, 318, 664, 5339, 25680, 837, 272, 372, 2838, 14, 29789, 1252, 1294, 19237, 16, 61, 199, 199, 318, 664, 25108, 837, 272, 372, 747, 14, 2314, 14, 362, 360, 4947, 2339, 358, 503, 747, 14, 2314, 14, 362, 360, 3791, 358, 199, 199, 318, 1104, 63, 3150, 63, 265, 63, 3846, 1102, 8, 3150, 12, 1591, 304, 272, 408, 2670, 2104, 314, 23780, 402, 282, 16572, 4422, 641, 3982, 1591, 14, 408, 2286, 340, 4422, 508, 378, 26, 267, 372, 756, 339, 2088, 275, 5817, 8, 354, 534, 1074, 4422, 641, 3982, 1591, 297, 2088, 2848, 534, 8997, 446, 16, 450, 68, 7, 450, 4422, 12, 11216, 29, 16058, 12, 3982, 4965, 29, 1102, 9, 272, 2088, 14, 1065, 342, 272, 340, 2088, 14, 362, 63, 2604, 1252, 1195, 508, 378, 26, 267, 372, 715, 339, 372, 756, 199, 199, 318, 1104, 63, 3150, 8, 3150, 304, 260, 272, 408, 2670, 2104, 314, 23780, 402, 282, 16572, 4422, 14, 408, 2286, 340, 4422, 508, 378, 26, 267, 372, 756, 2286, 862, 26, 267, 747, 14, 8997, 8, 442, 8, 3150, 395, 4673, 14, 7864, 63, 36, 3143, 9, 272, 871, 6440, 26, 267, 372, 756, 272, 587, 26, 267, 372, 715, 199, 199, 624, 199, 13735, 314, 666, 2082, 12, 1844, 436, 4422, 367, 282, 8135, 12, 221, 199, 8997, 446, 25, 1006, 314, 10358, 4568, 543, 626, 8135, 14, 199, 3917, 4422, 365, 446, 17, 12, 2066, 314, 2963, 4133, 365, 2575, 15248, 12, 221, 199, 1152, 781, 1104, 367, 1263, 32196, 10358, 367, 626, 8135, 221, 199, 460, 14561, 446, 25, 5204, 10358, 199, 37, 14, 71, 19533, 26, 1844, 841, 5783, 18, 12, 2512, 2112, 272, 19533, 26, 1844, 841, 5783, 18, 12, 5584, 1024, 529, 2112, 272, 19533, 26, 1844, 841, 5783, 18, 12, 9997, 2112, 199, 624, 199, 318, 14561, 63, 25, 63, 9255, 63, 11816, 8, 18259, 12, 1844, 12, 4422, 304, 272, 2512, 14, 815, 360, 12154, 1958, 10358, 367, 8135, 450, 83, 7, 450, 666, 694, 9, 5493, 4422, 63, 513, 275, 942, 339, 327, 4422, 365, 314, 4422, 402, 314, 19533, 2112, 14, 272, 327, 4422, 883, 506, 446, 17, 340, 314, 2112, 365, 3224, 2575, 272, 340, 4422, 1137, 446, 17, 26, 267, 4422, 63, 513, 275, 359, 3150, 61, 339, 2088, 275, 5817, 360, 362, 282, 769, 402, 10358, 370, 14561, 446, 25, 297, 2088, 2848, 534, 1190, 399, 88, 1204, 20595, 7369, 80, 61, 941, 7266, 3427, 83, 10, 719, 60, 83, 32639, 83, 2, 1204, 282, 14947, 8891, 91, 1361, 2672, 18, 4988, 891, 450, 334, 719, 430, 339, 862, 26, 267, 2088, 14, 1065, 8, 3502, 10881, 29, 549, 9, 272, 871, 2186, 465, 325, 26, 267, 2512, 14, 3764, 360, 6005, 370, 664, 314, 4422, 769, 402, 10358, 367 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 67, 9, 32585, 1168, 453, 3277, 9079, 14, 2900, 5924, 5702, 14, 221, 199, 3, 199, 624, 199, 1084, 402, 27939, 367, 14043, 16572, 3718, 14, 421, 199, 624, 199, 646, 747, 199, 646, 22214, 199, 646, 4298, 199, 646, 2838, 199, 646, 984, 199, 646, 4673, 199, 199, 504, 15852, 24111, 14, 4927, 793, 492, 627, 199, 504, 15852, 24111, 14, 4405, 14, 1095, 492, 627, 421, 199, 2921, 275, 15852, 793, 14, 362, 63, 885, 63, 2921, 342, 199, 199, 3, 18964, 19601, 777, 375, 199, 3, 2966, 1750, 367, 4154, 4298, 199, 12711, 628, 5187, 2, 199, 199, 23627, 3100, 628, 11846, 736, 2, 199, 26030, 628, 5135, 2, 199, 36, 689, 7941, 628, 13245, 2, 199, 28170, 15400, 628, 29629, 2, 199, 3246, 63, 513, 275, 359, 23627, 3100, 12, 26030, 12, 36, 689, 7941, 12, 28170, 15400, 61, 199, 199, 9808, 63, 3246, 275, 4298, 14, 16040, 3430, 16, 1055, 2325, 342, 199, 199, 8225, 9524, 29, 736, 14, 2314, 14, 362, 360, 8225, 9524, 297, 488, 9, 421, 199, 3, 18964, 1531, 931, 777, 375, 199, 199, 9744, 3243, 275, 18744, 2647, 15, 2570, 23920, 15, 1393, 297, 1994, 2647, 15, 7646, 87, 15, 1393, 297, 1994, 2992, 15, 7646, 87, 15, 1393, 297, 1994, 1393, 297, 1994, 2647, 15, 1832, 15, 1393, 297, 19056, 1994, 2647, 15, 1393, 297, 1994, 21457, 297, 1994, 2647, 15, 21457, 297, 1994, 2647, 15, 9573, 297, 1994, 3519, 15, 1393, 297, 1994, 2992, 15, 31488, 27474, 1681, 15, 1393, 418, 199, 199, 692, 17346, 9524, 26, 272, 25548, 3243, 14, 740, 8, 8225, 9524, 9, 199, 199, 9744, 63, 8677, 275, 1052, 421, 199, 3, 1444, 306, 199, 199, 533, 5817, 22646, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 1760, 12, 3771, 304, 267, 291, 14, 1760, 29, 1760, 267, 291, 14, 3771, 29, 3771, 272, 347, 636, 495, 721, 277, 304, 267, 372, 298, 6531, 440, 16592, 1414, 26, 1543, 83, 7, 315, 642, 663, 402, 3792, 26, 450, 83, 2, 450, 334, 277, 14, 1760, 12, 2722, 8, 277, 14, 3771, 430, 1362, 16872, 199, 318, 2342, 7874, 607, 2042, 8, 1760, 12, 4722, 11804, 6034, 870, 547, 29, 549, 304, 272, 2288, 25548, 63, 8677, 339, 340, 2088, 440, 315, 25548, 63, 8677, 26, 267, 327, 8730, 4722, 3792, 436, 2793, 1133, 1050, 370, 2581, 14, 267, 367, 299, 315, 4722, 11804, 26, 288, 289, 275, 747, 14, 515, 14, 904, 8, 80, 12, 2088, 9, 288, 340, 747, 14, 515, 14, 2444, 8, 70, 304, 355, 372, 289, 10631, 367, 299, 315, 25548, 3243, 26, 288, 289, 275, 747, 14, 515, 14, 904, 8, 80, 12, 2088, 9, 288, 340, 747, 14, 515, 14, 2444, 8, 70, 304, 355, 25548, 63, 8677, 59, 1760, 61, 275, 289, 355, 372, 289, 10631, 340, 870, 547, 26, 288, 2512, 14, 13138, 360, 3110, 450, 83, 440, 1911, 7, 450, 2088, 9, 267, 2754, 63, 515, 275, 25548, 3243, 5873, 267, 2754, 63, 515, 14, 2880, 8, 8460, 11804, 9, 267, 746, 5817, 22646, 8, 1760, 12, 1733, 63, 515, 9, 272, 587, 26, 267, 372, 25548, 63, 8677, 59, 1760, 61, 26339, 199, 3, 1858, 3063, 781, 7171, 10137, 2005, 7809, 3423, 9682, 402, 314, 16078, 10059, 258, 199, 318, 664, 5339, 25680, 837, 272, 372, 2838, 14, 29789, 1252, 1294, 19237, 16, 61, 199, 199, 318, 664, 25108, 837, 272, 372, 747, 14, 2314, 14, 362, 360, 4947, 2339, 358, 503, 747, 14, 2314, 14, 362, 360, 3791, 358, 199, 199, 318, 1104, 63, 3150, 63, 265, 63, 3846, 1102, 8, 3150, 12, 1591, 304, 272, 408, 2670, 2104, 314, 23780, 402, 282, 16572, 4422, 641, 3982, 1591, 14, 408, 2286, 340, 4422, 508, 378, 26, 267, 372, 756, 339, 2088, 275, 5817, 8, 354, 534, 1074, 4422, 641, 3982, 1591, 297, 2088, 2848, 534, 8997, 446, 16, 450, 68, 7, 450, 4422, 12, 11216, 29, 16058, 12, 3982, 4965, 29, 1102, 9, 272, 2088, 14, 1065, 342, 272, 340, 2088, 14, 362, 63, 2604, 1252, 1195, 508, 378, 26, 267, 372, 715, 339, 372, 756, 199, 199, 318, 1104, 63, 3150, 8, 3150, 304, 260, 272, 408, 2670, 2104, 314, 23780, 402, 282, 16572, 4422, 14, 408, 2286, 340, 4422, 508, 378, 26, 267, 372, 756, 2286, 862, 26, 267, 747, 14, 8997, 8, 442, 8, 3150, 395, 4673, 14, 7864, 63, 36, 3143, 9, 272, 871, 6440, 26, 267, 372, 756, 272, 587, 26, 267, 372, 715, 199, 199, 624, 199, 13735, 314, 666, 2082, 12, 1844, 436, 4422, 367, 282, 8135, 12, 221, 199, 8997, 446, 25, 1006, 314, 10358, 4568, 543, 626, 8135, 14, 199, 3917, 4422, 365, 446, 17, 12, 2066, 314, 2963, 4133, 365, 2575, 15248, 12, 221, 199, 1152, 781, 1104, 367, 1263, 32196, 10358, 367, 626, 8135, 221, 199, 460, 14561, 446, 25, 5204, 10358, 199, 37, 14, 71, 19533, 26, 1844, 841, 5783, 18, 12, 2512, 2112, 272, 19533, 26, 1844, 841, 5783, 18, 12, 5584, 1024, 529, 2112, 272, 19533, 26, 1844, 841, 5783, 18, 12, 9997, 2112, 199, 624, 199, 318, 14561, 63, 25, 63, 9255, 63, 11816, 8, 18259, 12, 1844, 12, 4422, 304, 272, 2512, 14, 815, 360, 12154, 1958, 10358, 367, 8135, 450, 83, 7, 450, 666, 694, 9, 5493, 4422, 63, 513, 275, 942, 339, 327, 4422, 365, 314, 4422, 402, 314, 19533, 2112, 14, 272, 327, 4422, 883, 506, 446, 17, 340, 314, 2112, 365, 3224, 2575, 272, 340, 4422, 1137, 446, 17, 26, 267, 4422, 63, 513, 275, 359, 3150, 61, 339, 2088, 275, 5817, 360, 362, 282, 769, 402, 10358, 370, 14561, 446, 25, 297, 2088, 2848, 534, 1190, 399, 88, 1204, 20595, 7369, 80, 61, 941, 7266, 3427, 83, 10, 719, 60, 83, 32639, 83, 2, 1204, 282, 14947, 8891, 91, 1361, 2672, 18, 4988, 891, 450, 334, 719, 430, 339, 862, 26, 267, 2088, 14, 1065, 8, 3502, 10881, 29, 549, 9, 272, 871, 2186, 465, 325, 26, 267, 2512, 14, 3764, 360, 6005, 370, 664, 314, 4422, 769, 402, 10358, 367, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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##################################################################################### # # Copyright (C) Tavendo GmbH # # Unless a separate license agreement exists between you and Tavendo GmbH (e.g. you # have purchased a commercial license), the license terms below apply. # # Should you enter into a separate license agreement after having received a copy of # this software, then the terms of such license agreement replace the terms below at # the time at which such license agreement becomes effective. # # In case a separate license agreement ends, and such agreement ends without being # replaced by another separate license agreement, the license terms below apply # from the time at which said agreement ends. # # LICENSE TERMS # # This program is free software: you can redistribute it and/or modify it under the # terms of the GNU Affero General Public License, version 3, as published by the # Free Software Foundation. This program is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # See the GNU Affero General Public License Version 3 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/agpl-3.0.en.html>. # ##################################################################################### from __future__ import absolute_import import os from twisted.internet import defer from twisted.internet.endpoints import TCP4ServerEndpoint, \ TCP6ServerEndpoint, \ TCP4ClientEndpoint, \ TCP6ClientEndpoint, \ UNIXServerEndpoint, \ UNIXClientEndpoint from twisted.python.compat import unicode try: from twisted.internet.endpoints import SSL4ServerEndpoint, \ SSL4ClientEndpoint from crossbar.twisted.tlsctx import TlsServerContextFactory, \ TlsClientContextFactory except ImportError: _HAS_TLS = False else: _HAS_TLS = True from crossbar.twisted.sharedport import SharedPort __all__ = ('create_listening_endpoint_from_config', 'create_listening_port_from_config', 'create_connecting_endpoint_from_config', 'create_connecting_port_from_config') def create_listening_endpoint_from_config(config, cbdir, reactor): """ Create a Twisted stream server endpoint from a Crossbar.io transport configuration. See: https://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IStreamServerEndpoint.html :param config: The transport configuration. :type config: dict :param cbdir: Crossbar.io node directory (we need this for TLS key/certificates). :type cbdir: str :param reactor: The reactor to use for endpoint creation. :type reactor: obj :returns obj -- An instance implementing IStreamServerEndpoint """ endpoint = None # a TCP endpoint # if config['type'] == 'tcp': # the TCP protocol version (v4 or v6) # version = int(config.get('version', 4)) # the listening port # if type(config['port']) in (str, unicode): # read port from environment variable .. try: port = int(os.environ[config['port'][1:]]) except Exception as e: print("Could not read listening port from env var: {}".format(e)) raise e else: port = config['port'] # the listening interface # interface = str(config.get('interface', '').strip()) # the TCP accept queue depth # backlog = int(config.get('backlog', 50)) if 'tls' in config: if _HAS_TLS: key_filepath = os.path.abspath(os.path.join(cbdir, config['tls']['key'])) cert_filepath = os.path.abspath(os.path.join(cbdir, config['tls']['certificate'])) with open(key_filepath) as key_file: with open(cert_filepath) as cert_file: if 'dhparam' in config['tls']: dhparam_filepath = os.path.abspath(os.path.join(cbdir, config['tls']['dhparam'])) else: dhparam_filepath = None # create a TLS context factory # key = key_file.read() cert = cert_file.read() ciphers = config['tls'].get('ciphers', None) ctx = TlsServerContextFactory(key, cert, ciphers=ciphers, dhParamFilename=dhparam_filepath) # create a TLS server endpoint # if version == 4: endpoint = SSL4ServerEndpoint(reactor, port, ctx, backlog=backlog, interface=interface) elif version == 6: raise Exception("TLS on IPv6 not implemented") else: raise Exception("invalid TCP protocol version {}".format(version)) else: raise Exception("TLS transport requested, but TLS packages not available") else: # create a non-TLS server endpoint # if version == 4: endpoint = TCP4ServerEndpoint(reactor, port, backlog=backlog, interface=interface) elif version == 6: endpoint = TCP6ServerEndpoint(reactor, port, backlog=backlog, interface=interface) else: raise Exception("invalid TCP protocol version {}".format(version)) # a Unix Domain Socket endpoint # elif config['type'] == 'unix': # the accept queue depth # backlog = int(config.get('backlog', 50)) # the path # path = os.path.abspath(os.path.join(cbdir, config['path'])) # create the endpoint # endpoint = UNIXServerEndpoint(reactor, path, backlog=backlog) else: raise Exception("invalid endpoint type '{}'".format(config['type'])) return endpoint def create_listening_port_from_config(config, factory, cbdir, reactor): """ Create a Twisted listening port from a Crossbar.io transport configuration. See: https://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IListeningPort.html :param config: The transport configuration. :type config: dict :param factory: The transport factory to use (a provider of IProtocolFactory). :type factory: obj :param cbdir: Crossbar.io node directory (we need this for TLS key/certificates). :type cbdir: str :param reactor: The reactor to use for endpoint creation. :type reactor: obj :returns obj -- A Deferred that results in an IListeningPort or an CannotListenError """ if config['type'] == 'tcp' and config.get('shared', False): # the TCP protocol version (v4 or v6) # FIXME: handle v6 # version = int(config.get('version', 4)) # the listening port # port = int(config['port']) # the listening interface # interface = str(config.get('interface', '').strip()) # the TCP accept queue depth # backlog = int(config.get('backlog', 50)) listening_port = SharedPort(port, factory, backlog, interface, reactor, shared=True) try: listening_port.startListening() return defer.succeed(listening_port) except Exception as e: return defer.fail(e) else: endpoint = create_listening_endpoint_from_config(config, cbdir, reactor) return endpoint.listen(factory) def create_connecting_endpoint_from_config(config, cbdir, reactor): """ Create a Twisted stream client endpoint from a Crossbar.io transport configuration. See: https://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IStreamClientEndpoint.html :param config: The transport configuration. :type config: dict :param cbdir: Crossbar.io node directory (we need this for Unix domain socket paths and TLS key/certificates). :type cbdir: str :param reactor: The reactor to use for endpoint creation. :type reactor: obj :returns obj -- An instance implementing IStreamClientEndpoint """ endpoint = None # a TCP endpoint # if config['type'] == 'tcp': # the TCP protocol version (v4 or v6) # version = int(config.get('version', 4)) # the host to connect to # host = str(config['host']) # the port to connect to # port = int(config['port']) # connection timeout in seconds # timeout = int(config.get('timeout', 10)) if 'tls' in config: if _HAS_TLS: ctx = TlsClientContextFactory() # create a TLS client endpoint # if version == 4: endpoint = SSL4ClientEndpoint(reactor, host, port, ctx, timeout=timeout) elif version == 6: raise Exception("TLS on IPv6 not implemented") else: raise Exception("invalid TCP protocol version {}".format(version)) else: raise Exception("TLS transport requested, but TLS packages not available") else: # create a non-TLS client endpoint # if version == 4: endpoint = TCP4ClientEndpoint(reactor, host, port, timeout=timeout) elif version == 6: endpoint = TCP6ClientEndpoint(reactor, host, port, timeout=timeout) else: raise Exception("invalid TCP protocol version {}".format(version)) # a Unix Domain Socket endpoint # elif config['type'] == 'unix': # the path # path = os.path.abspath(os.path.join(cbdir, config['path'])) # connection timeout in seconds # timeout = int(config.get('timeout', 10)) # create the endpoint # endpoint = UNIXClientEndpoint(reactor, path, timeout=timeout) else: raise Exception("invalid endpoint type '{}'".format(config['type'])) return endpoint def create_connecting_port_from_config(config, factory, cbdir, reactor): """ Create a Twisted connecting port from a Crossbar.io transport configuration. See: https://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IListeningPort.html :param config: The transport configuration. :type config: dict :param factory: The transport factory to use (a provider of IProtocolFactory). :type factory: obj :param cbdir: Crossbar.io node directory (we need this for Unix domain socket paths and TLS key/certificates). :type cbdir: str :param reactor: The reactor to use for endpoint creation. :type reactor: obj :returns obj -- A Deferred that results in an IProtocol upon successful connection otherwise a ConnectError """ endpoint = create_connecting_endpoint_from_config(config, cbdir, reactor) return endpoint.connect(factory)
agpl-3.0
[ 13289, 8776, 199, 3, 199, 3, 221, 1898, 334, 35, 9, 377, 1214, 500, 79, 23428, 199, 3, 199, 3, 221, 4158, 282, 7396, 4190, 25025, 3495, 3382, 1265, 436, 377, 1214, 500, 79, 23428, 334, 69, 14, 71, 14, 1265, 199, 3, 221, 1172, 15932, 68, 282, 2414, 23012, 4190, 395, 314, 4190, 2895, 5084, 4838, 14, 199, 3, 199, 3, 221, 7719, 1265, 9509, 1901, 282, 7396, 4190, 25025, 2410, 9445, 3086, 282, 1331, 402, 199, 3, 221, 642, 2032, 12, 2066, 314, 2895, 402, 4066, 4190, 25025, 3350, 314, 2895, 5084, 737, 199, 3, 221, 314, 900, 737, 1314, 4066, 4190, 25025, 15410, 15826, 14, 199, 3, 199, 3, 221, 1010, 1930, 282, 7396, 4190, 25025, 11187, 12, 436, 4066, 25025, 11187, 1928, 3769, 199, 3, 221, 8717, 701, 4573, 7396, 4190, 25025, 12, 314, 4190, 2895, 5084, 4838, 199, 3, 221, 687, 314, 900, 737, 1314, 25097, 25025, 11187, 14, 199, 3, 199, 3, 221, 5113, 31510, 3053, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 199, 3, 221, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 12, 1015, 650, 12, 465, 3267, 701, 314, 199, 3, 221, 2868, 2290, 2752, 14, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 199, 3, 221, 2997, 12, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 199, 3, 221, 1666, 314, 1664, 4265, 1696, 1684, 844, 3394, 650, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 4190, 3180, 199, 3, 221, 543, 642, 2240, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 643, 1168, 13, 19, 14, 16, 14, 287, 14, 1360, 10827, 199, 3, 199, 13289, 8776, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 747, 199, 199, 504, 7390, 14, 4901, 492, 10133, 199, 504, 7390, 14, 4901, 14, 14461, 492, 13488, 20, 3120, 11442, 12, 971, 272, 13488, 22, 3120, 11442, 12, 971, 272, 13488, 20, 3041, 11442, 12, 971, 272, 13488, 22, 3041, 11442, 12, 971, 272, 22242, 3120, 11442, 12, 971, 272, 22242, 3041, 11442, 199, 504, 7390, 14, 1548, 14, 5819, 492, 2649, 199, 199, 893, 26, 272, 687, 7390, 14, 4901, 14, 14461, 492, 7799, 20, 3120, 11442, 12, 971, 267, 7799, 20, 3041, 11442, 272, 687, 8059, 1700, 14, 12145, 14, 9945, 3799, 492, 377, 478, 3120, 2998, 2927, 12, 971, 267, 377, 478, 3041, 2998, 2927, 199, 2590, 3545, 26, 272, 485, 13533, 63, 10224, 275, 756, 199, 2836, 26, 272, 485, 13533, 63, 10224, 275, 715, 199, 199, 504, 8059, 1700, 14, 12145, 14, 5555, 719, 492, 23752, 4313, 199, 199, 363, 452, 363, 275, 661, 981, 63, 5859, 316, 63, 6520, 63, 504, 63, 888, 297, 1779, 283, 981, 63, 5859, 316, 63, 719, 63, 504, 63, 888, 297, 1779, 283, 981, 63, 2242, 316, 63, 6520, 63, 504, 63, 888, 297, 1779, 283, 981, 63, 2242, 316, 63, 719, 63, 504, 63, 888, 358, 421, 199, 318, 1218, 63, 5859, 316, 63, 6520, 63, 504, 63, 888, 8, 888, 12, 7434, 694, 12, 9655, 304, 272, 408, 272, 2790, 282, 17078, 2547, 1654, 6037, 687, 282, 28965, 1700, 14, 2308, 7773, 2897, 14, 339, 1666, 26, 4178, 921, 12145, 3642, 14, 957, 15, 12233, 15, 1818, 15, 1246, 15, 12145, 14, 4901, 14, 7436, 14, 41, 3296, 3120, 11442, 14, 1360, 339, 520, 635, 1101, 26, 710, 7773, 2897, 14, 272, 520, 466, 1101, 26, 1211, 272, 520, 635, 7434, 694, 26, 28965, 1700, 14, 2308, 1031, 2082, 334, 1129, 1929, 642, 367, 12213, 790, 15, 16159, 680, 272, 520, 466, 7434, 694, 26, 620, 272, 520, 635, 9655, 26, 710, 9655, 370, 675, 367, 6037, 7143, 14, 272, 520, 466, 9655, 26, 1559, 339, 520, 5808, 1559, 1553, 1626, 1256, 18234, 473, 3296, 3120, 11442, 272, 408, 272, 6037, 275, 488, 339, 327, 282, 13488, 6037, 272, 327, 272, 340, 1101, 459, 466, 418, 508, 283, 8815, 356, 398, 327, 314, 13488, 4113, 1015, 334, 86, 20, 503, 373, 22, 9, 267, 327, 267, 1015, 275, 1109, 8, 888, 14, 362, 360, 1023, 297, 841, 430, 398, 327, 314, 22721, 1844, 267, 327, 267, 340, 730, 8, 888, 459, 719, 1105, 315, 334, 495, 12, 2649, 304, 288, 327, 1586, 1844, 687, 3734, 1750, 2508, 288, 862, 26, 355, 1844, 275, 1109, 8, 736, 14, 2314, 59, 888, 459, 719, 3488, 17, 2938, 566, 288, 871, 2186, 465, 325, 26, 355, 870, 480, 6531, 440, 1586, 22721, 1844, 687, 2589, 2729, 26, 8352, 908, 8, 69, 430, 355, 746, 325, 267, 587, 26, 288, 1844, 275, 1101, 459, 719, 418, 398, 327, 314, 22721, 3217, 267, 327, 267, 3217, 275, 620, 8, 888, 14, 362, 360, 3266, 297, 12548, 1913, 1012, 398, 327, 314, 13488, 4729, 4126, 5818, 267, 327, 267, 1771, 793, 275, 1109, 8, 888, 14, 362, 360, 31267, 297, 5238, 430, 398, 340, 283, 9945, 7, 315, 1101, 26, 953, 340, 485, 13533, 63, 10224, 26, 355, 790, 63, 7218, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 2894, 694, 12, 1101, 459, 9945, 2545, 498, 5156, 355, 6250, 63, 7218, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 2894, 694, 12, 1101, 459, 9945, 2545, 6999, 5156, 2234, 543, 1551, 8, 498, 63, 7218, 9, 465, 790, 63, 493, 26, 490, 543, 1551, 8, 4736, 63, 7218, 9, 465, 6250, 63, 493, 26, 9453, 340, 283, 7821, 635, 7, 315, 1101, 459, 9945, 2565, 1169, 31387, 635, 63, 7218, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 2894, 694, 12, 1101, 459, 9945, 2545, 7821, 635, 5156, 717, 587, 26, 1169, 31387, 635, 63, 7218, 275, 488, 9453, 327, 1218, 282, 12213, 1067, 6434, 717, 327, 717, 790, 275, 790, 63, 493, 14, 739, 342, 717, 6250, 275, 6250, 63, 493, 14 ]
[ 8776, 199, 3, 199, 3, 221, 1898, 334, 35, 9, 377, 1214, 500, 79, 23428, 199, 3, 199, 3, 221, 4158, 282, 7396, 4190, 25025, 3495, 3382, 1265, 436, 377, 1214, 500, 79, 23428, 334, 69, 14, 71, 14, 1265, 199, 3, 221, 1172, 15932, 68, 282, 2414, 23012, 4190, 395, 314, 4190, 2895, 5084, 4838, 14, 199, 3, 199, 3, 221, 7719, 1265, 9509, 1901, 282, 7396, 4190, 25025, 2410, 9445, 3086, 282, 1331, 402, 199, 3, 221, 642, 2032, 12, 2066, 314, 2895, 402, 4066, 4190, 25025, 3350, 314, 2895, 5084, 737, 199, 3, 221, 314, 900, 737, 1314, 4066, 4190, 25025, 15410, 15826, 14, 199, 3, 199, 3, 221, 1010, 1930, 282, 7396, 4190, 25025, 11187, 12, 436, 4066, 25025, 11187, 1928, 3769, 199, 3, 221, 8717, 701, 4573, 7396, 4190, 25025, 12, 314, 4190, 2895, 5084, 4838, 199, 3, 221, 687, 314, 900, 737, 1314, 25097, 25025, 11187, 14, 199, 3, 199, 3, 221, 5113, 31510, 3053, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 199, 3, 221, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 12, 1015, 650, 12, 465, 3267, 701, 314, 199, 3, 221, 2868, 2290, 2752, 14, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 199, 3, 221, 2997, 12, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 199, 3, 221, 1666, 314, 1664, 4265, 1696, 1684, 844, 3394, 650, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 4190, 3180, 199, 3, 221, 543, 642, 2240, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 643, 1168, 13, 19, 14, 16, 14, 287, 14, 1360, 10827, 199, 3, 199, 13289, 8776, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 747, 199, 199, 504, 7390, 14, 4901, 492, 10133, 199, 504, 7390, 14, 4901, 14, 14461, 492, 13488, 20, 3120, 11442, 12, 971, 272, 13488, 22, 3120, 11442, 12, 971, 272, 13488, 20, 3041, 11442, 12, 971, 272, 13488, 22, 3041, 11442, 12, 971, 272, 22242, 3120, 11442, 12, 971, 272, 22242, 3041, 11442, 199, 504, 7390, 14, 1548, 14, 5819, 492, 2649, 199, 199, 893, 26, 272, 687, 7390, 14, 4901, 14, 14461, 492, 7799, 20, 3120, 11442, 12, 971, 267, 7799, 20, 3041, 11442, 272, 687, 8059, 1700, 14, 12145, 14, 9945, 3799, 492, 377, 478, 3120, 2998, 2927, 12, 971, 267, 377, 478, 3041, 2998, 2927, 199, 2590, 3545, 26, 272, 485, 13533, 63, 10224, 275, 756, 199, 2836, 26, 272, 485, 13533, 63, 10224, 275, 715, 199, 199, 504, 8059, 1700, 14, 12145, 14, 5555, 719, 492, 23752, 4313, 199, 199, 363, 452, 363, 275, 661, 981, 63, 5859, 316, 63, 6520, 63, 504, 63, 888, 297, 1779, 283, 981, 63, 5859, 316, 63, 719, 63, 504, 63, 888, 297, 1779, 283, 981, 63, 2242, 316, 63, 6520, 63, 504, 63, 888, 297, 1779, 283, 981, 63, 2242, 316, 63, 719, 63, 504, 63, 888, 358, 421, 199, 318, 1218, 63, 5859, 316, 63, 6520, 63, 504, 63, 888, 8, 888, 12, 7434, 694, 12, 9655, 304, 272, 408, 272, 2790, 282, 17078, 2547, 1654, 6037, 687, 282, 28965, 1700, 14, 2308, 7773, 2897, 14, 339, 1666, 26, 4178, 921, 12145, 3642, 14, 957, 15, 12233, 15, 1818, 15, 1246, 15, 12145, 14, 4901, 14, 7436, 14, 41, 3296, 3120, 11442, 14, 1360, 339, 520, 635, 1101, 26, 710, 7773, 2897, 14, 272, 520, 466, 1101, 26, 1211, 272, 520, 635, 7434, 694, 26, 28965, 1700, 14, 2308, 1031, 2082, 334, 1129, 1929, 642, 367, 12213, 790, 15, 16159, 680, 272, 520, 466, 7434, 694, 26, 620, 272, 520, 635, 9655, 26, 710, 9655, 370, 675, 367, 6037, 7143, 14, 272, 520, 466, 9655, 26, 1559, 339, 520, 5808, 1559, 1553, 1626, 1256, 18234, 473, 3296, 3120, 11442, 272, 408, 272, 6037, 275, 488, 339, 327, 282, 13488, 6037, 272, 327, 272, 340, 1101, 459, 466, 418, 508, 283, 8815, 356, 398, 327, 314, 13488, 4113, 1015, 334, 86, 20, 503, 373, 22, 9, 267, 327, 267, 1015, 275, 1109, 8, 888, 14, 362, 360, 1023, 297, 841, 430, 398, 327, 314, 22721, 1844, 267, 327, 267, 340, 730, 8, 888, 459, 719, 1105, 315, 334, 495, 12, 2649, 304, 288, 327, 1586, 1844, 687, 3734, 1750, 2508, 288, 862, 26, 355, 1844, 275, 1109, 8, 736, 14, 2314, 59, 888, 459, 719, 3488, 17, 2938, 566, 288, 871, 2186, 465, 325, 26, 355, 870, 480, 6531, 440, 1586, 22721, 1844, 687, 2589, 2729, 26, 8352, 908, 8, 69, 430, 355, 746, 325, 267, 587, 26, 288, 1844, 275, 1101, 459, 719, 418, 398, 327, 314, 22721, 3217, 267, 327, 267, 3217, 275, 620, 8, 888, 14, 362, 360, 3266, 297, 12548, 1913, 1012, 398, 327, 314, 13488, 4729, 4126, 5818, 267, 327, 267, 1771, 793, 275, 1109, 8, 888, 14, 362, 360, 31267, 297, 5238, 430, 398, 340, 283, 9945, 7, 315, 1101, 26, 953, 340, 485, 13533, 63, 10224, 26, 355, 790, 63, 7218, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 2894, 694, 12, 1101, 459, 9945, 2545, 498, 5156, 355, 6250, 63, 7218, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 2894, 694, 12, 1101, 459, 9945, 2545, 6999, 5156, 2234, 543, 1551, 8, 498, 63, 7218, 9, 465, 790, 63, 493, 26, 490, 543, 1551, 8, 4736, 63, 7218, 9, 465, 6250, 63, 493, 26, 9453, 340, 283, 7821, 635, 7, 315, 1101, 459, 9945, 2565, 1169, 31387, 635, 63, 7218, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
alexthered/kienhoc-platform
lms/djangoapps/courseware/migrations/0009_add_field_default.py
114
9698
# -*- 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): # Changing field 'XModuleContentField.value' db.alter_column('courseware_xmodulecontentfield', 'value', self.gf('django.db.models.fields.TextField')()) # Changing field 'XModuleStudentInfoField.value' db.alter_column('courseware_xmodulestudentinfofield', 'value', self.gf('django.db.models.fields.TextField')()) # Changing field 'XModuleSettingsField.value' db.alter_column('courseware_xmodulesettingsfield', 'value', self.gf('django.db.models.fields.TextField')()) # Changing field 'XModuleStudentPrefsField.value' db.alter_column('courseware_xmodulestudentprefsfield', 'value', self.gf('django.db.models.fields.TextField')()) def backwards(self, orm): # Changing field 'XModuleContentField.value' db.alter_column('courseware_xmodulecontentfield', 'value', self.gf('django.db.models.fields.TextField')(null=True)) # Changing field 'XModuleStudentInfoField.value' db.alter_column('courseware_xmodulestudentinfofield', 'value', self.gf('django.db.models.fields.TextField')(null=True)) # Changing field 'XModuleSettingsField.value' db.alter_column('courseware_xmodulesettingsfield', 'value', self.gf('django.db.models.fields.TextField')(null=True)) # Changing field 'XModuleStudentPrefsField.value' db.alter_column('courseware_xmodulestudentprefsfield', 'value', self.gf('django.db.models.fields.TextField')(null=True)) models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'courseware.studentmodule': { 'Meta': {'unique_together': "(('student', 'module_state_key', 'course_id'),)", 'object_name': 'StudentModule'}, 'course_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), 'done': ('django.db.models.fields.CharField', [], {'default': "'na'", 'max_length': '8', 'db_index': 'True'}), 'grade': ('django.db.models.fields.FloatField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'max_grade': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}), 'module_state_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_column': "'module_id'", 'db_index': 'True'}), 'module_type': ('django.db.models.fields.CharField', [], {'default': "'problem'", 'max_length': '32', 'db_index': 'True'}), 'state': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'student': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, 'courseware.xmodulecontentfield': { 'Meta': {'unique_together': "(('definition_id', 'field_name'),)", 'object_name': 'XModuleContentField'}, 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), 'definition_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'field_name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}), 'value': ('django.db.models.fields.TextField', [], {'default': "'null'"}) }, 'courseware.xmodulesettingsfield': { 'Meta': {'unique_together': "(('usage_id', 'field_name'),)", 'object_name': 'XModuleSettingsField'}, 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), 'field_name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}), 'usage_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'value': ('django.db.models.fields.TextField', [], {'default': "'null'"}) }, 'courseware.xmodulestudentinfofield': { 'Meta': {'unique_together': "(('student', 'field_name'),)", 'object_name': 'XModuleStudentInfoField'}, 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), 'field_name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}), 'student': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'value': ('django.db.models.fields.TextField', [], {'default': "'null'"}) }, 'courseware.xmodulestudentprefsfield': { 'Meta': {'unique_together': "(('student', 'module_type', 'field_name'),)", 'object_name': 'XModuleStudentPrefsField'}, 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), 'field_name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}), 'module_type': ('django.db.models.fields.CharField', [], {'max_length': '64', 'db_index': 'True'}), 'student': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'value': ('django.db.models.fields.TextField', [], {'default': "'null'"}) } } complete_apps = ['courseware']
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 56, 2377, 2714, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 1317, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 358, 1012, 398, 327, 27854, 901, 283, 56, 2377, 18086, 2354, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 5500, 815, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 358, 1012, 398, 327, 27854, 901, 283, 56, 2377, 5268, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 1751, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 358, 1012, 398, 327, 27854, 901, 283, 56, 2377, 18086, 48, 7655, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 5500, 17253, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 358, 1012, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 56, 2377, 2714, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 1317, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 430, 398, 327, 27854, 901, 283, 56, 2377, 18086, 2354, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 5500, 815, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 430, 398, 327, 27854, 901, 283, 56, 2377, 5268, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 1751, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 430, 398, 327, 27854, 901, 283, 56, 2377, 18086, 48, 7655, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 5500, 17253, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 430, 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, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267 ]
[ 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, 398, 327, 27854, 901, 283, 56, 2377, 2714, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 1317, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 358, 1012, 398, 327, 27854, 901, 283, 56, 2377, 18086, 2354, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 5500, 815, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 358, 1012, 398, 327, 27854, 901, 283, 56, 2377, 5268, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 1751, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 358, 1012, 398, 327, 27854, 901, 283, 56, 2377, 18086, 48, 7655, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 5500, 17253, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 358, 1012, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 56, 2377, 2714, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 1317, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 430, 398, 327, 27854, 901, 283, 56, 2377, 18086, 2354, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 5500, 815, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 430, 398, 327, 27854, 901, 283, 56, 2377, 5268, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 1751, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 430, 398, 327, 27854, 901, 283, 56, 2377, 18086, 48, 7655, 792, 14, 585, 7, 267, 1592, 14, 11858, 63, 2301, 360, 17744, 63, 14293, 5500, 17253, 698, 297, 283, 585, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 430, 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, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ChinaMassClouds/copenstack-server
openstack/src/ceilometer-2014.2.2/ceilometer/tests/storage/test_pymongo_base.py
5
8903
# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Tests the mongodb and db2 common functionality """ import contextlib import copy import datetime import mock import pymongo from ceilometer.openstack.common.gettextutils import _ from ceilometer.publisher import utils from ceilometer import sample from ceilometer.storage.mongo import utils as pymongo_utils from ceilometer.tests import db as tests_db from ceilometer.tests.storage import test_storage_scenarios @tests_db.run_with('mongodb', 'db2') class CompatibilityTest(test_storage_scenarios.DBTestBase, tests_db.MixinTestsWithBackendScenarios): def prepare_data(self): def old_record_metering_data(self, data): self.db.user.update( {'_id': data['user_id']}, {'$addToSet': {'source': data['source'], }, }, upsert=True, ) self.db.project.update( {'_id': data['project_id']}, {'$addToSet': {'source': data['source'], }, }, upsert=True, ) received_timestamp = datetime.datetime.utcnow() self.db.resource.update( {'_id': data['resource_id']}, {'$set': {'project_id': data['project_id'], 'user_id': data['user_id'], # Current metadata being used and when it was # last updated. 'timestamp': data['timestamp'], 'received_timestamp': received_timestamp, 'metadata': data['resource_metadata'], 'source': data['source'], }, '$addToSet': {'meter': {'counter_name': data['counter_name'], 'counter_type': data['counter_type'], }, }, }, upsert=True, ) record = copy.copy(data) self.db.meter.insert(record) # Stubout with the old version DB schema, the one w/o 'counter_unit' with mock.patch.object(self.conn, 'record_metering_data', side_effect=old_record_metering_data): self.counters = [] c = sample.Sample( 'volume.size', 'gauge', 'GiB', 5, 'user-id', 'project1', 'resource-id', timestamp=datetime.datetime(2012, 9, 25, 10, 30), resource_metadata={'display_name': 'test-volume', 'tag': 'self.counter', }, source='test', ) self.counters.append(c) msg = utils.meter_message_from_counter( c, secret='not-so-secret') self.conn.record_metering_data(self.conn, msg) # Create the old format alarm with a dict instead of a # array for matching_metadata alarm = dict(alarm_id='0ld-4l3rt', enabled=True, name='old-alert', description='old-alert', timestamp=None, meter_name='cpu', user_id='me', project_id='and-da-boys', comparison_operator='lt', threshold=36, statistic='count', evaluation_periods=1, period=60, state="insufficient data", state_timestamp=None, ok_actions=[], alarm_actions=['http://nowhere/alarms'], insufficient_data_actions=[], repeat_actions=False, matching_metadata={'key': 'value'}) self.alarm_conn.db.alarm.update( {'alarm_id': alarm['alarm_id']}, {'$set': alarm}, upsert=True) alarm['alarm_id'] = 'other-kind-of-0ld-4l3rt' alarm['name'] = 'other-old-alaert' alarm['matching_metadata'] = [{'key': 'key1', 'value': 'value1'}, {'key': 'key2', 'value': 'value2'}] self.alarm_conn.db.alarm.update( {'alarm_id': alarm['alarm_id']}, {'$set': alarm}, upsert=True) def test_alarm_get_old_format_matching_metadata_dict(self): old = list(self.alarm_conn.get_alarms(name='old-alert'))[0] self.assertEqual('threshold', old.type) self.assertEqual([{'field': 'key', 'op': 'eq', 'value': 'value', 'type': 'string'}], old.rule['query']) self.assertEqual(60, old.rule['period']) self.assertEqual('cpu', old.rule['meter_name']) self.assertEqual(1, old.rule['evaluation_periods']) self.assertEqual('count', old.rule['statistic']) self.assertEqual('lt', old.rule['comparison_operator']) self.assertEqual(36, old.rule['threshold']) def test_alarm_get_old_format_matching_metadata_array(self): old = list(self.alarm_conn.get_alarms(name='other-old-alaert'))[0] self.assertEqual('threshold', old.type) self.assertEqual(sorted([{'field': 'key1', 'op': 'eq', 'value': 'value1', 'type': 'string'}, {'field': 'key2', 'op': 'eq', 'value': 'value2', 'type': 'string'}]), sorted(old.rule['query']),) self.assertEqual('cpu', old.rule['meter_name']) self.assertEqual(60, old.rule['period']) self.assertEqual(1, old.rule['evaluation_periods']) self.assertEqual('count', old.rule['statistic']) self.assertEqual('lt', old.rule['comparison_operator']) self.assertEqual(36, old.rule['threshold']) def test_counter_unit(self): meters = list(self.conn.get_meters()) self.assertEqual(1, len(meters)) def test_mongodb_connect_raises_after_custom_number_of_attempts(self): retry_interval = 13 max_retries = 37 self.CONF.set_override( 'retry_interval', retry_interval, group='database') self.CONF.set_override( 'max_retries', max_retries, group='database') # PyMongo is being used to connect even to DB2, but it only # accepts URLs with the 'mongodb' scheme. This replacement is # usually done in the DB2 connection implementation, but since # we don't call that, we have to do it here. self.CONF.set_override( 'connection', self.db_manager.url.replace('db2:', 'mongodb:', 1), group='database') pool = pymongo_utils.ConnectionPool() with contextlib.nested( mock.patch( 'pymongo.MongoClient', side_effect=pymongo.errors.ConnectionFailure('foo')), mock.patch.object(pymongo_utils.LOG, 'error'), mock.patch.object(pymongo_utils.LOG, 'warn'), mock.patch.object(pymongo_utils.time, 'sleep') ) as (MockMongo, MockLOGerror, MockLOGwarn, Mocksleep): self.assertRaises(pymongo.errors.ConnectionFailure, pool.connect, self.CONF.database.connection) Mocksleep.assert_has_calls([mock.call(retry_interval) for i in range(max_retries)]) MockLOGwarn.assert_any_call( _('Unable to connect to the database server: %(errmsg)s.' ' Trying again in %(retry_interval)d seconds.') % {'errmsg': 'foo', 'retry_interval': retry_interval}) MockLOGerror.assert_called_with( _('Unable to connect to the database after ' '%(retries)d retries. Giving up.') % {'retries': max_retries})
gpl-2.0
[ 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 624, 2925, 314, 32315, 13152, 436, 1592, 18, 2863, 9330, 199, 624, 199, 199, 646, 15502, 199, 646, 1331, 199, 646, 2197, 199, 199, 646, 1683, 199, 646, 21878, 199, 199, 504, 10142, 25617, 14, 8512, 14, 2330, 14, 5152, 1208, 492, 485, 199, 504, 10142, 25617, 14, 12789, 492, 3778, 199, 504, 10142, 25617, 492, 2690, 199, 504, 10142, 25617, 14, 3494, 14, 9217, 492, 3778, 465, 21878, 63, 1208, 199, 504, 10142, 25617, 14, 2219, 492, 1592, 465, 2295, 63, 697, 199, 504, 10142, 25617, 14, 2219, 14, 3494, 492, 511, 63, 3494, 63, 32225, 421, 199, 32, 2219, 63, 697, 14, 1065, 63, 1045, 360, 22130, 13152, 297, 283, 697, 18, 358, 199, 533, 3599, 5880, 774, 8, 396, 63, 3494, 63, 32225, 14, 2846, 14440, 12, 717, 2295, 63, 697, 14, 4256, 2925, 3007, 8447, 12327, 17832, 304, 339, 347, 9275, 63, 576, 8, 277, 304, 267, 347, 2269, 63, 3059, 63, 26754, 63, 576, 8, 277, 12, 666, 304, 288, 291, 14, 697, 14, 751, 14, 873, 8, 355, 32136, 344, 356, 666, 459, 751, 63, 344, 14949, 355, 30108, 525, 1378, 1084, 356, 791, 1365, 356, 666, 459, 1365, 995, 3044, 1660, 326, 1660, 355, 1536, 407, 29, 549, 12, 288, 776, 288, 291, 14, 697, 14, 1715, 14, 873, 8, 355, 32136, 344, 356, 666, 459, 1715, 63, 344, 14949, 355, 30108, 525, 1378, 1084, 356, 791, 1365, 356, 666, 459, 1365, 995, 3044, 1660, 326, 1660, 355, 1536, 407, 29, 549, 12, 288, 776, 288, 3086, 63, 3954, 275, 2197, 14, 2083, 14, 10779, 342, 288, 291, 14, 697, 14, 1927, 14, 873, 8, 355, 32136, 344, 356, 666, 459, 1927, 63, 344, 14949, 355, 30108, 409, 356, 791, 1715, 63, 344, 356, 666, 459, 1715, 63, 344, 995, 2079, 283, 751, 63, 344, 356, 666, 459, 751, 63, 344, 995, 2079, 327, 9338, 3341, 3769, 1202, 436, 1380, 652, 1990, 2079, 327, 2061, 4588, 14, 2079, 283, 3954, 356, 666, 459, 3954, 995, 2079, 283, 9226, 63, 3954, 356, 3086, 63, 3954, 12, 2079, 283, 2343, 356, 666, 459, 1927, 63, 2343, 995, 2079, 283, 1365, 356, 666, 459, 1365, 995, 2079, 1660, 326, 4505, 525, 1378, 1084, 356, 791, 10011, 356, 791, 5337, 63, 354, 356, 666, 459, 5337, 63, 354, 995, 1460, 283, 5337, 63, 466, 356, 666, 459, 5337, 63, 466, 995, 1460, 1660, 3044, 1660, 326, 1660, 355, 1536, 407, 29, 549, 12, 288, 776, 953, 2777, 275, 1331, 14, 1574, 8, 576, 9, 288, 291, 14, 697, 14, 10011, 14, 3176, 8, 3059, 9, 398, 327, 23429, 548, 543, 314, 2269, 1015, 6249, 4177, 12, 314, 1373, 336, 15, 79, 283, 5337, 63, 3248, 7, 267, 543, 1683, 14, 2068, 14, 785, 8, 277, 14, 1631, 12, 283, 3059, 63, 26754, 63, 576, 297, 3044, 5366, 63, 5881, 29, 1753, 63, 3059, 63, 26754, 63, 576, 304, 288, 291, 14, 16558, 275, 942, 288, 286, 275, 2690, 14, 8176, 8, 355, 283, 2405, 14, 890, 297, 355, 283, 26775, 297, 355, 283, 39, 17587, 297, 355, 959, 12, 355, 283, 751, 13, 344, 297, 355, 283, 1715, 17, 297, 355, 283, 1927, 13, 344, 297, 355, 4913, 29, 2083, 14, 2083, 8, 7409, 12, 1749, 12, 5661, 12, 1616, 12, 4233, 395, 355, 2073, 63, 2343, 3713, 2918, 63, 354, 356, 283, 396, 13, 2405, 297, 3521, 283, 1450, 356, 283, 277, 14, 5337, 297, 3521, 1660, 355, 1350, 534, 396, 297, 288, 776, 288, 291, 14, 16558, 14, 740, 8, 67, 9, 288, 1499, 275, 3778, 14, 10011, 63, 1188, 63, 504, 63, 5337, 8, 355, 286, 12, 355, 7565, 534, 1397, 13, 1152, 13, 4731, 358, 288, 291, 14, 1631, 14, 3059, 63, 26754, 63, 576, 8, 277, 14, 1631, 12, 1499, 9, 398, 327, 2790, 314, 2269, 1475, 17987, 543, 282, 1211, 3140, 402, 282, 267, 327, 1625, 367, 4877, 63, 2343, 267, 17987, 275, 1211, 8, 14160, 63, 344, 534, 16, 1447, 13, 20, 76, 19, 2591, 297, 2151, 5223, 29, 549, 12, 2151, 536, 534, 1753, 13, 9241, 297, 2151, 1369, 534, 1753, 13, 9241, 297, 2151, 4913, 29, 403, 12, 2151, 21247, 63, 354, 534, 3541, 297, 2151, 922, 63, 344, 534, 278, 297, 2151, 2199, 63, 344, 534, 460, 13, 983, 13, 656, 588, 297, 2151, 9132, 63, 3856, 534, 4116, 297, 2151, 8765, 29, 1344, 12, 2151, 22394, 534, 835, 297, 2151, 11735, 63, 20441, 29, 17, 12, 2151, 6247, 29, 2259, 12, 2151, 1174, 628, 3617, 12983, 666, 401, 2151, 1174, 63, 3954, 29, 403, 12, 2151, 4112, 63, 3723, 6034, 2151, 17987, 63, 3723, 2968, 1014, 921, 2131, 1681, 15, 279, 25005, 995, 2151, 5261, 12983, 63, 576, 63, 3723, 6034, 2151, 11982, 63, 3723, 29, 797, 12, 2151, 4877, 63, 2343, 3713, 498, 356, 283, 585, 3071, 398, 291, 14, 14160, 63, 1631, 14, 697, 14, 14160, 14, 873, 8, 288, 791, 14160, 63, 344, 356, 17987, 459, 14160, 63, 344, 14949, 288, 30108, 409, 356, 17987, 1386, 288, 1536, 407, 29, 549, 9, 398, 17987, 459, 14160, 63, 344, 418, 275, 283, 1848, 13, 5091, 13, 1618, 13, 16, 1447, 13, 20, 76, 19, 2591, 7, 267, 17987, 459, 354, 418, 275, 283, 1848, 13, 1753, 13, 14774, 15299, 7, 267, 17987, 459, 9467, 63, 2343, 418, 275, 9016, 498, 356, 283, 498, 17, 297, 283, 585, 356, 283 ]
[ 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 624, 2925, 314, 32315, 13152, 436, 1592, 18, 2863, 9330, 199, 624, 199, 199, 646, 15502, 199, 646, 1331, 199, 646, 2197, 199, 199, 646, 1683, 199, 646, 21878, 199, 199, 504, 10142, 25617, 14, 8512, 14, 2330, 14, 5152, 1208, 492, 485, 199, 504, 10142, 25617, 14, 12789, 492, 3778, 199, 504, 10142, 25617, 492, 2690, 199, 504, 10142, 25617, 14, 3494, 14, 9217, 492, 3778, 465, 21878, 63, 1208, 199, 504, 10142, 25617, 14, 2219, 492, 1592, 465, 2295, 63, 697, 199, 504, 10142, 25617, 14, 2219, 14, 3494, 492, 511, 63, 3494, 63, 32225, 421, 199, 32, 2219, 63, 697, 14, 1065, 63, 1045, 360, 22130, 13152, 297, 283, 697, 18, 358, 199, 533, 3599, 5880, 774, 8, 396, 63, 3494, 63, 32225, 14, 2846, 14440, 12, 717, 2295, 63, 697, 14, 4256, 2925, 3007, 8447, 12327, 17832, 304, 339, 347, 9275, 63, 576, 8, 277, 304, 267, 347, 2269, 63, 3059, 63, 26754, 63, 576, 8, 277, 12, 666, 304, 288, 291, 14, 697, 14, 751, 14, 873, 8, 355, 32136, 344, 356, 666, 459, 751, 63, 344, 14949, 355, 30108, 525, 1378, 1084, 356, 791, 1365, 356, 666, 459, 1365, 995, 3044, 1660, 326, 1660, 355, 1536, 407, 29, 549, 12, 288, 776, 288, 291, 14, 697, 14, 1715, 14, 873, 8, 355, 32136, 344, 356, 666, 459, 1715, 63, 344, 14949, 355, 30108, 525, 1378, 1084, 356, 791, 1365, 356, 666, 459, 1365, 995, 3044, 1660, 326, 1660, 355, 1536, 407, 29, 549, 12, 288, 776, 288, 3086, 63, 3954, 275, 2197, 14, 2083, 14, 10779, 342, 288, 291, 14, 697, 14, 1927, 14, 873, 8, 355, 32136, 344, 356, 666, 459, 1927, 63, 344, 14949, 355, 30108, 409, 356, 791, 1715, 63, 344, 356, 666, 459, 1715, 63, 344, 995, 2079, 283, 751, 63, 344, 356, 666, 459, 751, 63, 344, 995, 2079, 327, 9338, 3341, 3769, 1202, 436, 1380, 652, 1990, 2079, 327, 2061, 4588, 14, 2079, 283, 3954, 356, 666, 459, 3954, 995, 2079, 283, 9226, 63, 3954, 356, 3086, 63, 3954, 12, 2079, 283, 2343, 356, 666, 459, 1927, 63, 2343, 995, 2079, 283, 1365, 356, 666, 459, 1365, 995, 2079, 1660, 326, 4505, 525, 1378, 1084, 356, 791, 10011, 356, 791, 5337, 63, 354, 356, 666, 459, 5337, 63, 354, 995, 1460, 283, 5337, 63, 466, 356, 666, 459, 5337, 63, 466, 995, 1460, 1660, 3044, 1660, 326, 1660, 355, 1536, 407, 29, 549, 12, 288, 776, 953, 2777, 275, 1331, 14, 1574, 8, 576, 9, 288, 291, 14, 697, 14, 10011, 14, 3176, 8, 3059, 9, 398, 327, 23429, 548, 543, 314, 2269, 1015, 6249, 4177, 12, 314, 1373, 336, 15, 79, 283, 5337, 63, 3248, 7, 267, 543, 1683, 14, 2068, 14, 785, 8, 277, 14, 1631, 12, 283, 3059, 63, 26754, 63, 576, 297, 3044, 5366, 63, 5881, 29, 1753, 63, 3059, 63, 26754, 63, 576, 304, 288, 291, 14, 16558, 275, 942, 288, 286, 275, 2690, 14, 8176, 8, 355, 283, 2405, 14, 890, 297, 355, 283, 26775, 297, 355, 283, 39, 17587, 297, 355, 959, 12, 355, 283, 751, 13, 344, 297, 355, 283, 1715, 17, 297, 355, 283, 1927, 13, 344, 297, 355, 4913, 29, 2083, 14, 2083, 8, 7409, 12, 1749, 12, 5661, 12, 1616, 12, 4233, 395, 355, 2073, 63, 2343, 3713, 2918, 63, 354, 356, 283, 396, 13, 2405, 297, 3521, 283, 1450, 356, 283, 277, 14, 5337, 297, 3521, 1660, 355, 1350, 534, 396, 297, 288, 776, 288, 291, 14, 16558, 14, 740, 8, 67, 9, 288, 1499, 275, 3778, 14, 10011, 63, 1188, 63, 504, 63, 5337, 8, 355, 286, 12, 355, 7565, 534, 1397, 13, 1152, 13, 4731, 358, 288, 291, 14, 1631, 14, 3059, 63, 26754, 63, 576, 8, 277, 14, 1631, 12, 1499, 9, 398, 327, 2790, 314, 2269, 1475, 17987, 543, 282, 1211, 3140, 402, 282, 267, 327, 1625, 367, 4877, 63, 2343, 267, 17987, 275, 1211, 8, 14160, 63, 344, 534, 16, 1447, 13, 20, 76, 19, 2591, 297, 2151, 5223, 29, 549, 12, 2151, 536, 534, 1753, 13, 9241, 297, 2151, 1369, 534, 1753, 13, 9241, 297, 2151, 4913, 29, 403, 12, 2151, 21247, 63, 354, 534, 3541, 297, 2151, 922, 63, 344, 534, 278, 297, 2151, 2199, 63, 344, 534, 460, 13, 983, 13, 656, 588, 297, 2151, 9132, 63, 3856, 534, 4116, 297, 2151, 8765, 29, 1344, 12, 2151, 22394, 534, 835, 297, 2151, 11735, 63, 20441, 29, 17, 12, 2151, 6247, 29, 2259, 12, 2151, 1174, 628, 3617, 12983, 666, 401, 2151, 1174, 63, 3954, 29, 403, 12, 2151, 4112, 63, 3723, 6034, 2151, 17987, 63, 3723, 2968, 1014, 921, 2131, 1681, 15, 279, 25005, 995, 2151, 5261, 12983, 63, 576, 63, 3723, 6034, 2151, 11982, 63, 3723, 29, 797, 12, 2151, 4877, 63, 2343, 3713, 498, 356, 283, 585, 3071, 398, 291, 14, 14160, 63, 1631, 14, 697, 14, 14160, 14, 873, 8, 288, 791, 14160, 63, 344, 356, 17987, 459, 14160, 63, 344, 14949, 288, 30108, 409, 356, 17987, 1386, 288, 1536, 407, 29, 549, 9, 398, 17987, 459, 14160, 63, 344, 418, 275, 283, 1848, 13, 5091, 13, 1618, 13, 16, 1447, 13, 20, 76, 19, 2591, 7, 267, 17987, 459, 354, 418, 275, 283, 1848, 13, 1753, 13, 14774, 15299, 7, 267, 17987, 459, 9467, 63, 2343, 418, 275, 9016, 498, 356, 283, 498, 17, 297, 283, 585, 356, 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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): """ Parser for multipart form data, which may include file data. Lifted from https://github.com/tomchristie/django-rest-framework/pull/4026/ to work around request.data being empty when multipart/form-data is posted. See https://github.com/tomchristie/django-rest-framework/issues/3951 """ def parse(self, stream, media_type=None, parser_context=None): """ Parses the incoming bytestream as a multipart encoded form, and returns a DataAndFiles object. `.data` will be a `QueryDict` containing all the form parameters. `.files` will be a `QueryDict` containing all the form files. For POSTs, accept Django request parsing. See issue #3951. """ parser_context = parser_context or {} request = parser_context['request'] _request = request._request if _request.method == 'POST': return DataAndFiles(_request.POST, _request.FILES) return super(MultiPartParser, self).parse( stream, media_type=media_type, parser_context=parser_context)
bsd-3-clause
[ 504, 4618, 63, 4857, 14, 11531, 492, 3918, 3325, 5535, 12, 6879, 8416, 2842, 421, 199, 533, 6879, 8416, 2842, 8, 3947, 8416, 2842, 304, 272, 408, 272, 10191, 367, 15193, 1824, 666, 12, 1314, 1443, 2387, 570, 666, 14, 339, 491, 692, 471, 687, 4178, 921, 5031, 14, 957, 15, 3151, 335, 18824, 1873, 15, 1176, 13, 3911, 13, 4857, 15, 9302, 15, 13314, 22, 15, 272, 370, 1736, 6818, 1056, 14, 576, 3769, 2701, 1380, 15193, 15, 964, 13, 576, 365, 22752, 14, 272, 1666, 4178, 921, 5031, 14, 957, 15, 3151, 335, 18824, 1873, 15, 1176, 13, 3911, 13, 4857, 15, 10115, 15, 1355, 2869, 272, 408, 339, 347, 2198, 8, 277, 12, 2547, 12, 5898, 63, 466, 29, 403, 12, 1798, 63, 1100, 29, 403, 304, 267, 408, 267, 29968, 314, 12467, 18792, 1091, 465, 282, 15193, 5737, 1824, 12, 267, 436, 2529, 282, 3918, 3325, 5535, 909, 14, 398, 19853, 576, 64, 911, 506, 282, 658, 3227, 2141, 64, 3035, 1006, 314, 1824, 2633, 14, 267, 19853, 1725, 64, 911, 506, 282, 658, 3227, 2141, 64, 3035, 1006, 314, 1824, 1584, 14, 398, 2104, 8761, 83, 12, 4729, 5634, 1056, 6057, 14, 221, 1666, 4976, 327, 1355, 2869, 14, 267, 408, 267, 1798, 63, 1100, 275, 1798, 63, 1100, 503, 1052, 267, 1056, 275, 1798, 63, 1100, 459, 1069, 418, 267, 485, 1069, 275, 1056, 423, 1069, 267, 340, 485, 1069, 14, 765, 508, 283, 4030, 356, 288, 372, 3918, 3325, 5535, 1547, 1069, 14, 4030, 12, 485, 1069, 14, 9472, 9, 267, 372, 1613, 8, 3947, 8416, 2842, 12, 291, 680, 1122, 8, 288, 2547, 12, 5898, 63, 466, 29, 4603, 63, 466, 12, 1798, 63, 1100, 29, 2087, 63, 1100, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 11531, 492, 3918, 3325, 5535, 12, 6879, 8416, 2842, 421, 199, 533, 6879, 8416, 2842, 8, 3947, 8416, 2842, 304, 272, 408, 272, 10191, 367, 15193, 1824, 666, 12, 1314, 1443, 2387, 570, 666, 14, 339, 491, 692, 471, 687, 4178, 921, 5031, 14, 957, 15, 3151, 335, 18824, 1873, 15, 1176, 13, 3911, 13, 4857, 15, 9302, 15, 13314, 22, 15, 272, 370, 1736, 6818, 1056, 14, 576, 3769, 2701, 1380, 15193, 15, 964, 13, 576, 365, 22752, 14, 272, 1666, 4178, 921, 5031, 14, 957, 15, 3151, 335, 18824, 1873, 15, 1176, 13, 3911, 13, 4857, 15, 10115, 15, 1355, 2869, 272, 408, 339, 347, 2198, 8, 277, 12, 2547, 12, 5898, 63, 466, 29, 403, 12, 1798, 63, 1100, 29, 403, 304, 267, 408, 267, 29968, 314, 12467, 18792, 1091, 465, 282, 15193, 5737, 1824, 12, 267, 436, 2529, 282, 3918, 3325, 5535, 909, 14, 398, 19853, 576, 64, 911, 506, 282, 658, 3227, 2141, 64, 3035, 1006, 314, 1824, 2633, 14, 267, 19853, 1725, 64, 911, 506, 282, 658, 3227, 2141, 64, 3035, 1006, 314, 1824, 1584, 14, 398, 2104, 8761, 83, 12, 4729, 5634, 1056, 6057, 14, 221, 1666, 4976, 327, 1355, 2869, 14, 267, 408, 267, 1798, 63, 1100, 275, 1798, 63, 1100, 503, 1052, 267, 1056, 275, 1798, 63, 1100, 459, 1069, 418, 267, 485, 1069, 275, 1056, 423, 1069, 267, 340, 485, 1069, 14, 765, 508, 283, 4030, 356, 288, 372, 3918, 3325, 5535, 1547, 1069, 14, 4030, 12, 485, 1069, 14, 9472, 9, 267, 372, 1613, 8, 3947, 8416, 2842, 12, 291, 680, 1122, 8, 288, 2547, 12, 5898, 63, 466, 29, 4603, 63, 466, 12, 1798, 63, 1100, 29, 2087, 63, 1100, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
annegentle/magnum
magnum/objects/bay.py
8
8241
# coding=utf-8 # # # 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 oslo_versionedobjects import fields from magnum.common import exception from magnum.common import utils from magnum.db import api as dbapi from magnum.objects import base from magnum.objects import fields as m_fields @base.MagnumObjectRegistry.register class Bay(base.MagnumPersistentObject, base.MagnumObject, base.MagnumObjectDictCompat): # Version 1.0: Initial version VERSION = '1.0' dbapi = dbapi.get_instance() fields = { 'id': fields.IntegerField(), 'uuid': fields.UUIDField(nullable=True), 'name': fields.StringField(nullable=True), 'project_id': fields.StringField(nullable=True), 'user_id': fields.StringField(nullable=True), 'baymodel_id': fields.StringField(nullable=True), 'stack_id': fields.StringField(nullable=True), 'status': m_fields.BayStatusField(nullable=True), 'status_reason': fields.StringField(nullable=True), 'api_address': fields.StringField(nullable=True), 'node_addresses': fields.ListOfStringsField(nullable=True), 'node_count': fields.IntegerField(nullable=True), 'master_count': fields.IntegerField(nullable=True), 'discovery_url': fields.StringField(nullable=True), 'master_addresses': fields.ListOfStringsField(nullable=True), 'ca_cert_ref': fields.StringField(nullable=True), 'magnum_cert_ref': fields.StringField(nullable=True), } @staticmethod def _from_db_object(bay, db_bay): """Converts a database entity to a formal object.""" for field in bay.fields: bay[field] = db_bay[field] bay.obj_reset_changes() return bay @staticmethod def _from_db_object_list(db_objects, cls, context): """Converts a list of database entities to a list of formal objects.""" return [Bay._from_db_object(cls(context), obj) for obj in db_objects] @base.remotable_classmethod def get(cls, context, bay_id): """Find a bay based on its id or uuid and return a Bay object. :param bay_id: the id *or* uuid of a bay. :returns: a :class:`Bay` object. """ if utils.is_int_like(bay_id): return cls.get_by_id(context, bay_id) elif utils.is_uuid_like(bay_id): return cls.get_by_uuid(context, bay_id) else: raise exception.InvalidIdentity(identity=bay_id) @base.remotable_classmethod def get_by_id(cls, context, bay_id): """Find a bay based on its integer id and return a Bay object. :param bay_id: the id of a bay. :returns: a :class:`Bay` object. """ db_bay = cls.dbapi.get_bay_by_id(context, bay_id) bay = Bay._from_db_object(cls(context), db_bay) return bay @base.remotable_classmethod def get_by_uuid(cls, context, uuid): """Find a bay based on uuid and return a :class:`Bay` object. :param uuid: the uuid of a bay. :param context: Security context :returns: a :class:`Bay` object. """ db_bay = cls.dbapi.get_bay_by_uuid(context, uuid) bay = Bay._from_db_object(cls(context), db_bay) return bay @base.remotable_classmethod def get_by_name(cls, context, name): """Find a bay based on name and return a Bay object. :param name: the logical name of a bay. :param context: Security context :returns: a :class:`Bay` object. """ db_bay = cls.dbapi.get_bay_by_name(context, name) bay = Bay._from_db_object(cls(context), db_bay) return bay @base.remotable_classmethod def list(cls, context, limit=None, marker=None, sort_key=None, sort_dir=None, filters=None): """Return a list of Bay objects. :param context: Security context. :param limit: maximum number of resources to return in a single result. :param marker: pagination marker for large data sets. :param sort_key: column to sort results by. :param sort_dir: direction to sort. "asc" or "desc". :param filters: filter dict, can includes 'baymodel_id', 'name', 'node_count', 'stack_id', 'api_address', 'node_addresses', 'project_id', 'user_id', 'status'(should be a status list), 'master_count'. :returns: a list of :class:`Bay` object. """ db_bays = cls.dbapi.get_bay_list(context, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir, filters=filters) return Bay._from_db_object_list(db_bays, cls, context) @base.remotable def create(self, context=None): """Create a Bay record in the DB. :param context: Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don't use it. A context should be set when instantiating the object, e.g.: Bay(context) """ values = self.obj_get_changes() db_bay = self.dbapi.create_bay(values) self._from_db_object(self, db_bay) @base.remotable def destroy(self, context=None): """Delete the Bay from the DB. :param context: Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don't use it. A context should be set when instantiating the object, e.g.: Bay(context) """ self.dbapi.destroy_bay(self.uuid) self.obj_reset_changes() @base.remotable def save(self, context=None): """Save updates to this Bay. Updates will be made column by column based on the result of self.what_changed(). :param context: Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don't use it. A context should be set when instantiating the object, e.g.: Bay(context) """ updates = self.obj_get_changes() self.dbapi.update_bay(self.uuid, updates) self.obj_reset_changes() @base.remotable def refresh(self, context=None): """Loads updates for this Bay. Loads a bay with the same uuid from the database and checks for updated attributes. Updates are applied from the loaded bay column by column, if there are any updates. :param context: Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don't use it. A context should be set when instantiating the object, e.g.: Bay(context) """ current = self.__class__.get_by_uuid(self._context, uuid=self.uuid) for field in self.fields: if self.obj_attr_is_set(field) and self[field] != current[field]: self[field] = current[field]
apache-2.0
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 11258, 63, 24155, 1462, 492, 1504, 199, 199, 504, 15916, 453, 14, 2330, 492, 1919, 199, 504, 15916, 453, 14, 2330, 492, 3778, 199, 504, 15916, 453, 14, 697, 492, 2986, 465, 29333, 199, 504, 15916, 453, 14, 1462, 492, 1300, 199, 504, 15916, 453, 14, 1462, 492, 1504, 465, 333, 63, 955, 421, 199, 32, 1095, 14, 22745, 1507, 1692, 10899, 14, 2683, 199, 533, 29434, 8, 1095, 14, 22745, 1507, 31966, 1692, 12, 1300, 14, 22745, 1507, 1692, 12, 881, 1300, 14, 22745, 1507, 1692, 2141, 2404, 292, 304, 272, 327, 3394, 413, 14, 16, 26, 6026, 1015, 272, 15945, 275, 283, 17, 14, 16, 7, 339, 29333, 275, 29333, 14, 362, 63, 842, 342, 339, 1504, 275, 469, 267, 283, 344, 356, 1504, 14, 3901, 1062, 267, 283, 2580, 356, 1504, 14, 8757, 792, 8, 16375, 29, 549, 395, 267, 283, 354, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 1715, 63, 344, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 751, 63, 344, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 19558, 1238, 63, 344, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 2340, 63, 344, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 1205, 356, 333, 63, 955, 14, 29115, 3694, 792, 8, 16375, 29, 549, 395, 267, 283, 1205, 63, 5764, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 1246, 63, 1562, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 932, 63, 7423, 356, 1504, 14, 30210, 12672, 792, 8, 16375, 29, 549, 395, 267, 283, 932, 63, 835, 356, 1504, 14, 3901, 8, 16375, 29, 549, 395, 267, 283, 4133, 63, 835, 356, 1504, 14, 3901, 8, 16375, 29, 549, 395, 267, 283, 14859, 63, 633, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 4133, 63, 7423, 356, 1504, 14, 30210, 12672, 792, 8, 16375, 29, 549, 395, 267, 283, 696, 63, 4736, 63, 1121, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 19902, 453, 63, 4736, 63, 1121, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 272, 789, 339, 768, 4639, 272, 347, 485, 504, 63, 697, 63, 785, 8, 19558, 12, 1592, 63, 19558, 304, 267, 408, 17729, 282, 3050, 4642, 370, 282, 1824, 279, 909, 1041, 267, 367, 901, 315, 30933, 14, 955, 26, 288, 30933, 59, 698, 61, 275, 1592, 63, 19558, 59, 698, 61, 398, 30933, 14, 1113, 63, 3958, 63, 6627, 342, 267, 372, 30933, 339, 768, 4639, 272, 347, 485, 504, 63, 697, 63, 785, 63, 513, 8, 697, 63, 1462, 12, 843, 12, 1067, 304, 267, 408, 17729, 282, 769, 402, 3050, 9045, 370, 282, 769, 402, 1824, 279, 2251, 1041, 267, 372, 359, 29115, 423, 504, 63, 697, 63, 785, 8, 1886, 8, 1100, 395, 1559, 9, 367, 1559, 315, 1592, 63, 1462, 61, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 664, 8, 1886, 12, 1067, 12, 30933, 63, 344, 304, 267, 408, 6591, 282, 30933, 4079, 641, 2399, 1305, 503, 5377, 436, 372, 282, 29434, 909, 14, 398, 520, 635, 30933, 63, 344, 26, 314, 1305, 627, 269, 10, 5377, 402, 282, 30933, 14, 267, 520, 5808, 26, 282, 520, 533, 1705, 29115, 64, 909, 14, 267, 408, 267, 340, 3778, 14, 374, 63, 442, 63, 2930, 8, 19558, 63, 344, 304, 288, 372, 843, 14, 362, 63, 991, 63, 344, 8, 1100, 12, 30933, 63, 344, 9, 267, 916, 3778, 14, 374, 63, 2580, 63, 2930, 8, 19558, 63, 344, 304, 288, 372, 843, 14, 362, 63, 991, 63, 2580, 8, 1100, 12, 30933, 63, 344, 9, 267, 587, 26, 288, 746, 1919, 14, 3364, 10193, 8, 5582, 29, 19558, 63, 344, 9, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 664, 63, 991, 63, 344, 8, 1886, 12, 1067, 12, 30933, 63, 344, 304, 267, 408, 6591, 282, 30933, 4079, 641, 2399, 3000, 1305, 436, 372, 282, 29434, 909, 14, 398, 520, 635, 30933, 63, 344, 26, 314, 1305, 402, 282, 30933, 14, 267, 520, 5808, 26, 282, 520, 533, 1705, 29115, 64, 909, 14, 267, 408, 267, 1592, 63, 19558, 275, 843, 14, 22103, 14, 362, 63, 19558, 63, 991, 63, 344, 8, 1100, 12, 30933, 63, 344, 9, 267, 30933, 275, 29434, 423, 504, 63, 697, 63, 785, 8, 1886, 8, 1100, 395, 1592, 63, 19558, 9, 267, 372, 30933, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 664, 63, 991, 63, 2580, 8, 1886, 12, 1067, 12, 5377, 304, 267, 408, 6591, 282, 30933, 4079, 641, 5377, 436, 372, 282, 520, 533, 1705, 29115, 64, 909, 14, 398, 520, 635, 5377, 26, 314, 5377, 402, 282, 30933, 14, 267, 520, 635, 1067, 26, 13863, 1067, 267, 520, 5808, 26, 282, 520, 533, 1705, 29115, 64, 909, 14, 267, 408, 267, 1592, 63, 19558, 275, 843, 14, 22103, 14, 362, 63, 19558, 63, 991, 63, 2580, 8, 1100, 12, 5377, 9, 267, 30933, 275, 29434, 423, 504, 63, 697, 63, 785, 8, 1886, 8, 1100, 395, 1592, 63, 19558, 9, 267, 372, 30933, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 664 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 11258, 63, 24155, 1462, 492, 1504, 199, 199, 504, 15916, 453, 14, 2330, 492, 1919, 199, 504, 15916, 453, 14, 2330, 492, 3778, 199, 504, 15916, 453, 14, 697, 492, 2986, 465, 29333, 199, 504, 15916, 453, 14, 1462, 492, 1300, 199, 504, 15916, 453, 14, 1462, 492, 1504, 465, 333, 63, 955, 421, 199, 32, 1095, 14, 22745, 1507, 1692, 10899, 14, 2683, 199, 533, 29434, 8, 1095, 14, 22745, 1507, 31966, 1692, 12, 1300, 14, 22745, 1507, 1692, 12, 881, 1300, 14, 22745, 1507, 1692, 2141, 2404, 292, 304, 272, 327, 3394, 413, 14, 16, 26, 6026, 1015, 272, 15945, 275, 283, 17, 14, 16, 7, 339, 29333, 275, 29333, 14, 362, 63, 842, 342, 339, 1504, 275, 469, 267, 283, 344, 356, 1504, 14, 3901, 1062, 267, 283, 2580, 356, 1504, 14, 8757, 792, 8, 16375, 29, 549, 395, 267, 283, 354, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 1715, 63, 344, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 751, 63, 344, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 19558, 1238, 63, 344, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 2340, 63, 344, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 1205, 356, 333, 63, 955, 14, 29115, 3694, 792, 8, 16375, 29, 549, 395, 267, 283, 1205, 63, 5764, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 1246, 63, 1562, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 932, 63, 7423, 356, 1504, 14, 30210, 12672, 792, 8, 16375, 29, 549, 395, 267, 283, 932, 63, 835, 356, 1504, 14, 3901, 8, 16375, 29, 549, 395, 267, 283, 4133, 63, 835, 356, 1504, 14, 3901, 8, 16375, 29, 549, 395, 267, 283, 14859, 63, 633, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 4133, 63, 7423, 356, 1504, 14, 30210, 12672, 792, 8, 16375, 29, 549, 395, 267, 283, 696, 63, 4736, 63, 1121, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 19902, 453, 63, 4736, 63, 1121, 356, 1504, 14, 14912, 8, 16375, 29, 549, 395, 272, 789, 339, 768, 4639, 272, 347, 485, 504, 63, 697, 63, 785, 8, 19558, 12, 1592, 63, 19558, 304, 267, 408, 17729, 282, 3050, 4642, 370, 282, 1824, 279, 909, 1041, 267, 367, 901, 315, 30933, 14, 955, 26, 288, 30933, 59, 698, 61, 275, 1592, 63, 19558, 59, 698, 61, 398, 30933, 14, 1113, 63, 3958, 63, 6627, 342, 267, 372, 30933, 339, 768, 4639, 272, 347, 485, 504, 63, 697, 63, 785, 63, 513, 8, 697, 63, 1462, 12, 843, 12, 1067, 304, 267, 408, 17729, 282, 769, 402, 3050, 9045, 370, 282, 769, 402, 1824, 279, 2251, 1041, 267, 372, 359, 29115, 423, 504, 63, 697, 63, 785, 8, 1886, 8, 1100, 395, 1559, 9, 367, 1559, 315, 1592, 63, 1462, 61, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 664, 8, 1886, 12, 1067, 12, 30933, 63, 344, 304, 267, 408, 6591, 282, 30933, 4079, 641, 2399, 1305, 503, 5377, 436, 372, 282, 29434, 909, 14, 398, 520, 635, 30933, 63, 344, 26, 314, 1305, 627, 269, 10, 5377, 402, 282, 30933, 14, 267, 520, 5808, 26, 282, 520, 533, 1705, 29115, 64, 909, 14, 267, 408, 267, 340, 3778, 14, 374, 63, 442, 63, 2930, 8, 19558, 63, 344, 304, 288, 372, 843, 14, 362, 63, 991, 63, 344, 8, 1100, 12, 30933, 63, 344, 9, 267, 916, 3778, 14, 374, 63, 2580, 63, 2930, 8, 19558, 63, 344, 304, 288, 372, 843, 14, 362, 63, 991, 63, 2580, 8, 1100, 12, 30933, 63, 344, 9, 267, 587, 26, 288, 746, 1919, 14, 3364, 10193, 8, 5582, 29, 19558, 63, 344, 9, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 664, 63, 991, 63, 344, 8, 1886, 12, 1067, 12, 30933, 63, 344, 304, 267, 408, 6591, 282, 30933, 4079, 641, 2399, 3000, 1305, 436, 372, 282, 29434, 909, 14, 398, 520, 635, 30933, 63, 344, 26, 314, 1305, 402, 282, 30933, 14, 267, 520, 5808, 26, 282, 520, 533, 1705, 29115, 64, 909, 14, 267, 408, 267, 1592, 63, 19558, 275, 843, 14, 22103, 14, 362, 63, 19558, 63, 991, 63, 344, 8, 1100, 12, 30933, 63, 344, 9, 267, 30933, 275, 29434, 423, 504, 63, 697, 63, 785, 8, 1886, 8, 1100, 395, 1592, 63, 19558, 9, 267, 372, 30933, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 664, 63, 991, 63, 2580, 8, 1886, 12, 1067, 12, 5377, 304, 267, 408, 6591, 282, 30933, 4079, 641, 5377, 436, 372, 282, 520, 533, 1705, 29115, 64, 909, 14, 398, 520, 635, 5377, 26, 314, 5377, 402, 282, 30933, 14, 267, 520, 635, 1067, 26, 13863, 1067, 267, 520, 5808, 26, 282, 520, 533, 1705, 29115, 64, 909, 14, 267, 408, 267, 1592, 63, 19558, 275, 843, 14, 22103, 14, 362, 63, 19558, 63, 991, 63, 2580, 8, 1100, 12, 5377, 9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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 ]
yanheven/keystone
keystone/auth/plugins/external.py
6
6451
# Copyright 2013 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Keystone External Authentication Plugins""" import abc from oslo_config import cfg import six from keystone import auth from keystone.common import dependency from keystone import exception from keystone.i18n import _ from keystone.openstack.common import versionutils CONF = cfg.CONF @six.add_metaclass(abc.ABCMeta) class Base(auth.AuthMethodHandler): method = 'external' def authenticate(self, context, auth_info, auth_context): """Use REMOTE_USER to look up the user in the identity backend. auth_context is an in-out variable that will be updated with the user_id from the actual user from the REMOTE_USER env variable. """ try: REMOTE_USER = context['environment']['REMOTE_USER'] except KeyError: msg = _('No authenticated user') raise exception.Unauthorized(msg) try: user_ref = self._authenticate(REMOTE_USER, context) auth_context['user_id'] = user_ref['id'] if ('kerberos' in CONF.token.bind and (context['environment'].get('AUTH_TYPE', '').lower() == 'negotiate')): auth_context['bind']['kerberos'] = user_ref['name'] except Exception: msg = _('Unable to lookup user %s') % (REMOTE_USER) raise exception.Unauthorized(msg) @abc.abstractmethod def _authenticate(self, remote_user, context): """Look up the user in the identity backend. Return user_ref """ pass @dependency.requires('identity_api') class DefaultDomain(Base): def _authenticate(self, remote_user, context): """Use remote_user to look up the user in the identity backend.""" domain_id = CONF.identity.default_domain_id user_ref = self.identity_api.get_user_by_name(remote_user, domain_id) return user_ref @dependency.requires('identity_api', 'resource_api') class Domain(Base): def _authenticate(self, remote_user, context): """Use remote_user to look up the user in the identity backend. The domain will be extracted from the REMOTE_DOMAIN environment variable if present. If not, the default domain will be used. """ username = remote_user try: domain_name = context['environment']['REMOTE_DOMAIN'] except KeyError: domain_id = CONF.identity.default_domain_id else: domain_ref = self.resource_api.get_domain_by_name(domain_name) domain_id = domain_ref['id'] user_ref = self.identity_api.get_user_by_name(username, domain_id) return user_ref @dependency.requires('assignment_api', 'identity_api') class KerberosDomain(Domain): """Allows `kerberos` as a method.""" method = 'kerberos' def _authenticate(self, remote_user, context): auth_type = context['environment'].get('AUTH_TYPE') if auth_type != 'Negotiate': raise exception.Unauthorized(_("auth_type is not Negotiate")) return super(KerberosDomain, self)._authenticate(remote_user, context) class ExternalDefault(DefaultDomain): """Deprecated. Please use keystone.auth.external.DefaultDomain instead.""" @versionutils.deprecated( as_of=versionutils.deprecated.ICEHOUSE, in_favor_of='keystone.auth.external.DefaultDomain', remove_in=+1) def __init__(self): super(ExternalDefault, self).__init__() class ExternalDomain(Domain): """Deprecated. Please use keystone.auth.external.Domain instead.""" @versionutils.deprecated( as_of=versionutils.deprecated.ICEHOUSE, in_favor_of='keystone.auth.external.Domain', remove_in=+1) def __init__(self): super(ExternalDomain, self).__init__() @dependency.requires('identity_api') class LegacyDefaultDomain(Base): """Deprecated. Please use keystone.auth.external.DefaultDomain instead. This plugin exists to provide compatibility for the unintended behavior described here: https://bugs.launchpad.net/keystone/+bug/1253484 """ @versionutils.deprecated( as_of=versionutils.deprecated.ICEHOUSE, in_favor_of='keystone.auth.external.DefaultDomain', remove_in=+1) def __init__(self): super(LegacyDefaultDomain, self).__init__() def _authenticate(self, remote_user, context): """Use remote_user to look up the user in the identity backend.""" # NOTE(dolph): this unintentionally discards half the REMOTE_USER value names = remote_user.split('@') username = names.pop(0) domain_id = CONF.identity.default_domain_id user_ref = self.identity_api.get_user_by_name(username, domain_id) return user_ref @dependency.requires('identity_api', 'resource_api') class LegacyDomain(Base): """Deprecated. Please use keystone.auth.external.Domain instead.""" @versionutils.deprecated( as_of=versionutils.deprecated.ICEHOUSE, in_favor_of='keystone.auth.external.Domain', remove_in=+1) def __init__(self): super(LegacyDomain, self).__init__() def _authenticate(self, remote_user, context): """Use remote_user to look up the user in the identity backend. If remote_user contains an `@` assume that the substring before the rightmost `@` is the username, and the substring after the @ is the domain name. """ names = remote_user.rsplit('@', 1) username = names.pop(0) if names: domain_name = names[0] domain_ref = self.resource_api.get_domain_by_name(domain_name) domain_id = domain_ref['id'] else: domain_id = CONF.identity.default_domain_id user_ref = self.identity_api.get_user_by_name(username, domain_id) return user_ref
apache-2.0
[ 3, 1898, 6171, 14260, 2752, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 624, 1197, 8361, 18802, 15995, 30317, 624, 199, 199, 646, 13022, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 646, 3816, 199, 199, 504, 19395, 492, 1790, 199, 504, 19395, 14, 2330, 492, 5936, 199, 504, 19395, 492, 1919, 199, 504, 19395, 14, 73, 1085, 78, 492, 485, 199, 504, 19395, 14, 8512, 14, 2330, 492, 1015, 1208, 421, 199, 3103, 275, 4810, 14, 3103, 421, 199, 32, 4174, 14, 525, 63, 6577, 8, 3175, 14, 22254, 9, 199, 533, 3523, 8, 1178, 14, 2817, 3767, 2461, 304, 339, 1083, 275, 283, 5159, 7, 339, 347, 12895, 8, 277, 12, 1067, 12, 1790, 63, 815, 12, 1790, 63, 1100, 304, 267, 408, 6119, 820, 2769, 9407, 63, 3791, 370, 3648, 1536, 314, 922, 315, 314, 8503, 4865, 14, 398, 1790, 63, 1100, 365, 376, 315, 13, 548, 1750, 626, 911, 506, 4588, 543, 314, 267, 922, 63, 344, 687, 314, 3503, 922, 687, 314, 820, 2769, 9407, 63, 3791, 2589, 1750, 14, 267, 408, 267, 862, 26, 288, 820, 2769, 9407, 63, 3791, 275, 1067, 459, 5418, 2545, 16058, 63, 3791, 418, 267, 871, 4067, 26, 288, 1499, 275, 4018, 1944, 15082, 922, 358, 288, 746, 1919, 14, 28290, 8, 1328, 9, 267, 862, 26, 288, 922, 63, 1121, 275, 291, 423, 13975, 8, 16058, 63, 3791, 12, 1067, 9, 288, 1790, 63, 1100, 459, 751, 63, 344, 418, 275, 922, 63, 1121, 459, 344, 418, 288, 340, 661, 2570, 23920, 7, 315, 6392, 14, 1418, 14, 3409, 436, 355, 334, 1100, 459, 5418, 2278, 362, 360, 5580, 63, 2711, 297, 12548, 2325, 342, 326, 508, 283, 21961, 323, 8109, 355, 1790, 63, 1100, 459, 3409, 2545, 2570, 23920, 418, 275, 922, 63, 1121, 459, 354, 418, 267, 871, 2186, 26, 288, 1499, 275, 4018, 6005, 370, 4237, 922, 450, 83, 358, 450, 334, 16058, 63, 3791, 9, 288, 746, 1919, 14, 28290, 8, 1328, 9, 339, 768, 3175, 14, 10315, 272, 347, 485, 13975, 8, 277, 12, 3982, 63, 751, 12, 1067, 304, 267, 408, 20926, 1536, 314, 922, 315, 314, 8503, 4865, 14, 398, 1432, 922, 63, 1121, 267, 408, 267, 986, 421, 199, 32, 8575, 14, 6537, 360, 5582, 63, 1246, 358, 199, 533, 3758, 7705, 8, 1563, 304, 272, 347, 485, 13975, 8, 277, 12, 3982, 63, 751, 12, 1067, 304, 267, 408, 6119, 3982, 63, 751, 370, 3648, 1536, 314, 922, 315, 314, 8503, 4865, 1041, 267, 2881, 63, 344, 275, 6392, 14, 5582, 14, 885, 63, 2261, 63, 344, 267, 922, 63, 1121, 275, 291, 14, 5582, 63, 1246, 14, 362, 63, 751, 63, 991, 63, 354, 8, 3846, 63, 751, 12, 2881, 63, 344, 9, 267, 372, 922, 63, 1121, 421, 199, 32, 8575, 14, 6537, 360, 5582, 63, 1246, 297, 283, 1927, 63, 1246, 358, 199, 533, 14061, 8, 1563, 304, 272, 347, 485, 13975, 8, 277, 12, 3982, 63, 751, 12, 1067, 304, 267, 408, 6119, 3982, 63, 751, 370, 3648, 1536, 314, 922, 315, 314, 8503, 4865, 14, 398, 710, 2881, 911, 506, 12509, 687, 314, 820, 2769, 9407, 63, 7378, 3734, 267, 1750, 340, 3451, 14, 982, 440, 12, 314, 849, 2881, 911, 506, 1202, 14, 267, 408, 398, 3434, 275, 3982, 63, 751, 267, 862, 26, 288, 2881, 63, 354, 275, 1067, 459, 5418, 2545, 16058, 63, 7378, 418, 267, 871, 4067, 26, 288, 2881, 63, 344, 275, 6392, 14, 5582, 14, 885, 63, 2261, 63, 344, 267, 587, 26, 288, 2881, 63, 1121, 275, 291, 14, 1927, 63, 1246, 14, 362, 63, 2261, 63, 991, 63, 354, 8, 2261, 63, 354, 9, 288, 2881, 63, 344, 275, 2881, 63, 1121, 459, 344, 418, 398, 922, 63, 1121, 275, 291, 14, 5582, 63, 1246, 14, 362, 63, 751, 63, 991, 63, 354, 8, 2473, 12, 2881, 63, 344, 9, 267, 372, 922, 63, 1121, 421, 199, 32, 8575, 14, 6537, 360, 10861, 63, 1246, 297, 283, 5582, 63, 1246, 358, 199, 533, 1804, 281, 23920, 7705, 8, 7705, 304, 272, 408, 19780, 658, 2570, 23920, 64, 465, 282, 1083, 1041, 272, 1083, 275, 283, 2570, 23920, 7, 339, 347, 485, 13975, 8, 277, 12, 3982, 63, 751, 12, 1067, 304, 267, 1790, 63, 466, 275, 1067, 459, 5418, 2278, 362, 360, 5580, 63, 2711, 358, 267, 340, 1790, 63, 466, 1137, 283, 4698, 14727, 323, 356, 288, 746, 1919, 14, 28290, 6115, 1178, 63, 466, 365, 440, 5612, 14727, 323, 2237, 267, 372, 1613, 8, 43, 281, 23920, 7705, 12, 291, 10445, 13975, 8, 3846, 63, 751, 12, 1067, 9, 421, 199, 533, 18802, 2698, 8, 2698, 7705, 304, 272, 408, 19727, 14, 7754, 675, 19395, 14, 1178, 14, 5159, 14, 2698, 7705, 3140, 1041, 339, 768, 1023, 1208, 14, 6667, 8, 267, 465, 63, 1618, 29, 1023, 1208, 14, 6667, 14, 4047, 2979, 4701, 12, 267, 315, 63, 17520, 63, 1618, 534, 19143, 14, 1178, 14, 5159, 14, 2698, 7705, 297, 267, 2813, 63, 262, 29744, 17, 9, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 11389, 2698, 12, 291, 2843, 826, 4533, 421, 199, 533, 18802, 7705, 8, 7705, 304, 272, 408, 19727, 14, 7754, 675, 19395, 14, 1178, 14, 5159, 14, 7705, 3140, 1041, 339, 768, 1023, 1208, 14, 6667, 8, 267, 465, 63, 1618, 29, 1023, 1208, 14, 6667, 14, 4047, 2979, 4701, 12, 267, 315, 63 ]
[ 1898, 6171, 14260, 2752, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 624, 1197, 8361, 18802, 15995, 30317, 624, 199, 199, 646, 13022, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 646, 3816, 199, 199, 504, 19395, 492, 1790, 199, 504, 19395, 14, 2330, 492, 5936, 199, 504, 19395, 492, 1919, 199, 504, 19395, 14, 73, 1085, 78, 492, 485, 199, 504, 19395, 14, 8512, 14, 2330, 492, 1015, 1208, 421, 199, 3103, 275, 4810, 14, 3103, 421, 199, 32, 4174, 14, 525, 63, 6577, 8, 3175, 14, 22254, 9, 199, 533, 3523, 8, 1178, 14, 2817, 3767, 2461, 304, 339, 1083, 275, 283, 5159, 7, 339, 347, 12895, 8, 277, 12, 1067, 12, 1790, 63, 815, 12, 1790, 63, 1100, 304, 267, 408, 6119, 820, 2769, 9407, 63, 3791, 370, 3648, 1536, 314, 922, 315, 314, 8503, 4865, 14, 398, 1790, 63, 1100, 365, 376, 315, 13, 548, 1750, 626, 911, 506, 4588, 543, 314, 267, 922, 63, 344, 687, 314, 3503, 922, 687, 314, 820, 2769, 9407, 63, 3791, 2589, 1750, 14, 267, 408, 267, 862, 26, 288, 820, 2769, 9407, 63, 3791, 275, 1067, 459, 5418, 2545, 16058, 63, 3791, 418, 267, 871, 4067, 26, 288, 1499, 275, 4018, 1944, 15082, 922, 358, 288, 746, 1919, 14, 28290, 8, 1328, 9, 267, 862, 26, 288, 922, 63, 1121, 275, 291, 423, 13975, 8, 16058, 63, 3791, 12, 1067, 9, 288, 1790, 63, 1100, 459, 751, 63, 344, 418, 275, 922, 63, 1121, 459, 344, 418, 288, 340, 661, 2570, 23920, 7, 315, 6392, 14, 1418, 14, 3409, 436, 355, 334, 1100, 459, 5418, 2278, 362, 360, 5580, 63, 2711, 297, 12548, 2325, 342, 326, 508, 283, 21961, 323, 8109, 355, 1790, 63, 1100, 459, 3409, 2545, 2570, 23920, 418, 275, 922, 63, 1121, 459, 354, 418, 267, 871, 2186, 26, 288, 1499, 275, 4018, 6005, 370, 4237, 922, 450, 83, 358, 450, 334, 16058, 63, 3791, 9, 288, 746, 1919, 14, 28290, 8, 1328, 9, 339, 768, 3175, 14, 10315, 272, 347, 485, 13975, 8, 277, 12, 3982, 63, 751, 12, 1067, 304, 267, 408, 20926, 1536, 314, 922, 315, 314, 8503, 4865, 14, 398, 1432, 922, 63, 1121, 267, 408, 267, 986, 421, 199, 32, 8575, 14, 6537, 360, 5582, 63, 1246, 358, 199, 533, 3758, 7705, 8, 1563, 304, 272, 347, 485, 13975, 8, 277, 12, 3982, 63, 751, 12, 1067, 304, 267, 408, 6119, 3982, 63, 751, 370, 3648, 1536, 314, 922, 315, 314, 8503, 4865, 1041, 267, 2881, 63, 344, 275, 6392, 14, 5582, 14, 885, 63, 2261, 63, 344, 267, 922, 63, 1121, 275, 291, 14, 5582, 63, 1246, 14, 362, 63, 751, 63, 991, 63, 354, 8, 3846, 63, 751, 12, 2881, 63, 344, 9, 267, 372, 922, 63, 1121, 421, 199, 32, 8575, 14, 6537, 360, 5582, 63, 1246, 297, 283, 1927, 63, 1246, 358, 199, 533, 14061, 8, 1563, 304, 272, 347, 485, 13975, 8, 277, 12, 3982, 63, 751, 12, 1067, 304, 267, 408, 6119, 3982, 63, 751, 370, 3648, 1536, 314, 922, 315, 314, 8503, 4865, 14, 398, 710, 2881, 911, 506, 12509, 687, 314, 820, 2769, 9407, 63, 7378, 3734, 267, 1750, 340, 3451, 14, 982, 440, 12, 314, 849, 2881, 911, 506, 1202, 14, 267, 408, 398, 3434, 275, 3982, 63, 751, 267, 862, 26, 288, 2881, 63, 354, 275, 1067, 459, 5418, 2545, 16058, 63, 7378, 418, 267, 871, 4067, 26, 288, 2881, 63, 344, 275, 6392, 14, 5582, 14, 885, 63, 2261, 63, 344, 267, 587, 26, 288, 2881, 63, 1121, 275, 291, 14, 1927, 63, 1246, 14, 362, 63, 2261, 63, 991, 63, 354, 8, 2261, 63, 354, 9, 288, 2881, 63, 344, 275, 2881, 63, 1121, 459, 344, 418, 398, 922, 63, 1121, 275, 291, 14, 5582, 63, 1246, 14, 362, 63, 751, 63, 991, 63, 354, 8, 2473, 12, 2881, 63, 344, 9, 267, 372, 922, 63, 1121, 421, 199, 32, 8575, 14, 6537, 360, 10861, 63, 1246, 297, 283, 5582, 63, 1246, 358, 199, 533, 1804, 281, 23920, 7705, 8, 7705, 304, 272, 408, 19780, 658, 2570, 23920, 64, 465, 282, 1083, 1041, 272, 1083, 275, 283, 2570, 23920, 7, 339, 347, 485, 13975, 8, 277, 12, 3982, 63, 751, 12, 1067, 304, 267, 1790, 63, 466, 275, 1067, 459, 5418, 2278, 362, 360, 5580, 63, 2711, 358, 267, 340, 1790, 63, 466, 1137, 283, 4698, 14727, 323, 356, 288, 746, 1919, 14, 28290, 6115, 1178, 63, 466, 365, 440, 5612, 14727, 323, 2237, 267, 372, 1613, 8, 43, 281, 23920, 7705, 12, 291, 10445, 13975, 8, 3846, 63, 751, 12, 1067, 9, 421, 199, 533, 18802, 2698, 8, 2698, 7705, 304, 272, 408, 19727, 14, 7754, 675, 19395, 14, 1178, 14, 5159, 14, 2698, 7705, 3140, 1041, 339, 768, 1023, 1208, 14, 6667, 8, 267, 465, 63, 1618, 29, 1023, 1208, 14, 6667, 14, 4047, 2979, 4701, 12, 267, 315, 63, 17520, 63, 1618, 534, 19143, 14, 1178, 14, 5159, 14, 2698, 7705, 297, 267, 2813, 63, 262, 29744, 17, 9, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 11389, 2698, 12, 291, 2843, 826, 4533, 421, 199, 533, 18802, 7705, 8, 7705, 304, 272, 408, 19727, 14, 7754, 675, 19395, 14, 1178, 14, 5159, 14, 7705, 3140, 1041, 339, 768, 1023, 1208, 14, 6667, 8, 267, 465, 63, 1618, 29, 1023, 1208, 14, 6667, 14, 4047, 2979, 4701, 12, 267, 315, 63, 0 ]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 1 ]
lainegates/DDA
loadDataTools.py
1
41566
# coding=gbk #*************************************************************************** #* * #* Copyright (c) 2009, 2010 * #* Xiaolong Cheng <lainegates@163.com> * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * #* as published by the Free Software Foundation; either version 2 of * #* the License, or (at your option) any later version. * #* for detail see the LICENCE text file. * #* * #* 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 Library General Public License for more details. * #* * #* You should have received a copy of the GNU Library General Public * #* License along with this program; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * #*************************************************************************** import FreeCADGui from PyQt4 import QtCore , QtGui import Base from Base import showErrorMessageBox import DDADatabase def checkFileExists(path): import os if not os.path.isfile(path): showErrorMessageBox("FileError" , "File \"%s\" doesn't exist"%path) return False return True class FileReader(): ''' read files , this class will omit the blank lines ''' def __init__(self): self.__fileName = None self.__file = None def setFile(self, fileName): self.__fileName = fileName try: self.__file = open(self.__fileName , 'rb') except: showErrorMessageBox('file open error' , fileName + ' open failed') return False return True def getNextLine(self): line = self.__file.readline() while len(line)!=0: line = line.strip() if len(line)==0: # blank line with '\n' line = self.__file.readline() else: break # this line is not blank if len(line)==0: # file already ends import Base Base.showErrorMessageBox('file error' , 'unvalid data') raise return line def closeFile(self): self.__file.close() class Block: def __init__(self): self.blockIndex = 0 # the index of this block self.startNo = 0 self.endNo = 0 self.vertices = [] self.parameters = [] self.stressX = 0 self.stressY = 0 self.stressXY = 0 self.materialNo = 0 # used in dc result # count how many hole points are on this block self.holePointsCount = 0 def getPoints(self): return [(t[1],t[2],0) for t in self.vertices] def visible(self): if self.holePointsCount>0: return False elif self.holePointsCount==0: return True else : raise Exception('unvalid value %f'% self.holePointsCount) class DDALine: def __init__(self , p1 , p2 , materialNo): self.startPoint = p1 self.endPoint = p2 self.materialNo = materialNo self.visible = True class BoltElement(DDALine): def __init__(self , p1 , p2 , e , t , f): DDALine.__init__(self, p1, p2, 0) self.e = e self.t = t self.f = f class DDAPolyLine: def __init__(self , pts , materialNo): self.pts = pts self.materialNo = materialNo self.visible = True class DDAPoint: def __init__(self , x=0 , y=0): self.x = x self.y = y self.Xspeed = 0 self.Yspeed = 0 self.blockNo = 0 self.visible = True class FixedPoint(DDAPoint): pass class LoadingPoint(DDAPoint): pass class MeasuredPoint(DDAPoint): def __init__(self): DDAPoint.__init__(self) self.u = 0 self.v = 0 self.r = 0 self.stressX = 0 self.stressY = 0 self.stressXY = 0 class HolePoint(DDAPoint): pass class Graph: def __init__(self): self.blocks = [] self.fixedPoints = [] self.measuredPoints = [] self.loadingPoints = [] self.holePoints = [] self.boltElements = [] def reset(self): self.blocks = [] self.fixedPoints = [] self.measuredPoints = [] self.loadingPoints = [] self.boltElements = [] class BaseParseData(): ''' parse data loaded , data may be DL data , DC data etc. ''' def parse(self , filename): ''' abstract function , overwrited by subclass ''' pass def parseFloatNum(self , numStr , itemName='None'): try: num = float(numStr) except: try: num = int(numStr) except: showErrorMessageBox( 'InputError' , itemName + ' should be a float number') return None return num def parseIntNum(self , numStr , itemName='None'): try: num = int(numStr) except: showErrorMessageBox( 'InputError' , itemName + ' should be a integer') return None return num class ParseAndLoadDLData(BaseParseData): ''' parse DL data ''' def __init__(self): self.reset() self.__fileReader = FileReader() def GetResources(self): return { 'Pixmap' : 'LoadDLInput', 'MenuText': 'LoadDCInputData', 'ToolTip': "Load DC Input Data"} def Activated(self): from Base import __currentProjectPath__ if self.parse(__currentProjectPath__ + '/data.dl'): self.save2Database() import Base Base.changeStep4Stage('ShapesAvailable') def reset(self): self.checkStatus = False self.__miniLength = 0 self.__jointSetNum = 0 self.__boundaryNodeNum = 0 self.__tunnelNum = 0 self.__addtionalLineNum = 0 self.__materialLineNum = 0 self.__boltElementNum = 0 self.__fixedPointNum = 0 self.__loadingPointNum = 0 self.__measuredPointNum = 0 self.__holePointNum = 0 self.__jointSets = [] self.__slope = [] self.__boundaryNodes = [] self.__tunnels = [] self.__additionalLines = [] self.__materialLines = [] self.__boltElements = [] self.__fixedPoints = [] self.__loadingPoints = [] self.__measuredPoints = [] self.__holePoints = [] def parse(self , filename ): ''' parse DL data :param filename: the data file name ''' self.reset() if not self.__fileReader.setFile(filename): return False if not self.__parsePandect(): return False if not self.__parseJointSets(): return False if not self.__parseBoundaryNodes(): return False if not self.__parseTunnels(): return False if not self.__parseLines(): return False if not self.__parsePoints(): return False self.__fileReader.closeFile() return True def __parseJointSets(self): ''' parse joint sets ''' # joint dip , dip direction for i in range(self.__jointSetNum): self.__jointSets.append(range(6)) tmpNums = self.__jointSets[-1] str = self.__fileReader.getNextLine() nums = str.strip().split() tmpNums[0] = self.parseFloatNum(nums[0], 'joint dip') tmpNums[1] = self.parseFloatNum(nums[1], 'dip direction') if tmpNums[0] == None or tmpNums[1] == None : return False print 'joint %d : ( %f , %f)'%( i , tmpNums[0],tmpNums[1]) # slope dip , dip direction tmpNumbers = [0 , 1] str = self.__fileReader.getNextLine() nums = str.strip().split() tmpNumbers[0] = self.parseFloatNum(nums[0], 'slope dip') tmpNumbers[1] = self.parseFloatNum(nums[1], 'dip direction') if tmpNumbers[0] == None or tmpNumbers[1] == None : return False print 'slope : ( %f , %f)'%(tmpNumbers[0],tmpNumbers[1]) self.__slope.append((tmpNumbers[0],tmpNumbers[1])) for i in range(self.__jointSetNum): tmpNums = self.__jointSets[i] str = self.__fileReader.getNextLine() nums = str.strip().split() tmpNums[2] = self.parseFloatNum(nums[0], 'spacing') tmpNums[3] = self.parseFloatNum(nums[1], 'length') tmpNums[4] = self.parseFloatNum(nums[2], 'bridge') tmpNums[5] = self.parseFloatNum(nums[3], 'random') if tmpNums[2] == None or tmpNums[3] == None or tmpNums[4] == None or tmpNums[5] == None : return False print 'joint %d parameter : ( %f , %f , %f , %f)'%(i , tmpNums[2],tmpNums[3],tmpNums[4],tmpNums[5]) return True def __parseBoundaryNodes(self ): ''' parse boundary nodes ''' for i in range(self.__boundaryNodeNum): str = self.__fileReader.getNextLine() nums = str.strip().split() tmpNums = [0 , 1 , 0] tmpNums[0] = self.parseFloatNum(nums[0], 'coordinate number') tmpNums[1] = self.parseFloatNum(nums[1], 'coordinate number') if tmpNums[0] == None or tmpNums[1] == None : return False print 'boundary line %d : (%f , %f)'%(i , tmpNums[0] , tmpNums[1]) self.__boundaryNodes.append(tmpNums) return True def __parseTunnels(self ): ''' parse tunnels ''' for i in range(self.__tunnelNum): # tunnel shape number str = self.__fileReader.getNextLine() shapeNo = self.parseIntNum(str, 'tunnel shape number') if shapeNo == None : return False # tunnel a b c r tmpNums = range(4) str = self.__fileReader.getNextLine() names = ['a' , 'b' , 'c' , 'r'] nums = str.strip().split() for j in range(4): tmpNums[j] = self.parseFloatNum(nums[j], 'tunnel ' +names[j]) if tmpNums[j] == None : return False # tunnel center center = [0 , 1] str = self.__fileReader.getNextLine() nums = str.strip().split() for j in range(2): center[j] = self.parseFloatNum(nums[j], 'tunnel center number') if center[j] == None : return False print 'tunnel %d : (%f , %f , %f , %f , %f , %f , %f)'%(i , shapeNo , tmpNums[0] , tmpNums[1] , tmpNums[2] , tmpNums[3] , center[0] , center[1]) self.__tunnels.append((shapeNo , tmpNums[0] , tmpNums[1] , tmpNums[2] , tmpNums[3] , center[0] , center[1])) return True def __parseLines(self ): ''' parse material lines , addtional lines ''' tmpNums = range(4) # additional line for i in range(self.__addtionalLineNum): str = self.__fileReader.getNextLine() nums = str.strip().split() for j in range(4): tmpNums[j] = self.parseFloatNum(nums[j], 'additional line coordinate number') if tmpNums[j] == None : return False materialNo = self.parseFloatNum(nums[4], 'additional line material number') if materialNo == None : return False print 'additional line %d :(%f , %f , %f , %f , %f)'%(i , tmpNums[0] , tmpNums[1] ,tmpNums[2] , tmpNums[3] , materialNo) self.__additionalLines.append((tmpNums[0] , tmpNums[1] ,tmpNums[2] , tmpNums[3] , materialNo)) # material line for i in range(self.__materialLineNum): str = self.__fileReader.getNextLine() nums = str.strip().split() for j in range(4): tmpNums[j] = self.parseFloatNum(nums[j], 'material line coordinate number') if tmpNums[j] == None : return False materialNo = self.parseFloatNum(nums[4], 'block material number') if materialNo == None : return False print 'block material %d :(%f , %f , %f , %f , %f)'%(i , tmpNums[0] , tmpNums[1] ,tmpNums[2] , tmpNums[3] , materialNo) self.__materialLines.append((tmpNums[0] , tmpNums[1] ,tmpNums[2] , tmpNums[3] , materialNo)) # bolt elements for i in range(self.__boltElementNum): str = self.__fileReader.getNextLine() nums = str.strip().split() for j in range(4): tmpNums[j] = self.parseFloatNum(nums[j], 'bolt element coordinate number') if tmpNums[j] == None : return False e0 = self.parseFloatNum(nums[4], 'bolt element e0') t0 = self.parseFloatNum(nums[5], 'bolt element t0') f0 = self.parseFloatNum(nums[6], 'bolt element f0') if materialNo == None : return False print 'block material %d :(%f , %f , %f , %f , %f , %f , %f)'%(i , tmpNums[0] , tmpNums[1] ,tmpNums[2] , tmpNums[3] , e0 , t0 , f0) self.__boltElements.append((tmpNums[0] , tmpNums[1] ,tmpNums[2] , tmpNums[3] , e0 , t0 , f0)) return True def __parsePoints(self): ''' parse points , fixed points , loading points , measured points , hole points :param file: input dl file ''' tmpNums = range(4) # fixed points for i in range(self.__fixedPointNum): str = self.__fileReader.getNextLine() nums = str.strip().split() for j in range(4): tmpNums[j] = self.parseFloatNum(nums[j], 'fixed point coordinate number') if tmpNums[j] == None : return False print 'fixed line %d : (%f , %f , %f , %f)'%(i , tmpNums[0] , tmpNums[1] ,tmpNums[2] , tmpNums[3]) self.__fixedPoints.append((tmpNums[0] , tmpNums[1] ,tmpNums[2] , tmpNums[3])) # measured points itemNames = ['loading point' , 'measured point' , 'hole point'] realNums = [self.__loadingPointNum , self.__measuredPointNum , self.__holePointNum] for k in range(len(itemNames)): for i in range(realNums[k]): str = self.__fileReader.getNextLine() nums = str.strip().split() for j in range(2): tmpNums[j] = self.parseFloatNum(nums[j], itemNames[k] +' coordinate number') if tmpNums[j] == None : return False print '%s %d : (%f , %f)'%(itemNames[k] , i , tmpNums[0] , tmpNums[1]) if k==0 : self.__loadingPoints.append((tmpNums[0] , tmpNums[1])) elif k==1 : self.__measuredPoints.append((tmpNums[0] , tmpNums[1])) elif k==2 : self.__holePoints.append((tmpNums[0] , tmpNums[1])) return True def __parsePandect(self): ''' parse Numbers , for example , number of joint set ''' self.__miniLength = self.parseFloatNum(self.__fileReader.getNextLine(), 'minimun edge length') if self.__miniLength == None : return False self.__jointSetNum = self.parseIntNum(self.__fileReader.getNextLine(), 'joint set number') if self.__jointSetNum == None: return False self.__boundaryNodeNum = self.parseIntNum(self.__fileReader.getNextLine(), 'boundary line number') if self.__boundaryNodeNum == None: return False self.__tunnelNum = self.parseIntNum(self.__fileReader.getNextLine(), 'tunnel number') if self.__tunnelNum == None: return False self.__addtionalLineNum = self.parseIntNum(self.__fileReader.getNextLine(), 'additional line number') if self.__addtionalLineNum == None: return False self.__materialLineNum = self.parseIntNum(self.__fileReader.getNextLine(), 'material line number') if self.__materialLineNum == None: return False self.__boltElementNum = self.parseIntNum(self.__fileReader.getNextLine(), 'bolt element number') if self.__boltElementNum == None: return False self.__fixedPointNum = self.parseIntNum(self.__fileReader.getNextLine(), 'fixed point number') if self.__fixedPointNum == None: return False self.__loadingPointNum = self.parseIntNum(self.__fileReader.getNextLine(), 'loading point number') if self.__loadingPointNum == None: return False self.__measuredPointNum = self.parseIntNum(self.__fileReader.getNextLine(), 'measured point number') if self.__measuredPointNum == None: return False self.__holePointNum = self.parseIntNum(self.__fileReader.getNextLine(), 'hole point number') if self.__holePointNum == None: return False return True def save2Database(self): ''' save data to DDADatabase.dl_database ''' from DDAShapes import DDAJointSets , DDATunnels DDADatabase.dl_database = DDADatabase.DLDatabase() database = DDADatabase.dl_database database.jointSets = self.__jointSets DDAJointSets.dataTable.refreshData(database.jointSets) database.slope = self.__slope DDAJointSets.slopeDataTable.refreshData(database.slope) database.tunnels = self.__tunnels DDATunnels.dataTable.refreshData(database.tunnels) # boundaryNodes pts = [tuple(p) for p in self.__boundaryNodes] pts.append(pts[0]) database.boundaryNodes = [DDAPolyLine( pts, 1)] # additional lines database.additionalLines = \ [DDALine((p[0],p[1],0) , (p[2],p[3],0) , p[4]) for p in self.__additionalLines] # material line database.materialLines = \ [DDALine((p[0],p[1],0) , (p[2],p[3],0) , p[4]) for p in self.__materialLines] # bolt element database.boltElements = \ [BoltElement((p[0],p[1],0) , (p[2],p[3],0) , p[4] , p[5] , p[6]) for p in self.__boltElements] # points database.fixedPoints = [DDAPoint(t[0],t[1]) for t in self.__fixedPoints] database.loadingPoints = [DDAPoint(t[0],t[1]) for t in self.__loadingPoints] database.measuredPoints = [DDAPoint(t[0],t[1]) for t in self.__measuredPoints] database.holePoints = [DDAPoint(t[0],t[1]) for t in self.__holePoints] self.reset() import Base Base.refreshAllShapes() class ParseDFInputParameters(BaseParseData): def __init__(self): self.__file = None self.reset() def reset(self): from DDADatabase import df_inputDatabase self.paras = df_inputDatabase.paras self.paras.reset() def __parseParaSchema(self): ''' parse parameters from DF parameters file :param infile: ''' for i in range(7): line = self.__file.getNextLine() t =self.parseFloatNum(line) if t==None: return False if i==0: self.paras.ifDynamic = float(t) elif i==1: self.paras.stepsNum = int(t) elif i==2: self.paras.blockMatsNum = int(t) elif i==3: self.paras.jointMatsNum = int(t) elif i==4: self.paras.ratio = t elif i==5: self.paras.OneSteptimeLimit = int(t) else: self.paras.springStiffness = int(t) print 'DF Para : IfDynamic: %d steps: %d blockMats: %d JointMats: %d Ratio: %f timeInterval: %d stiffness: %d'\ %(self.paras.ifDynamic, self.paras.stepsNum , self.paras.blockMatsNum , self.paras.jointMatsNum \ , self.paras.ratio, self.paras.OneSteptimeLimit, self.paras.springStiffness) print 'Df parameters schema done' return True def __parsePointsParameters(self): ''' parse parameters for fixed points and loading points :param infile: ''' # parse fixed points and loading points' type 0 : fixed points , 2: loading points # fixed points from DDADatabase import df_inputDatabase if len(df_inputDatabase.fixedPoints)>0: line = self.__file.getNextLine() nums = line.split() for i in nums: if self.parseIntNum(i)==None : return False print nums # loading points if len(df_inputDatabase.loadingPoints)>0: line = self.__file.getNextLine() nums = line.split() for i in nums: if self.parseIntNum(i)==None : return False print nums # parse loading points parameters (starttime , stressX , stressY , endtime , stressX , stressY) for i in range(len(df_inputDatabase.loadingPoints)): digits = [1]*6 line1 = self.__file.getNextLine() nums1 = line1.split() line2 = self.__file.getNextLine() nums2 = line2.split() for j in range(3): digits[j] = self.parseIntNum(nums1[j]) digits[j+3] = self.parseIntNum(nums2[j]) if None in digits: return False self.paras.loadingPointMats.append(digits) print nums1 , nums2 print 'fixed points and loading points done.' return True def __parseBlocksAndJointsPara(self): ''' parse parameters for blocks and joints' :param infile: ''' for i in range(self.paras.blockMatsNum): digits = [1]*14 line1 = self.__file.getNextLine() nums1 = line1.split() for j in range(5): digits[j] = self.parseFloatNum(nums1[j]) line2 = self.__file.getNextLine() nums2 = line2.split() line3 = self.__file.getNextLine() nums3 = line3.split() line4 = self.__file.getNextLine() nums4 = line4.split() for j in range(3): digits[j+5] = self.parseFloatNum(nums2[j]) digits[j+8] = self.parseFloatNum(nums3[j]) digits[j+11] = self.parseFloatNum(nums4[j]) if None in digits: return False self.paras.blockMats.append(digits) print digits for i in range(self.paras.jointMatsNum): digits = [1]*3 line = self.__file.getNextLine() nums = line.split() for j in range(3): digits[j] = self.parseFloatNum(nums[j]) if None in digits: return False self.paras.jointMats.append(digits) print digits print 'DF blocks and block vertices\' parameters done.' return True def __parseRestPara(self ): ''' parse SOR and axes :param infile: ''' # parse SOR line = self.__file.getNextLine() self.paras.SOR = self.parseFloatNum(line) if self.paras.SOR==None: return False print 'SOR : ' , self.paras.SOR line = self.__file.getNextLine() nums = line.split() for i in range(3): if self.parseFloatNum(nums[i])==None: return False print nums print 'DF parameters all done.' return True def parse(self , path = None): self.reset() if not path: Base.__currentProjectPath__+'/parameters.df' if not checkFileExists(path): return False import Base self.__file = FileReader() self.__file.setFile(path) if not self.__parseParaSchema() or not self.__parsePointsParameters() \ or not self.__parseBlocksAndJointsPara() or not self.__parseRestPara(): return False return True class ParseDFInputGraphData(BaseParseData): def __init__(self): self.__fileReader = None def GetResources(self): return { 'Pixmap' : 'LoadDFInput', 'MenuText': 'LoadDFInputData', 'ToolTip': "Load DF Input Data"} def Activated(self): self.parse() import Base Base.changeStep4Stage('ShapesAvailable') def finish(self): pass def parse(self , path=None): self.refreshBlocksData() import Base if not path : path = Base.__currentProjectPath__+'/data.df' if not checkFileExists(path): return False file = open(path , "rb") if not self.__parseDataSchema(file) or not self.__parseBlocks(file) or \ not self.__parseBlockVertices(file) or not self.__parseBoltElements(file) \ or not self.__parsePoints(file): Base.showErrorMessageBox("DataError", 'Data input unvalid') return False return True def refreshBlocksData(self): import Base self.graph = Base.getDatabaser4CurrentStage() self.graph.reset() self.blocksNum = 0 self.blockVerticesNum = 0 self.fixedPointsNum = 0 self.loadingPointsNum = 0 self.measuredPointsNum = 0 self.boltElementsNum = 0 def __parseDataSchema(self , infile): line = infile.readline() nums = line.split() self.blocksNum = self.parseIntNum(nums[0]) self.boltElementsNum = self.parseIntNum(nums[1]) self.blockVerticesNum = self.parseIntNum(nums[2]) line = infile.readline() nums = line.split() self.fixedPointsNum = self.parseIntNum(nums[0]) self.loadingPointsNum = self.parseIntNum(nums[1]) self.measuredPointsNum = self.parseIntNum(nums[2]) if None in [self.blocksNum , self.boltElementsNum , self.blockVerticesNum \ , self.fixedPointsNum , self.loadingPointsNum , self.measuredPointsNum]: return False print 'DF data : blocks : %d bolts : %d vertices : %d fixed Pnts :%d LoadingPnts :%d MeasuredPnts: %d' \ %(self.blocksNum , self.boltElementsNum , self.blockVerticesNum \ , self.fixedPointsNum , self.loadingPointsNum , self.measuredPointsNum) return True def __parseBlocks(self , infile): ''' parsing blocks and try to get the maximum material No :param infile: ''' from DDADatabase import df_inputDatabase df_inputDatabase.blockMatCollections = set() blockMatCollection = df_inputDatabase.blockMatCollections for i in range(0 , self.blocksNum): line = infile.readline() nums = line.split() # get blocks' vertices' material No t0 = self.parseIntNum(nums[0]) t1 = self.parseIntNum(nums[1]) t2 = self.parseIntNum(nums[2]) if t0==None or t1==None or t2==None: return False tmpB = Block() tmpB.materialNo = t0 tmpB.startNo = t1 tmpB.endNo = t2 blockMatCollection.add(t0) self.graph.blocks.append(tmpB ) # print line , print 'DF blocks Info done.' return True def __parseBlockVertices(self,infile): ''' parsing blocks' vertices and try to get the maximum material No :param infile: ''' from DDADatabase import df_inputDatabase df_inputDatabase.jointMatCollections =set() jointMatCollection = df_inputDatabase.jointMatCollections ptsBounds = range(4) for i in range(self.blocksNum): tmpB = self.graph.blocks[i] for j in range(int(tmpB.endNo) - int(tmpB.startNo) +1): # read blocks vertices line = infile.readline() # print line nums = line.split() # get joint material No t0 = int(self.parseFloatNum(nums[0])) t1 = self.parseFloatNum(nums[1]) t2 = self.parseFloatNum(nums[2]) if t0==None or t1==None or t2==None: return False tmpB.vertices.append( (t0,t1,t2) ) jointMatCollection.add(t0) # get vertices' value boundary if i==0: ptsBounds[0]=ptsBounds[1] = t1 ptsBounds[2]=ptsBounds[2] = t2 else: if t1<ptsBounds[0]: ptsBounds[0]=t1 elif t1>ptsBounds[1]: ptsBounds[1]=t1 elif t2<ptsBounds[2]: ptsBounds[2]=t2 elif t2>ptsBounds[3]: ptsBounds[3]=t2 for i in range(4): # block parameters line = infile.readline() # print line nums = line.split() t0 = self.parseFloatNum(nums[0]) t1 = self.parseFloatNum(nums[1]) t2 = self.parseFloatNum(nums[2]) if t0==None or t1==None or t2==None: return False tmpB.parameters.extend([t0,t1,t2]) import Base margin = ptsBounds[1]-ptsBounds[0] if margin > (ptsBounds[3]-ptsBounds[2]): margin = ptsBounds[3]-ptsBounds[2] Base.__radius4Points__ = margin/60 print 'DF blocks vertices data done.' return True def __parseBoltElements(self , infile): for i in range(self.boltElementsNum): for j in range(3): line = infile.readline() print ' %d bolt elements parsed done'%self.boltElementsNum return True def parse1Point(self , line , point): #print line , nums = line.split() point.x = self.parseFloatNum(nums[0]) point.y = self.parseFloatNum(nums[1]) point.blockNo = int(self.parseFloatNum(nums[2])) def __parsePoints(self , infile): ''' parsing fixed , loading , and measured points :param infile: ''' for i in range(self.fixedPointsNum): pnt = FixedPoint() line = infile.readline() self.parse1Point(line , pnt) self.graph.fixedPoints.append(pnt) print ' fixed points : %d done'%self.fixedPointsNum for i in range(self.loadingPointsNum): pnt = LoadingPoint() line = infile.readline() self.parse1Point(line , pnt) self.graph.loadingPoints.append(pnt) print ' loading points : %d done'%self.loadingPointsNum for i in range(self.measuredPointsNum): pnt = MeasuredPoint() line = infile.readline() self.parse1Point(line , pnt) self.graph.measuredPoints.append(pnt) print ' measured points : %d done'%self.measuredPointsNum print 'DF points done.' return True class ParseAndLoadDCInputData(BaseParseData): def __init__(self): self.reset() self.__fileReader = FileReader() self.database = None def GetResources(self): return { 'Pixmap' : 'LoadDCInput', 'MenuText': 'LoadDCInputData', 'ToolTip': "Load DC Input Data"} def Activated(self): self.parse() import Base Base.changeStep4Stage('SpecialStep') import Base database = Base.getDatabaser4CurrentStage() database.clearRedoUndoList() def finish(self): pass def reset(self): self.jointLinesNum = 0 self.materialLinesNum = 0 self.additionalLinesNum = 0 self.boltElementsNum = 0 self.fixedPointsNum = 0 self.loadingPointsNum = 0 self.measuredPointsNum = 0 self.holePointsNum = 0 def __ParsePandect(self): # from DDADatabase import dc_inputDatabase self.__fileReader.getNextLine() # minimum edge length e0 nums = self.__fileReader.getNextLine().split() self.jointLinesNum = self.parseIntNum(nums[0]) # temperary code, I will try to revise this if I fully understand the data.dc self.database.boundaryLinesNum = self.parseIntNum(nums[1]) nums = self.__fileReader.getNextLine() self.materialLinesNum = self.parseIntNum(nums) nums = self.__fileReader.getNextLine() self.boltElementsNum = self.parseIntNum(nums) nums = self.__fileReader.getNextLine() self.fixedPointsNum = self.parseIntNum(nums) nums = self.__fileReader.getNextLine() self.loadingPointsNum = self.parseIntNum(nums) nums = self.__fileReader.getNextLine() self.measuredPointsNum = self.parseIntNum(nums) nums = self.__fileReader.getNextLine() self.holePointsNum = self.parseIntNum(nums) def __parseLines(self): # from DDADatabase import dc_inputDatabase # joint lines self.database.jointLines = [] for i in range(self.jointLinesNum): nums = self.__fileReader.getNextLine().split() jointMaterial = int(self.parseFloatNum(nums[4])) p1 = ( self.parseFloatNum(nums[0]) , self.parseFloatNum(nums[1]) , 0 ) p2 = ( self.parseFloatNum(nums[2]) , self.parseFloatNum(nums[3]) , 0 ) self.database.jointLines.append(DDALine(p1 , p2 , jointMaterial)) # material lines self.database.materialLines = [] for i in range(self.materialLinesNum): self.__fileReader.getNextLine() # bolt elements tmpNums = range(4) self.database.boltElements = [] for i in range(self.boltElementsNum): nums = self.__fileReader.getNextLine().split() for j in range(4): tmpNums[j] = self.parseFloatNum(nums[j], 'bolt element coordinate number') if tmpNums[j] == None : return False e0 = self.parseFloatNum(nums[4], 'bolt element e0') t0 = self.parseFloatNum(nums[5], 'bolt element t0') f0 = self.parseFloatNum(nums[6], 'bolt element f0') if e0==None or t0==None or f0==None : return False print 'block material %d :(%f , %f , %f , %f , %f , %f , %f)'%(i , tmpNums[0] , tmpNums[1] ,tmpNums[2] , tmpNums[3] , e0 , t0 , f0) self.database.boltElements.append(BoltElement(tmpNums[0] , tmpNums[1] ,tmpNums[2] , tmpNums[3] , e0 , t0 , f0)) def __parsePoints(self): # from DDADatabase import dc_inputDatabase import Base # fixed points windowInfo = [0 , 0 , 0 , 0] nums = self.__fileReader.getNextLine().split() p = (self.parseFloatNum(nums[0]) , self.parseFloatNum(nums[1]) , 0) self.database.fixedPoints.append( FixedPoint(p[0] , p[1])) windowInfo[0] = windowInfo[1] = p[0] windowInfo[2] = windowInfo[3] = p[1] for i in range(self.fixedPointsNum-1): nums = self.__fileReader.getNextLine().split() p = (self.parseFloatNum(nums[0]) , self.parseFloatNum(nums[1]) , 0) if p[0]<windowInfo[0]:windowInfo[0] = p[0] if p[0]>windowInfo[1]:windowInfo[1] = p[0] if p[1]<windowInfo[2]:windowInfo[2] = p[1] if p[1]>windowInfo[3]:windowInfo[3] = p[1] self.database.fixedPoints.append( FixedPoint(p[0] , p[1])) Base.__radius4Points__ = (windowInfo[1] - windowInfo[0]) * 0.01 Base.__windowInfo__ = windowInfo # loading points for i in range(self.loadingPointsNum): nums = self.__fileReader.getNextLine().split() self.database.loadingPoints.append( \ LoadingPoint(self.parseFloatNum(nums[0]) , self.parseFloatNum(nums[1]))) # measured points for i in range(self.measuredPointsNum): nums = self.__fileReader.getNextLine().split() self.database.measuredPoints.append( \ MeasuredPoint(self.parseFloatNum(nums[0]) , self.parseFloatNum(nums[1]))) # hole points for i in range(self.holePointsNum): nums = self.__fileReader.getNextLine().split() self.database.holePoints.append( \ HolePoint(self.parseFloatNum(nums[0]) , self.parseFloatNum(nums[1]))) def parse(self): import Base filename = Base.__currentProjectPath__ + '/data.dc' print 'try to read DC data from file : ' , filename # filename = Base.__currentProjectPath__ + '/tmpData.dc' self.__fileReader.setFile(filename) import DDADatabase self.database = DDADatabase.DCInputDatabase() self.reset() self.__ParsePandect() self.__parseLines() self.__parsePoints() self.__fileReader.closeFile() DDADatabase.dc_inputDatabase = self.database self.database = None class DDALoadData(): def __init__(self): self.current_path = Base.__currentProjectPath__ def changeStage( self ): if Base.__currentStage__ == 'DL': # DL stage print 'switch to DL stage' self.parseData = ParseAndLoadDLData() elif Base.__currentStage__ == 'DC': # DC stage pass def GetResources(self): return { 'MenuText': 'Load', 'ToolTip': "Load DL data."} def __storeFileName(self , filename): ''' store the name of file which is being loaded ''' file = open(self.current_path+'\\Ff.c' , 'wb') file.write(filename.strip().split('/')[-1]) file.close() def __confirmLoadFile(self): ''' if a new data file loaded , old shapes will be cleared , so before this ,we have to make sure if user want to do this. ''' box = QtGui.QMessageBox() box.setText('New data will be imported , and old shapes will be wipped.') box.setInformativeText('Do you want to do this?') box.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) box.setDefaultButton(QtGui.QMessageBox.Ok) ret = box.exec_() if ret == QtGui.QMessageBox.Ok: return True return False def Activated(self): self.changeStage() filename = str( QtGui.QFileDialog.getOpenFileName(None , 'please select input file' , self.current_path) ) if not self.parseData.parse(filename): self.parseData.reset() print 'input data status : invalid' return False print 'input data status : ok' if self.__confirmLoadFile(): self.__storeFileName(filename) self.parseData.save2Database() FreeCADGui.DDADisplayCmd.preview() def finish(self): pass FreeCADGui.addCommand('DDA_LoadDLInputData', ParseAndLoadDLData()) FreeCADGui.addCommand('DDA_Load', DDALoadData()) FreeCADGui.addCommand('DDA_LoadDCInputData', ParseAndLoadDCInputData()) FreeCADGui.addCommand('DDA_LoadDFInputGraphData', ParseDFInputGraphData())
lgpl-2.1
[ 3, 2803, 29, 4908, 75, 199, 199, 3, 17623, 199, 15002, 17997, 627, 199, 15002, 257, 1898, 334, 67, 9, 8937, 12, 7129, 2476, 4519, 627, 257, 199, 15002, 257, 1323, 4674, 393, 951, 2799, 7420, 665, 416, 1132, 71, 2335, 32, 11931, 14, 957, 30, 15530, 627, 257, 199, 15002, 17997, 627, 199, 15002, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 15002, 257, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 334, 44, 12006, 9, 259, 627, 199, 15002, 257, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 258, 627, 199, 15002, 257, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 7861, 627, 199, 15002, 257, 367, 10093, 1937, 314, 5059, 6013, 1318, 570, 14, 2476, 627, 199, 15002, 17997, 627, 199, 15002, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 755, 627, 199, 15002, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 263, 627, 199, 15002, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 260, 627, 199, 15002, 257, 1664, 11243, 1696, 1684, 844, 367, 1655, 2436, 14, 8295, 627, 199, 15002, 17997, 627, 199, 15002, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 11243, 1696, 1684, 258, 627, 199, 15002, 257, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 257, 627, 199, 15002, 257, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 627, 199, 15002, 257, 8217, 6208, 257, 627, 199, 15002, 17997, 627, 199, 3, 17623, 199, 199, 646, 20914, 4324, 199, 504, 14084, 20, 492, 10565, 2360, 5928, 199, 646, 3523, 199, 504, 3523, 492, 2498, 547, 13695, 199, 646, 29662, 1554, 1963, 199, 199, 318, 1104, 1173, 7965, 8, 515, 304, 272, 492, 747, 272, 340, 440, 747, 14, 515, 14, 6292, 8, 515, 304, 267, 2498, 547, 13695, 480, 25212, 2, 2360, 298, 1173, 18321, 83, 4451, 3181, 1133, 2187, 6808, 515, 9, 267, 372, 756, 272, 372, 715, 199, 199, 533, 3814, 5929, 837, 272, 1449, 272, 1586, 1584, 2360, 642, 1021, 911, 19413, 314, 4596, 2385, 272, 1449, 272, 347, 636, 826, 721, 277, 304, 267, 291, 855, 15450, 275, 488, 267, 291, 855, 493, 275, 488, 5493, 347, 663, 1173, 8, 277, 12, 18305, 304, 267, 291, 855, 15450, 275, 18305, 267, 862, 26, 288, 291, 855, 493, 275, 1551, 8, 277, 855, 15450, 2360, 283, 4848, 358, 267, 871, 26, 288, 2498, 547, 13695, 360, 493, 1551, 1125, 7, 2360, 18305, 435, 283, 1551, 3405, 358, 288, 372, 756, 267, 372, 715, 2286, 347, 664, 5765, 3049, 8, 277, 304, 267, 1004, 275, 291, 855, 493, 14, 6407, 342, 267, 1830, 822, 8, 604, 9, 1111, 16, 26, 288, 1004, 275, 1004, 14, 1913, 342, 288, 340, 822, 8, 604, 12694, 16, 26, 327, 4596, 1004, 543, 1557, 78, 7, 355, 1004, 275, 291, 855, 493, 14, 6407, 342, 288, 587, 26, 355, 2059, 257, 327, 642, 1004, 365, 440, 4596, 267, 340, 822, 8, 604, 12694, 16, 26, 221, 327, 570, 2575, 11187, 288, 492, 3523, 288, 3523, 14, 2384, 547, 13695, 360, 493, 1125, 7, 2360, 283, 324, 1078, 666, 358, 288, 746, 267, 372, 1004, 2286, 347, 4002, 1173, 8, 277, 304, 267, 291, 855, 493, 14, 1600, 342, 1467, 199, 199, 533, 8651, 26, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1457, 2681, 275, 378, 327, 314, 1478, 402, 642, 1853, 267, 291, 14, 928, 1944, 275, 378, 4960, 291, 14, 500, 1944, 275, 378, 267, 291, 14, 12637, 275, 942, 267, 291, 14, 3214, 275, 942, 267, 291, 14, 29530, 56, 275, 378, 267, 291, 14, 29530, 57, 275, 378, 267, 291, 14, 29530, 8195, 275, 378, 267, 291, 14, 9820, 1944, 275, 378, 327, 1202, 315, 12326, 754, 2728, 327, 2338, 4212, 5002, 2636, 274, 4501, 787, 641, 642, 1853, 267, 291, 14, 16668, 10225, 2353, 275, 378, 5493, 347, 664, 10225, 8, 277, 304, 267, 372, 3842, 84, 59, 17, 467, 84, 59, 18, 467, 16, 9, 367, 307, 315, 291, 14, 12637, 61, 2286, 347, 8917, 8, 277, 304, 267, 340, 291, 14, 16668, 10225, 2353, 30, 16, 26, 288, 372, 756, 267, 916, 291, 14, 16668, 10225, 2353, 389, 16, 26, 288, 372, 715, 267, 587, 520, 288, 746, 2186, 360, 324, 1078, 574, 450, 70, 5956, 291, 14, 16668, 10225, 2353, 9, 268, 199, 533, 577, 10741, 1132, 26, 272, 347, 636, 826, 721, 277, 2360, 299, 17, 2360, 299, 18, 2360, 6285, 1944, 304, 267, 291, 14, 928, 3428, 275, 299, 17, 267, 291, 14, 500, 3428, 275, 299, 18, 267, 291, 14, 9820, 1944, 275, 6285, 1944, 267, 291, 14, 6604, 275, 715, 268, 199, 533, 699, 28934, 2162, 8, 5745, 748, 1132, 304, 272, 347, 636, 826, 721, 277, 2360, 299, 17, 2360, 299, 18, 2360, 325, 2360, 307, 2360, 289, 304, 267, 577, 10741, 1132, 855, 826, 721, 277, 12, 299, 17, 12, 299, 18, 12, 378, 9, 267, 291, 14, 69, 275, 325, 267, 291, 14, 84, 275, 307, 267, 291, 14, 70, 275, 289, 268, 199, 533, 29662, 1282, 16242, 3049, 26, 272, 347, 636, 826, 721, 277, 2360, 21286, 2360, 6285, 1944, 304, 267, 291, 14, 8382, 275, 21286, 267, 291, 14, 9820, 1944, 275, 6285, 1944, 267, 291, 14, 6604, 275, 715, 268, 199, 533, 29662, 1282, 79, 442, 26, 272, 347, 636, 826, 721, 277, 2360, 671, 29, 16, 2360, 612, 29, 16, 304, 267, 291, 14, 88, 275, 671, 267, 291, 14, 89, 275, 612, 267, 291, 14, 56, 7625, 275, 378, 267, 291, 14, 57, 7625, 275, 378, 267, 291, 14, 1457, 1944, 275, 378, 267, 291, 14, 6604, 275, 715, 268, 199, 533, 18659, 3428, 8, 5745, 1282, 79, 442, 304, 272, 986, 199, 199, 533, 3835, 5384, 3428, 8, 5745, 1282, 79, 442, 304, 272, 986, 199, 199, 533, 3194, 305, 3297, 3428, 8, 5745, 1282, 79, 442, 304, 272, 347 ]
[ 2803, 29, 4908, 75, 199, 199, 3, 17623, 199, 15002, 17997, 627, 199, 15002, 257, 1898, 334, 67, 9, 8937, 12, 7129, 2476, 4519, 627, 257, 199, 15002, 257, 1323, 4674, 393, 951, 2799, 7420, 665, 416, 1132, 71, 2335, 32, 11931, 14, 957, 30, 15530, 627, 257, 199, 15002, 17997, 627, 199, 15002, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 15002, 257, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 334, 44, 12006, 9, 259, 627, 199, 15002, 257, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 258, 627, 199, 15002, 257, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 7861, 627, 199, 15002, 257, 367, 10093, 1937, 314, 5059, 6013, 1318, 570, 14, 2476, 627, 199, 15002, 17997, 627, 199, 15002, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 755, 627, 199, 15002, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 263, 627, 199, 15002, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 260, 627, 199, 15002, 257, 1664, 11243, 1696, 1684, 844, 367, 1655, 2436, 14, 8295, 627, 199, 15002, 17997, 627, 199, 15002, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 11243, 1696, 1684, 258, 627, 199, 15002, 257, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 257, 627, 199, 15002, 257, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 627, 199, 15002, 257, 8217, 6208, 257, 627, 199, 15002, 17997, 627, 199, 3, 17623, 199, 199, 646, 20914, 4324, 199, 504, 14084, 20, 492, 10565, 2360, 5928, 199, 646, 3523, 199, 504, 3523, 492, 2498, 547, 13695, 199, 646, 29662, 1554, 1963, 199, 199, 318, 1104, 1173, 7965, 8, 515, 304, 272, 492, 747, 272, 340, 440, 747, 14, 515, 14, 6292, 8, 515, 304, 267, 2498, 547, 13695, 480, 25212, 2, 2360, 298, 1173, 18321, 83, 4451, 3181, 1133, 2187, 6808, 515, 9, 267, 372, 756, 272, 372, 715, 199, 199, 533, 3814, 5929, 837, 272, 1449, 272, 1586, 1584, 2360, 642, 1021, 911, 19413, 314, 4596, 2385, 272, 1449, 272, 347, 636, 826, 721, 277, 304, 267, 291, 855, 15450, 275, 488, 267, 291, 855, 493, 275, 488, 5493, 347, 663, 1173, 8, 277, 12, 18305, 304, 267, 291, 855, 15450, 275, 18305, 267, 862, 26, 288, 291, 855, 493, 275, 1551, 8, 277, 855, 15450, 2360, 283, 4848, 358, 267, 871, 26, 288, 2498, 547, 13695, 360, 493, 1551, 1125, 7, 2360, 18305, 435, 283, 1551, 3405, 358, 288, 372, 756, 267, 372, 715, 2286, 347, 664, 5765, 3049, 8, 277, 304, 267, 1004, 275, 291, 855, 493, 14, 6407, 342, 267, 1830, 822, 8, 604, 9, 1111, 16, 26, 288, 1004, 275, 1004, 14, 1913, 342, 288, 340, 822, 8, 604, 12694, 16, 26, 327, 4596, 1004, 543, 1557, 78, 7, 355, 1004, 275, 291, 855, 493, 14, 6407, 342, 288, 587, 26, 355, 2059, 257, 327, 642, 1004, 365, 440, 4596, 267, 340, 822, 8, 604, 12694, 16, 26, 221, 327, 570, 2575, 11187, 288, 492, 3523, 288, 3523, 14, 2384, 547, 13695, 360, 493, 1125, 7, 2360, 283, 324, 1078, 666, 358, 288, 746, 267, 372, 1004, 2286, 347, 4002, 1173, 8, 277, 304, 267, 291, 855, 493, 14, 1600, 342, 1467, 199, 199, 533, 8651, 26, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1457, 2681, 275, 378, 327, 314, 1478, 402, 642, 1853, 267, 291, 14, 928, 1944, 275, 378, 4960, 291, 14, 500, 1944, 275, 378, 267, 291, 14, 12637, 275, 942, 267, 291, 14, 3214, 275, 942, 267, 291, 14, 29530, 56, 275, 378, 267, 291, 14, 29530, 57, 275, 378, 267, 291, 14, 29530, 8195, 275, 378, 267, 291, 14, 9820, 1944, 275, 378, 327, 1202, 315, 12326, 754, 2728, 327, 2338, 4212, 5002, 2636, 274, 4501, 787, 641, 642, 1853, 267, 291, 14, 16668, 10225, 2353, 275, 378, 5493, 347, 664, 10225, 8, 277, 304, 267, 372, 3842, 84, 59, 17, 467, 84, 59, 18, 467, 16, 9, 367, 307, 315, 291, 14, 12637, 61, 2286, 347, 8917, 8, 277, 304, 267, 340, 291, 14, 16668, 10225, 2353, 30, 16, 26, 288, 372, 756, 267, 916, 291, 14, 16668, 10225, 2353, 389, 16, 26, 288, 372, 715, 267, 587, 520, 288, 746, 2186, 360, 324, 1078, 574, 450, 70, 5956, 291, 14, 16668, 10225, 2353, 9, 268, 199, 533, 577, 10741, 1132, 26, 272, 347, 636, 826, 721, 277, 2360, 299, 17, 2360, 299, 18, 2360, 6285, 1944, 304, 267, 291, 14, 928, 3428, 275, 299, 17, 267, 291, 14, 500, 3428, 275, 299, 18, 267, 291, 14, 9820, 1944, 275, 6285, 1944, 267, 291, 14, 6604, 275, 715, 268, 199, 533, 699, 28934, 2162, 8, 5745, 748, 1132, 304, 272, 347, 636, 826, 721, 277, 2360, 299, 17, 2360, 299, 18, 2360, 325, 2360, 307, 2360, 289, 304, 267, 577, 10741, 1132, 855, 826, 721, 277, 12, 299, 17, 12, 299, 18, 12, 378, 9, 267, 291, 14, 69, 275, 325, 267, 291, 14, 84, 275, 307, 267, 291, 14, 70, 275, 289, 268, 199, 533, 29662, 1282, 16242, 3049, 26, 272, 347, 636, 826, 721, 277, 2360, 21286, 2360, 6285, 1944, 304, 267, 291, 14, 8382, 275, 21286, 267, 291, 14, 9820, 1944, 275, 6285, 1944, 267, 291, 14, 6604, 275, 715, 268, 199, 533, 29662, 1282, 79, 442, 26, 272, 347, 636, 826, 721, 277, 2360, 671, 29, 16, 2360, 612, 29, 16, 304, 267, 291, 14, 88, 275, 671, 267, 291, 14, 89, 275, 612, 267, 291, 14, 56, 7625, 275, 378, 267, 291, 14, 57, 7625, 275, 378, 267, 291, 14, 1457, 1944, 275, 378, 267, 291, 14, 6604, 275, 715, 268, 199, 533, 18659, 3428, 8, 5745, 1282, 79, 442, 304, 272, 986, 199, 199, 533, 3835, 5384, 3428, 8, 5745, 1282, 79, 442, 304, 272, 986, 199, 199, 533, 3194, 305, 3297, 3428, 8, 5745, 1282, 79, 442, 304, 272, 347, 0 ]
[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]
Tatsh-ansible/ansible
test/units/parsing/vault/test_vault_editor.py
5
20845
# (c) 2014, James Tanner <tanner.jc@gmail.com> # (c) 2014, James Cammarata, <jcammarata@ansible.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import os import tempfile import pytest from ansible.compat.tests import unittest from ansible.compat.tests.mock import patch from ansible import errors from ansible.parsing import vault from ansible.parsing.vault import VaultLib, VaultEditor, match_encrypt_secret from ansible.module_utils._text import to_bytes, to_text from units.mock.vault_helper import TextVaultSecret v10_data = """$ANSIBLE_VAULT;1.0;AES 53616c7465645f5fd0026926a2d415a28a2622116273fbc90e377225c12a347e1daf4456d36a77f9 9ad98d59f61d06a4b66718d855f16fb7bdfe54d1ec8aeaa4d06c2dc1fa630ae1846a029877f0eeb1 83c62ffb04c2512995e815de4b4d29ed""" v11_data = """$ANSIBLE_VAULT;1.1;AES256 62303130653266653331306264616235333735323636616539316433666463323964623162386137 3961616263373033353631316333623566303532663065310a393036623466376263393961326530 64336561613965383835646464623865663966323464653236343638373165343863623638316664 3631633031323837340a396530313963373030343933616133393566366137363761373930663833 3739""" @pytest.mark.skipif(not vault.HAS_CRYPTOGRAPHY, reason="Skipping cryptography tests because cryptography is not installed") class TestVaultEditor(unittest.TestCase): def setUp(self): self._test_dir = None self.vault_password = "test-vault-password" vault_secret = TextVaultSecret(self.vault_password) self.vault_secrets = [('vault_secret', vault_secret), ('default', vault_secret)] @property def vault_secret(self): return match_encrypt_secret(self.vault_secrets)[1] def tearDown(self): if self._test_dir: pass # shutil.rmtree(self._test_dir) self._test_dir = None def _secrets(self, password): vault_secret = TextVaultSecret(password) vault_secrets = [('default', vault_secret)] return vault_secrets def test_methods_exist(self): v = vault.VaultEditor(None) slots = ['create_file', 'decrypt_file', 'edit_file', 'encrypt_file', 'rekey_file', 'read_data', 'write_data'] for slot in slots: assert hasattr(v, slot), "VaultLib is missing the %s method" % slot def _create_test_dir(self): suffix = '_ansible_unit_test_%s_' % (self.__class__.__name__) return tempfile.mkdtemp(suffix=suffix) def _create_file(self, test_dir, name, content=None, symlink=False): file_path = os.path.join(test_dir, name) opened_file = open(file_path, 'wb') if content: opened_file.write(content) opened_file.close() return file_path def _vault_editor(self, vault_secrets=None): if vault_secrets is None: vault_secrets = self._secrets(self.vault_password) return VaultEditor(VaultLib(vault_secrets)) @patch('ansible.parsing.vault.call') def test_edit_file_helper_empty_target(self, mock_sp_call): self._test_dir = self._create_test_dir() src_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_contents) mock_sp_call.side_effect = self._faux_command ve = self._vault_editor() b_ciphertext = ve._edit_file_helper(src_file_path, self.vault_secret) self.assertNotEqual(src_contents, b_ciphertext) @patch('ansible.parsing.vault.call') def test_edit_file_helper_call_exception(self, mock_sp_call): self._test_dir = self._create_test_dir() src_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_contents) error_txt = 'calling editor raised an exception' mock_sp_call.side_effect = errors.AnsibleError(error_txt) ve = self._vault_editor() self.assertRaisesRegexp(errors.AnsibleError, error_txt, ve._edit_file_helper, src_file_path, self.vault_secret) @patch('ansible.parsing.vault.call') def test_edit_file_helper_symlink_target(self, mock_sp_call): self._test_dir = self._create_test_dir() src_file_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_file_contents) src_file_link_path = os.path.join(self._test_dir, 'a_link_to_dest_file') os.symlink(src_file_path, src_file_link_path) mock_sp_call.side_effect = self._faux_command ve = self._vault_editor() b_ciphertext = ve._edit_file_helper(src_file_link_path, self.vault_secret) self.assertNotEqual(src_file_contents, b_ciphertext, 'b_ciphertext should be encrypted and not equal to src_contents') def _faux_editor(self, editor_args, new_src_contents=None): if editor_args[0] == 'shred': return tmp_path = editor_args[-1] # simulate the tmp file being editted tmp_file = open(tmp_path, 'wb') if new_src_contents: tmp_file.write(new_src_contents) tmp_file.close() def _faux_command(self, tmp_path): pass @patch('ansible.parsing.vault.call') def test_edit_file_helper_no_change(self, mock_sp_call): self._test_dir = self._create_test_dir() src_file_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_file_contents) # editor invocation doesn't change anything def faux_editor(editor_args): self._faux_editor(editor_args, src_file_contents) mock_sp_call.side_effect = faux_editor ve = self._vault_editor() ve._edit_file_helper(src_file_path, self.vault_secret, existing_data=src_file_contents) new_target_file = open(src_file_path, 'rb') new_target_file_contents = new_target_file.read() self.assertEqual(src_file_contents, new_target_file_contents) def _assert_file_is_encrypted(self, vault_editor, src_file_path, src_contents): new_src_file = open(src_file_path, 'rb') new_src_file_contents = new_src_file.read() # TODO: assert that it is encrypted self.assertTrue(vault.is_encrypted(new_src_file_contents)) src_file_plaintext = vault_editor.vault.decrypt(new_src_file_contents) # the plaintext should not be encrypted self.assertFalse(vault.is_encrypted(src_file_plaintext)) # and the new plaintext should match the original self.assertEqual(src_file_plaintext, src_contents) def _assert_file_is_link(self, src_file_link_path, src_file_path): self.assertTrue(os.path.islink(src_file_link_path), 'The dest path (%s) should be a symlink to (%s) but is not' % (src_file_link_path, src_file_path)) def test_rekey_file(self): self._test_dir = self._create_test_dir() src_file_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_file_contents) ve = self._vault_editor() ve.encrypt_file(src_file_path, self.vault_secret) # FIXME: update to just set self._secrets or just a new vault secret id new_password = 'password2:electricbugaloo' new_vault_secret = TextVaultSecret(new_password) new_vault_secrets = [('default', new_vault_secret)] ve.rekey_file(src_file_path, vault.match_encrypt_secret(new_vault_secrets)[1]) # FIXME: can just update self._secrets here new_ve = vault.VaultEditor(VaultLib(new_vault_secrets)) self._assert_file_is_encrypted(new_ve, src_file_path, src_file_contents) def test_rekey_file_no_new_password(self): self._test_dir = self._create_test_dir() src_file_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_file_contents) ve = self._vault_editor() ve.encrypt_file(src_file_path, self.vault_secret) self.assertRaisesRegexp(errors.AnsibleError, 'The value for the new_password to rekey', ve.rekey_file, src_file_path, None) def test_rekey_file_not_encrypted(self): self._test_dir = self._create_test_dir() src_file_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_file_contents) ve = self._vault_editor() new_password = 'password2:electricbugaloo' self.assertRaisesRegexp(errors.AnsibleError, 'input is not vault encrypted data', ve.rekey_file, src_file_path, new_password) def test_plaintext(self): self._test_dir = self._create_test_dir() src_file_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_file_contents) ve = self._vault_editor() ve.encrypt_file(src_file_path, self.vault_secret) res = ve.plaintext(src_file_path) self.assertEqual(src_file_contents, res) def test_plaintext_not_encrypted(self): self._test_dir = self._create_test_dir() src_file_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_file_contents) ve = self._vault_editor() self.assertRaisesRegexp(errors.AnsibleError, 'input is not vault encrypted data', ve.plaintext, src_file_path) def test_encrypt_file(self): self._test_dir = self._create_test_dir() src_file_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_file_contents) ve = self._vault_editor() ve.encrypt_file(src_file_path, self.vault_secret) self._assert_file_is_encrypted(ve, src_file_path, src_file_contents) def test_encrypt_file_symlink(self): self._test_dir = self._create_test_dir() src_file_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_file_contents) src_file_link_path = os.path.join(self._test_dir, 'a_link_to_dest_file') os.symlink(src_file_path, src_file_link_path) ve = self._vault_editor() ve.encrypt_file(src_file_link_path, self.vault_secret) self._assert_file_is_encrypted(ve, src_file_path, src_file_contents) self._assert_file_is_encrypted(ve, src_file_link_path, src_file_contents) self._assert_file_is_link(src_file_link_path, src_file_path) @patch('ansible.parsing.vault.call') def test_edit_file(self, mock_sp_call): self._test_dir = self._create_test_dir() src_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_contents) new_src_contents = to_bytes("The info is different now.") def faux_editor(editor_args): self._faux_editor(editor_args, new_src_contents) mock_sp_call.side_effect = faux_editor ve = self._vault_editor() ve.encrypt_file(src_file_path, self.vault_secret) ve.edit_file(src_file_path) new_src_file = open(src_file_path, 'rb') new_src_file_contents = new_src_file.read() src_file_plaintext = ve.vault.decrypt(new_src_file_contents) self.assertEqual(src_file_plaintext, new_src_contents) new_stat = os.stat(src_file_path) @patch('ansible.parsing.vault.call') def test_edit_file_symlink(self, mock_sp_call): self._test_dir = self._create_test_dir() src_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_contents) new_src_contents = to_bytes("The info is different now.") def faux_editor(editor_args): self._faux_editor(editor_args, new_src_contents) mock_sp_call.side_effect = faux_editor ve = self._vault_editor() ve.encrypt_file(src_file_path, self.vault_secret) src_file_link_path = os.path.join(self._test_dir, 'a_link_to_dest_file') os.symlink(src_file_path, src_file_link_path) ve.edit_file(src_file_link_path) new_src_file = open(src_file_path, 'rb') new_src_file_contents = new_src_file.read() src_file_plaintext = ve.vault.decrypt(new_src_file_contents) self._assert_file_is_link(src_file_link_path, src_file_path) self.assertEqual(src_file_plaintext, new_src_contents) # self.assertEqual(src_file_plaintext, new_src_contents, # 'The decrypted plaintext of the editted file is not the expected contents.') @patch('ansible.parsing.vault.call') def test_edit_file_not_encrypted(self, mock_sp_call): self._test_dir = self._create_test_dir() src_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_contents) new_src_contents = to_bytes("The info is different now.") def faux_editor(editor_args): self._faux_editor(editor_args, new_src_contents) mock_sp_call.side_effect = faux_editor ve = self._vault_editor() self.assertRaisesRegexp(errors.AnsibleError, 'input is not vault encrypted data', ve.edit_file, src_file_path) def test_create_file_exists(self): self._test_dir = self._create_test_dir() src_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_contents) ve = self._vault_editor() self.assertRaisesRegexp(errors.AnsibleError, 'please use .edit. instead', ve.create_file, src_file_path, self.vault_secret) def test_decrypt_file_exception(self): self._test_dir = self._create_test_dir() src_contents = to_bytes("some info in a file\nyup.") src_file_path = self._create_file(self._test_dir, 'src_file', content=src_contents) ve = self._vault_editor() self.assertRaisesRegexp(errors.AnsibleError, 'input is not vault encrypted data', ve.decrypt_file, src_file_path) @patch.object(vault.VaultEditor, '_editor_shell_command') def test_create_file(self, mock_editor_shell_command): def sc_side_effect(filename): return ['touch', filename] mock_editor_shell_command.side_effect = sc_side_effect tmp_file = tempfile.NamedTemporaryFile() os.unlink(tmp_file.name) _secrets = self._secrets('ansible') ve = self._vault_editor(_secrets) ve.create_file(tmp_file.name, vault.match_encrypt_secret(_secrets)[1]) self.assertTrue(os.path.exists(tmp_file.name)) def test_decrypt_1_0(self): # Skip testing decrypting 1.0 files if we don't have access to AES, KDF or Counter. v10_file = tempfile.NamedTemporaryFile(delete=False) with v10_file as f: f.write(to_bytes(v10_data)) ve = self._vault_editor(self._secrets("ansible")) # make sure the password functions for the cipher error_hit = False try: ve.decrypt_file(v10_file.name) except errors.AnsibleError: error_hit = True raise # verify decrypted content f = open(v10_file.name, "rb") fdata = to_text(f.read()) f.close() os.unlink(v10_file.name) assert error_hit is False, "error decrypting 1.0 file" self.assertEqual(fdata.strip(), "foo") assert fdata.strip() == "foo", "incorrect decryption of 1.0 file: %s" % fdata.strip() def test_decrypt_1_1(self): v11_file = tempfile.NamedTemporaryFile(delete=False) with v11_file as f: f.write(to_bytes(v11_data)) ve = self._vault_editor(self._secrets("ansible")) # make sure the password functions for the cipher error_hit = False try: ve.decrypt_file(v11_file.name) except errors.AnsibleError: raise error_hit = True # verify decrypted content f = open(v11_file.name, "rb") fdata = to_text(f.read()) f.close() os.unlink(v11_file.name) assert error_hit is False, "error decrypting 1.1 file" assert fdata.strip() == "foo", "incorrect decryption of 1.1 file: %s" % fdata.strip() def test_rekey_migration(self): v10_file = tempfile.NamedTemporaryFile(delete=False) with v10_file as f: f.write(to_bytes(v10_data)) ve = self._vault_editor(self._secrets("ansible")) # make sure the password functions for the cipher error_hit = False new_secrets = self._secrets("ansible2") try: ve.rekey_file(v10_file.name, vault.match_encrypt_secret(new_secrets)[1]) except errors.AnsibleError: raise error_hit = True # verify decrypted content f = open(v10_file.name, "rb") fdata = f.read() f.close() assert error_hit is False, "error rekeying 1.0 file to 1.1" # ensure filedata can be decrypted, is 1.1 and is AES256 vl = VaultLib(new_secrets) dec_data = None error_hit = False try: dec_data = vl.decrypt(fdata) except errors.AnsibleError: raise error_hit = True os.unlink(v10_file.name) self.assertIn(b'AES256', fdata, 'AES256 was not found in vault file %s' % to_text(fdata)) assert error_hit is False, "error decrypting migrated 1.0 file" assert dec_data.strip() == b"foo", "incorrect decryption of rekeyed/migrated file: %s" % dec_data def test_real_path_dash(self): filename = '-' ve = self._vault_editor() res = ve._real_path(filename) self.assertEqual(res, '-') def test_real_path_dev_null(self): filename = '/dev/null' ve = self._vault_editor() res = ve._real_path(filename) self.assertEqual(res, '/dev/null') def test_real_path_symlink(self): self._test_dir = self._create_test_dir() file_path = self._create_file(self._test_dir, 'test_file', content=b'this is a test file') file_link_path = os.path.join(self._test_dir, 'a_link_to_test_file') os.symlink(file_path, file_link_path) ve = self._vault_editor() res = ve._real_path(file_link_path) self.assertEqual(res, file_path) @pytest.mark.skipif(not vault.HAS_PYCRYPTO, reason="Skipping pycrypto tests because pycrypto is not installed") class TestVaultEditorPyCrypto(unittest.TestCase): def setUp(self): self.has_cryptography = vault.HAS_CRYPTOGRAPHY vault.HAS_CRYPTOGRAPHY = False super(TestVaultEditorPyCrypto, self).setUp() def tearDown(self): vault.HAS_CRYPTOGRAPHY = self.has_cryptography super(TestVaultEditorPyCrypto, self).tearDown()
gpl-3.0
[ 3, 334, 67, 9, 6927, 12, 1603, 14015, 377, 5161, 665, 84, 5161, 14, 22760, 32, 6799, 14, 957, 30, 199, 3, 334, 67, 9, 6927, 12, 1603, 14015, 445, 455, 4584, 419, 12, 665, 74, 15176, 4584, 419, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 646, 5549, 199, 199, 646, 4613, 199, 199, 504, 3242, 14, 5819, 14, 2219, 492, 2882, 199, 504, 3242, 14, 5819, 14, 2219, 14, 1805, 492, 3371, 199, 199, 504, 3242, 492, 2552, 199, 504, 3242, 14, 11059, 492, 12738, 199, 504, 3242, 14, 11059, 14, 10077, 492, 812, 558, 4728, 12, 812, 558, 10423, 12, 1336, 63, 11929, 63, 4731, 199, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 12, 370, 63, 505, 199, 199, 504, 6204, 14, 1805, 14, 10077, 63, 3676, 492, 4516, 20229, 13790, 199, 199, 86, 709, 63, 576, 275, 408, 4, 8490, 63, 15162, 2233, 27, 17, 14, 16, 27, 14494, 199, 25839, 975, 67, 1342, 2182, 13067, 70, 21, 2592, 383, 12442, 1479, 65, 18, 68, 24415, 65, 1651, 65, 1479, 1081, 7524, 15000, 70, 3776, 2710, 69, 7332, 10932, 67, 713, 65, 12532, 69, 17, 31990, 1602, 1367, 68, 1344, 65, 1138, 70, 25, 199, 25, 350, 2905, 68, 1427, 70, 2976, 68, 1690, 65, 20, 66, 14916, 1085, 68, 12593, 70, 975, 4675, 23, 3691, 771, 1477, 68, 17, 825, 24, 3624, 2158, 20, 68, 1690, 67, 18, 3833, 17, 667, 22, 1216, 3624, 1085, 2466, 65, 996, 2905, 1138, 70, 16, 1024, 66, 17, 199, 2658, 67, 2789, 31311, 966, 67, 821, 713, 14732, 69, 28250, 271, 20, 66, 20, 68, 1398, 379, 624, 199, 199, 86, 845, 63, 576, 275, 408, 4, 8490, 63, 15162, 2233, 27, 17, 14, 17, 27, 14494, 3912, 199, 2789, 11810, 969, 21254, 708, 1272, 2182, 11769, 969, 1690, 9408, 26666, 8276, 1153, 1401, 1276, 708, 1344, 11065, 10355, 1355, 2192, 772, 1153, 1272, 772, 2766, 708, 1355, 11387, 1789, 975, 1789, 20629, 199, 13443, 975, 975, 1479, 11062, 1216, 1153, 1276, 15031, 969, 975, 1153, 1344, 8276, 1272, 1216, 1276, 708, 1272, 1216, 2182, 18035, 65, 1355, 1216, 11065, 5533, 1272, 11452, 1479, 11870, 1355, 23318, 2182, 1216, 199, 772, 12135, 1367, 975, 7491, 2182, 1703, 1703, 1276, 21336, 11387, 1789, 15102, 1272, 1355, 1272, 708, 1082, 772, 2182, 708, 1344, 1082, 1344, 1703, 14539, 10355, 1082, 8040, 1344, 10008, 15504, 10642, 772, 199, 15031, 975, 1153, 1644, 6557, 1703, 1401, 13424, 65, 1355, 2182, 11810, 969, 2534, 11062, 1216, 1216, 1082, 1355, 12135, 975, 969, 11870, 1276, 1272, 11065, 7498, 1344, 11452, 7498, 1355, 1216, 1272, 1703, 1153, 199, 1401, 1355, 624, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 1397, 12738, 14, 13533, 63, 2944, 7431, 2566, 3975, 1282, 16255, 12, 490, 4499, 628, 18297, 27617, 2295, 2952, 27617, 365, 440, 4903, 531, 199, 533, 1379, 20229, 10423, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 423, 396, 63, 694, 275, 488, 267, 291, 14, 10077, 63, 2060, 275, 298, 396, 13, 10077, 13, 2060, 2, 267, 12738, 63, 4731, 275, 4516, 20229, 13790, 8, 277, 14, 10077, 63, 2060, 9, 267, 291, 14, 10077, 63, 16153, 275, 4274, 10077, 63, 4731, 297, 12738, 63, 4731, 395, 2892, 661, 885, 297, 12738, 63, 4731, 1874, 339, 768, 1829, 272, 347, 12738, 63, 4731, 8, 277, 304, 267, 372, 1336, 63, 11929, 63, 4731, 8, 277, 14, 10077, 63, 16153, 2788, 17, 61, 339, 347, 6766, 8, 277, 304, 267, 340, 291, 423, 396, 63, 694, 26, 288, 986, 288, 327, 5145, 14, 9242, 8, 277, 423, 396, 63, 694, 9, 267, 291, 423, 396, 63, 694, 275, 488, 339, 347, 485, 16153, 8, 277, 12, 2505, 304, 267, 12738, 63, 4731, 275, 4516, 20229, 13790, 8, 2060, 9, 267, 12738, 63, 16153, 275, 4274, 885, 297, 12738, 63, 4731, 1874, 267, 372, 12738, 63, 16153, 339, 347, 511, 63, 2474, 63, 4494, 8, 277, 304, 267, 373, 275, 12738, 14, 20229, 10423, 8, 403, 9, 267, 14319, 275, 788, 981, 63, 493, 297, 326, 283, 15682, 63, 493, 297, 326, 283, 3773, 63, 493, 297, 326, 283, 11929, 63, 493, 297, 326, 283, 264, 498, 63, 493, 297, 326, 283, 739, 63, 576, 297, 326, 283, 952, 63, 576, 418, 267, 367, 9348, 315, 14319, 26, 288, 702, 2688, 8, 86, 12, 9348, 395, 298, 20229, 4728, 365, 4124, 314, 450, 83, 1083, 2, 450, 9348, 339, 347, 485, 981, 63, 396, 63, 694, 8, 277, 304, 267, 4739, 275, 2513, 4853, 63, 3248, 63, 396, 4970, 83, 8650, 450, 334, 277, 855, 533, 4914, 354, 3368, 267, 372, 5549, 14, 11983, 8, 4511, 29, 4511, 9, 339, 347, 485, 981, 63, 493, 8, 277, 12, 511, 63, 694, 12, 536, 12, 1564, 29, 403, 12, 15296, 29, 797, 304, 267, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 396, 63, 694, 12, 536, 9, 267, 12123, 63, 493, 275, 1551, 8 ]
[ 334, 67, 9, 6927, 12, 1603, 14015, 377, 5161, 665, 84, 5161, 14, 22760, 32, 6799, 14, 957, 30, 199, 3, 334, 67, 9, 6927, 12, 1603, 14015, 445, 455, 4584, 419, 12, 665, 74, 15176, 4584, 419, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 646, 5549, 199, 199, 646, 4613, 199, 199, 504, 3242, 14, 5819, 14, 2219, 492, 2882, 199, 504, 3242, 14, 5819, 14, 2219, 14, 1805, 492, 3371, 199, 199, 504, 3242, 492, 2552, 199, 504, 3242, 14, 11059, 492, 12738, 199, 504, 3242, 14, 11059, 14, 10077, 492, 812, 558, 4728, 12, 812, 558, 10423, 12, 1336, 63, 11929, 63, 4731, 199, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 12, 370, 63, 505, 199, 199, 504, 6204, 14, 1805, 14, 10077, 63, 3676, 492, 4516, 20229, 13790, 199, 199, 86, 709, 63, 576, 275, 408, 4, 8490, 63, 15162, 2233, 27, 17, 14, 16, 27, 14494, 199, 25839, 975, 67, 1342, 2182, 13067, 70, 21, 2592, 383, 12442, 1479, 65, 18, 68, 24415, 65, 1651, 65, 1479, 1081, 7524, 15000, 70, 3776, 2710, 69, 7332, 10932, 67, 713, 65, 12532, 69, 17, 31990, 1602, 1367, 68, 1344, 65, 1138, 70, 25, 199, 25, 350, 2905, 68, 1427, 70, 2976, 68, 1690, 65, 20, 66, 14916, 1085, 68, 12593, 70, 975, 4675, 23, 3691, 771, 1477, 68, 17, 825, 24, 3624, 2158, 20, 68, 1690, 67, 18, 3833, 17, 667, 22, 1216, 3624, 1085, 2466, 65, 996, 2905, 1138, 70, 16, 1024, 66, 17, 199, 2658, 67, 2789, 31311, 966, 67, 821, 713, 14732, 69, 28250, 271, 20, 66, 20, 68, 1398, 379, 624, 199, 199, 86, 845, 63, 576, 275, 408, 4, 8490, 63, 15162, 2233, 27, 17, 14, 17, 27, 14494, 3912, 199, 2789, 11810, 969, 21254, 708, 1272, 2182, 11769, 969, 1690, 9408, 26666, 8276, 1153, 1401, 1276, 708, 1344, 11065, 10355, 1355, 2192, 772, 1153, 1272, 772, 2766, 708, 1355, 11387, 1789, 975, 1789, 20629, 199, 13443, 975, 975, 1479, 11062, 1216, 1153, 1276, 15031, 969, 975, 1153, 1344, 8276, 1272, 1216, 1276, 708, 1272, 1216, 2182, 18035, 65, 1355, 1216, 11065, 5533, 1272, 11452, 1479, 11870, 1355, 23318, 2182, 1216, 199, 772, 12135, 1367, 975, 7491, 2182, 1703, 1703, 1276, 21336, 11387, 1789, 15102, 1272, 1355, 1272, 708, 1082, 772, 2182, 708, 1344, 1082, 1344, 1703, 14539, 10355, 1082, 8040, 1344, 10008, 15504, 10642, 772, 199, 15031, 975, 1153, 1644, 6557, 1703, 1401, 13424, 65, 1355, 2182, 11810, 969, 2534, 11062, 1216, 1216, 1082, 1355, 12135, 975, 969, 11870, 1276, 1272, 11065, 7498, 1344, 11452, 7498, 1355, 1216, 1272, 1703, 1153, 199, 1401, 1355, 624, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 1397, 12738, 14, 13533, 63, 2944, 7431, 2566, 3975, 1282, 16255, 12, 490, 4499, 628, 18297, 27617, 2295, 2952, 27617, 365, 440, 4903, 531, 199, 533, 1379, 20229, 10423, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 423, 396, 63, 694, 275, 488, 267, 291, 14, 10077, 63, 2060, 275, 298, 396, 13, 10077, 13, 2060, 2, 267, 12738, 63, 4731, 275, 4516, 20229, 13790, 8, 277, 14, 10077, 63, 2060, 9, 267, 291, 14, 10077, 63, 16153, 275, 4274, 10077, 63, 4731, 297, 12738, 63, 4731, 395, 2892, 661, 885, 297, 12738, 63, 4731, 1874, 339, 768, 1829, 272, 347, 12738, 63, 4731, 8, 277, 304, 267, 372, 1336, 63, 11929, 63, 4731, 8, 277, 14, 10077, 63, 16153, 2788, 17, 61, 339, 347, 6766, 8, 277, 304, 267, 340, 291, 423, 396, 63, 694, 26, 288, 986, 288, 327, 5145, 14, 9242, 8, 277, 423, 396, 63, 694, 9, 267, 291, 423, 396, 63, 694, 275, 488, 339, 347, 485, 16153, 8, 277, 12, 2505, 304, 267, 12738, 63, 4731, 275, 4516, 20229, 13790, 8, 2060, 9, 267, 12738, 63, 16153, 275, 4274, 885, 297, 12738, 63, 4731, 1874, 267, 372, 12738, 63, 16153, 339, 347, 511, 63, 2474, 63, 4494, 8, 277, 304, 267, 373, 275, 12738, 14, 20229, 10423, 8, 403, 9, 267, 14319, 275, 788, 981, 63, 493, 297, 326, 283, 15682, 63, 493, 297, 326, 283, 3773, 63, 493, 297, 326, 283, 11929, 63, 493, 297, 326, 283, 264, 498, 63, 493, 297, 326, 283, 739, 63, 576, 297, 326, 283, 952, 63, 576, 418, 267, 367, 9348, 315, 14319, 26, 288, 702, 2688, 8, 86, 12, 9348, 395, 298, 20229, 4728, 365, 4124, 314, 450, 83, 1083, 2, 450, 9348, 339, 347, 485, 981, 63, 396, 63, 694, 8, 277, 304, 267, 4739, 275, 2513, 4853, 63, 3248, 63, 396, 4970, 83, 8650, 450, 334, 277, 855, 533, 4914, 354, 3368, 267, 372, 5549, 14, 11983, 8, 4511, 29, 4511, 9, 339, 347, 485, 981, 63, 493, 8, 277, 12, 511, 63, 694, 12, 536, 12, 1564, 29, 403, 12, 15296, 29, 797, 304, 267, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 396, 63, 694, 12, 536, 9, 267, 12123, 63, 493, 275, 1551, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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f-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/>. # ############################################################################## { 'name': 'Leave Management', 'version': '1.5', 'author': 'OpenERP SA', 'category': 'Human Resources', 'sequence': 27, 'summary': 'Holidays, Allocation and Leave Requests', 'website': 'http://www.openerp.com', 'description': """ Manage leaves and allocation requests ===================================== This application controls the holiday schedule of your company. It allows employees to request holidays. Then, managers can review requests for holidays and approve or reject them. This way you can control the overall holiday planning for the company or department. You can configure several kinds of leaves (sickness, holidays, paid days, ...) and allocate leaves to an employee or department quickly using allocation requests. An employee can also make a request for more days off by making a new Allocation. It will increase the total of available days for that leave type (if the request is accepted). You can keep track of leaves in different ways by following reports: * Leaves Summary * Leaves by Department * Leaves Analysis A synchronization with an internal agenda (Meetings of the CRM module) is also possible in order to automatically create a meeting when a holiday request is accepted by setting up a type of meeting in Leave Type. """, 'images': ['images/hr_allocation_requests.jpeg', 'images/hr_leave_requests.jpeg', 'images/leaves_analysis.jpeg'], 'depends': ['hr', 'base_calendar', 'process', 'resource'], 'data': [ 'security/ir.model.access.csv', 'security/ir_rule.xml', 'hr_holidays_workflow.xml', 'hr_holidays_view.xml', 'hr_holidays_data.xml', 'hr_holidays_report.xml', 'report/hr_holidays_report_view.xml', 'report/available_holidays_view.xml', 'wizard/hr_holidays_summary_department_view.xml', 'wizard/hr_holidays_summary_employees_view.xml', 'board_hr_holidays_view.xml', ], 'demo': ['hr_holidays_demo.xml',], 'test': ['test/test_hr_holiday.yml', 'test/hr_holidays_report.yml', ], 'installable': True, 'application': True, 'auto_install': False, } # 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, 421, 199, 91, 272, 283, 354, 356, 283, 23679, 8259, 297, 272, 283, 1023, 356, 283, 17, 14, 21, 297, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 3710, 356, 283, 31355, 26250, 297, 272, 283, 4041, 356, 8087, 12, 272, 283, 4705, 356, 283, 17810, 317, 4899, 12, 4580, 1985, 436, 28015, 20260, 297, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 1802, 356, 408, 199, 20588, 16733, 436, 18723, 4145, 199, 2486, 19989, 199, 199, 2765, 4223, 13467, 314, 26475, 2977, 8732, 402, 2195, 7233, 14, 2779, 6127, 9052, 18149, 370, 1056, 26475, 4899, 14, 9442, 12, 19680, 883, 11248, 4145, 367, 26475, 4899, 436, 4286, 432, 503, 17100, 3062, 14, 961, 4340, 1265, 883, 3304, 314, 20347, 26475, 2977, 1620, 11495, 367, 314, 7233, 503, 27669, 14, 199, 199, 5556, 883, 7908, 9978, 24241, 402, 16733, 334, 32370, 4171, 12, 26475, 4899, 12, 30677, 7609, 12, 19172, 436, 18310, 16733, 370, 376, 15778, 503, 27669, 23661, 1808, 18723, 4145, 14, 1626, 15778, 883, 2597, 1852, 282, 1056, 367, 1655, 7609, 2331, 701, 10663, 282, 892, 4580, 1985, 14, 2779, 911, 19781, 314, 3141, 402, 2808, 7609, 367, 626, 10137, 730, 334, 692, 314, 1056, 365, 10226, 680, 199, 199, 5556, 883, 4215, 4426, 402, 16733, 315, 3365, 15217, 701, 2569, 13924, 26, 9948, 199, 10, 7005, 7047, 22486, 199, 10, 7005, 7047, 701, 1487, 12493, 199, 10, 7005, 7047, 21916, 199, 199, 33, 29509, 543, 376, 5007, 1839, 29162, 334, 1352, 386, 780, 402, 314, 445, 11026, 859, 9, 365, 2597, 3962, 315, 1865, 370, 5847, 1218, 282, 31495, 1380, 282, 26475, 2977, 1056, 365, 10226, 701, 4260, 1536, 282, 730, 402, 31495, 315, 28015, 2434, 14, 199, 7208, 272, 283, 4782, 356, 788, 4782, 15, 6271, 63, 14940, 63, 6615, 14, 14230, 297, 283, 4782, 15, 6271, 63, 12422, 63, 6615, 14, 14230, 297, 283, 4782, 15, 16554, 63, 10466, 14, 14230, 995, 272, 283, 8912, 356, 788, 6271, 297, 283, 1095, 63, 8183, 297, 283, 1412, 297, 283, 1927, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 4416, 15, 723, 63, 2200, 14, 1652, 297, 267, 283, 6271, 63, 26131, 63, 8856, 14, 1652, 297, 267, 283, 6271, 63, 26131, 63, 1345, 14, 1652, 297, 267, 283, 6271, 63, 26131, 63, 576, 14, 1652, 297, 267, 283, 6271, 63, 26131, 63, 3070, 14, 1652, 297, 267, 283, 3070, 15, 6271, 63, 26131, 63, 3070, 63, 1345, 14, 1652, 297, 267, 283, 3070, 15, 4561, 63, 26131, 63, 1345, 14, 1652, 297, 267, 283, 9819, 15, 6271, 63, 26131, 63, 4705, 63, 19623, 63, 1345, 14, 1652, 297, 267, 283, 9819, 15, 6271, 63, 26131, 63, 4705, 63, 24561, 63, 1345, 14, 1652, 297, 267, 283, 3576, 63, 6271, 63, 26131, 63, 1345, 14, 1652, 297, 267, 2156, 272, 283, 8768, 356, 788, 6271, 63, 26131, 63, 8768, 14, 1652, 297, 467, 272, 283, 396, 356, 788, 396, 15, 396, 63, 6271, 63, 20154, 2977, 14, 11714, 297, 1467, 283, 396, 15, 6271, 63, 26131, 63, 3070, 14, 11714, 297, 272, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 3578, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 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 ]
[ 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, 421, 199, 91, 272, 283, 354, 356, 283, 23679, 8259, 297, 272, 283, 1023, 356, 283, 17, 14, 21, 297, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 3710, 356, 283, 31355, 26250, 297, 272, 283, 4041, 356, 8087, 12, 272, 283, 4705, 356, 283, 17810, 317, 4899, 12, 4580, 1985, 436, 28015, 20260, 297, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 1802, 356, 408, 199, 20588, 16733, 436, 18723, 4145, 199, 2486, 19989, 199, 199, 2765, 4223, 13467, 314, 26475, 2977, 8732, 402, 2195, 7233, 14, 2779, 6127, 9052, 18149, 370, 1056, 26475, 4899, 14, 9442, 12, 19680, 883, 11248, 4145, 367, 26475, 4899, 436, 4286, 432, 503, 17100, 3062, 14, 961, 4340, 1265, 883, 3304, 314, 20347, 26475, 2977, 1620, 11495, 367, 314, 7233, 503, 27669, 14, 199, 199, 5556, 883, 7908, 9978, 24241, 402, 16733, 334, 32370, 4171, 12, 26475, 4899, 12, 30677, 7609, 12, 19172, 436, 18310, 16733, 370, 376, 15778, 503, 27669, 23661, 1808, 18723, 4145, 14, 1626, 15778, 883, 2597, 1852, 282, 1056, 367, 1655, 7609, 2331, 701, 10663, 282, 892, 4580, 1985, 14, 2779, 911, 19781, 314, 3141, 402, 2808, 7609, 367, 626, 10137, 730, 334, 692, 314, 1056, 365, 10226, 680, 199, 199, 5556, 883, 4215, 4426, 402, 16733, 315, 3365, 15217, 701, 2569, 13924, 26, 9948, 199, 10, 7005, 7047, 22486, 199, 10, 7005, 7047, 701, 1487, 12493, 199, 10, 7005, 7047, 21916, 199, 199, 33, 29509, 543, 376, 5007, 1839, 29162, 334, 1352, 386, 780, 402, 314, 445, 11026, 859, 9, 365, 2597, 3962, 315, 1865, 370, 5847, 1218, 282, 31495, 1380, 282, 26475, 2977, 1056, 365, 10226, 701, 4260, 1536, 282, 730, 402, 31495, 315, 28015, 2434, 14, 199, 7208, 272, 283, 4782, 356, 788, 4782, 15, 6271, 63, 14940, 63, 6615, 14, 14230, 297, 283, 4782, 15, 6271, 63, 12422, 63, 6615, 14, 14230, 297, 283, 4782, 15, 16554, 63, 10466, 14, 14230, 995, 272, 283, 8912, 356, 788, 6271, 297, 283, 1095, 63, 8183, 297, 283, 1412, 297, 283, 1927, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 4416, 15, 723, 63, 2200, 14, 1652, 297, 267, 283, 6271, 63, 26131, 63, 8856, 14, 1652, 297, 267, 283, 6271, 63, 26131, 63, 1345, 14, 1652, 297, 267, 283, 6271, 63, 26131, 63, 576, 14, 1652, 297, 267, 283, 6271, 63, 26131, 63, 3070, 14, 1652, 297, 267, 283, 3070, 15, 6271, 63, 26131, 63, 3070, 63, 1345, 14, 1652, 297, 267, 283, 3070, 15, 4561, 63, 26131, 63, 1345, 14, 1652, 297, 267, 283, 9819, 15, 6271, 63, 26131, 63, 4705, 63, 19623, 63, 1345, 14, 1652, 297, 267, 283, 9819, 15, 6271, 63, 26131, 63, 4705, 63, 24561, 63, 1345, 14, 1652, 297, 267, 283, 3576, 63, 6271, 63, 26131, 63, 1345, 14, 1652, 297, 267, 2156, 272, 283, 8768, 356, 788, 6271, 63, 26131, 63, 8768, 14, 1652, 297, 467, 272, 283, 396, 356, 788, 396, 15, 396, 63, 6271, 63, 20154, 2977, 14, 11714, 297, 1467, 283, 396, 15, 6271, 63, 26131, 63, 3070, 14, 11714, 297, 272, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 3578, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
8l/bokken
lib/backend.py
4
1370
# -*- coding: utf-8 -*- """ Bokken Disassembler Framework Copyright (c) 2015 David Martínez Moreno <ender@debian.org> I am providing code in this repository to you under an open source license. Because this is a personal repository, the license you receive to my code is from me and not my employer (Facebook). 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. """ """ This library provides a generic Backend instance. """ class BasicBackend(): '''Blank instance of a disassembly engine.''' def __init__(): pass def analyze_entropy(self): if not self.filename: return False # TODO: We don't know what to do in case of a URL! if self.fileinfo == 'URL': return False
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 34, 745, 917, 5289, 21263, 82, 22545, 199, 7384, 334, 67, 9, 6900, 20232, 603, 580, 13676, 685, 90, 16917, 889, 665, 13747, 32, 23204, 14, 1308, 30, 199, 199, 41, 8140, 13070, 1233, 315, 642, 7611, 370, 1265, 1334, 376, 1551, 1350, 4190, 14, 199, 3655, 2651, 642, 365, 282, 25994, 7611, 12, 314, 4190, 1265, 9128, 370, 3002, 1233, 199, 374, 687, 562, 436, 440, 3002, 9052, 3374, 281, 334, 13414, 2706, 680, 199, 199, 2765, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 996, 6019, 13, 10067, 12, 8217, 14, 199, 624, 199, 199, 624, 961, 3555, 6571, 282, 7809, 25674, 1256, 14, 408, 199, 199, 533, 10082, 8447, 837, 272, 1449, 28083, 1256, 402, 282, 2153, 17828, 6869, 10595, 272, 347, 636, 826, 721, 304, 267, 986, 339, 347, 19897, 63, 10435, 8, 277, 304, 267, 340, 440, 291, 14, 1501, 26, 288, 372, 756, 267, 327, 3254, 26, 2136, 2793, 1133, 5715, 4052, 370, 886, 315, 1930, 402, 282, 2851, 1, 267, 340, 291, 14, 493, 815, 508, 283, 2632, 356, 288, 372, 756, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 34, 745, 917, 5289, 21263, 82, 22545, 199, 7384, 334, 67, 9, 6900, 20232, 603, 580, 13676, 685, 90, 16917, 889, 665, 13747, 32, 23204, 14, 1308, 30, 199, 199, 41, 8140, 13070, 1233, 315, 642, 7611, 370, 1265, 1334, 376, 1551, 1350, 4190, 14, 199, 3655, 2651, 642, 365, 282, 25994, 7611, 12, 314, 4190, 1265, 9128, 370, 3002, 1233, 199, 374, 687, 562, 436, 440, 3002, 9052, 3374, 281, 334, 13414, 2706, 680, 199, 199, 2765, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 996, 6019, 13, 10067, 12, 8217, 14, 199, 624, 199, 199, 624, 961, 3555, 6571, 282, 7809, 25674, 1256, 14, 408, 199, 199, 533, 10082, 8447, 837, 272, 1449, 28083, 1256, 402, 282, 2153, 17828, 6869, 10595, 272, 347, 636, 826, 721, 304, 267, 986, 339, 347, 19897, 63, 10435, 8, 277, 304, 267, 340, 440, 291, 14, 1501, 26, 288, 372, 756, 267, 327, 3254, 26, 2136, 2793, 1133, 5715, 4052, 370, 886, 315, 1930, 402, 282, 2851, 1, 267, 340, 291, 14, 493, 815, 508, 283, 2632, 356, 288, 372, 756, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
engine95/navel-855
tools/perf/scripts/python/net_dropmonitor.py
4235
1554
# Monitor the system for dropped packets and proudce a report of drop locations and counts import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import * drop_log = {} kallsyms = [] def get_kallsyms_table(): global kallsyms try: f = open("/proc/kallsyms", "r") linecount = 0 for line in f: linecount = linecount+1 f.seek(0) except: return j = 0 for line in f: loc = int(line.split()[0], 16) name = line.split()[2] j = j +1 if ((j % 100) == 0): print "\r" + str(j) + "/" + str(linecount), kallsyms.append({ 'loc': loc, 'name' : name}) print "\r" + str(j) + "/" + str(linecount) kallsyms.sort() return def get_sym(sloc): loc = int(sloc) for i in kallsyms: if (i['loc'] >= loc): return (i['name'], i['loc']-loc) return (None, 0) def print_drop_table(): print "%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT") for i in drop_log.keys(): (sym, off) = get_sym(i) if sym == None: sym = i print "%25s %25s %25s" % (sym, off, drop_log[i]) def trace_begin(): print "Starting trace (Ctrl-C to dump results)" def trace_end(): print "Gathering kallsyms data" get_kallsyms_table() print_drop_table() # called from perf, when it finds a correspoinding event def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, skbaddr, protocol, location): slocation = str(location) try: drop_log[slocation] = drop_log[slocation] + 1 except: drop_log[slocation] = 1
gpl-2.0
[ 3, 26504, 314, 2656, 367, 17481, 14593, 436, 557, 1181, 301, 282, 3622, 402, 5978, 9918, 436, 8242, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 507, 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, 4824, 63, 793, 275, 1052, 199, 32483, 275, 942, 199, 199, 318, 664, 63, 32483, 63, 1224, 837, 199, 198, 2966, 1022, 452, 13807, 199, 198, 893, 26, 507, 198, 70, 275, 1551, 4769, 4687, 15, 32483, 401, 298, 82, 531, 507, 198, 604, 835, 275, 378, 507, 198, 509, 1004, 315, 289, 26, 686, 198, 604, 835, 275, 1004, 835, 11, 17, 507, 198, 70, 14, 5507, 8, 16, 9, 199, 198, 2590, 26, 507, 198, 1107, 4388, 198, 74, 275, 378, 199, 198, 509, 1004, 315, 289, 26, 507, 198, 2102, 275, 1109, 8, 604, 14, 1294, 3430, 16, 467, 3193, 9, 507, 198, 354, 275, 1004, 14, 1294, 3430, 18, 61, 507, 198, 74, 275, 1335, 435, 17, 507, 198, 692, 3666, 74, 450, 2948, 9, 508, 378, 304, 686, 198, 1361, 1867, 82, 2, 435, 620, 8, 74, 9, 435, 10609, 435, 620, 8, 604, 835, 395, 507, 198, 32483, 14, 740, 2561, 283, 2102, 356, 4355, 12, 283, 354, 7, 520, 536, 1552, 421, 198, 1361, 1867, 82, 2, 435, 620, 8, 74, 9, 435, 10609, 435, 620, 8, 604, 835, 9, 199, 198, 32483, 14, 3191, 342, 199, 198, 1107, 199, 199, 318, 664, 63, 3840, 8, 83, 2102, 304, 199, 198, 2102, 275, 1109, 8, 83, 2102, 9, 199, 198, 509, 284, 315, 1022, 452, 13807, 26, 507, 198, 692, 334, 73, 459, 2102, 418, 2356, 4355, 304, 686, 198, 1107, 334, 73, 459, 354, 995, 284, 459, 2102, 418, 13, 2102, 9, 199, 198, 1107, 334, 403, 12, 378, 9, 199, 199, 318, 870, 63, 4824, 63, 1224, 837, 199, 198, 1361, 2071, 821, 83, 450, 821, 83, 450, 821, 83, 2, 450, 1689, 16575, 401, 298, 14839, 401, 298, 8760, 531, 199, 198, 509, 284, 315, 5978, 63, 793, 14, 1612, 837, 507, 198, 8, 3840, 12, 2331, 9, 275, 664, 63, 3840, 8, 73, 9, 507, 198, 692, 4678, 508, 488, 26, 686, 198, 3840, 275, 284, 507, 198, 1361, 2071, 821, 83, 450, 821, 83, 450, 821, 83, 2, 450, 334, 3840, 12, 2331, 12, 5978, 63, 793, 59, 73, 566, 421, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14139, 3307, 334, 9778, 13, 35, 370, 5461, 2058, 2924, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 298, 39, 7404, 316, 1022, 452, 13807, 666, 2, 199, 198, 362, 63, 32483, 63, 1224, 342, 199, 198, 1361, 63, 4824, 63, 1224, 342, 199, 199, 3, 2797, 687, 8582, 12, 1380, 652, 17651, 282, 1970, 470, 555, 688, 316, 1566, 199, 318, 11448, 363, 22197, 63, 6852, 8, 354, 12, 1067, 12, 5033, 12, 6513, 12, 14256, 12, 4422, 12, 1923, 12, 686, 198, 13664, 12, 4113, 12, 2909, 304, 199, 198, 83, 1985, 275, 620, 8, 1985, 9, 199, 198, 893, 26, 507, 198, 4824, 63, 793, 59, 83, 1985, 61, 275, 5978, 63, 793, 59, 83, 1985, 61, 435, 413, 199, 198, 2590, 26, 507, 198, 4824, 63, 793, 59, 83, 1985, 61, 275, 413, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 26504, 314, 2656, 367, 17481, 14593, 436, 557, 1181, 301, 282, 3622, 402, 5978, 9918, 436, 8242, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 507, 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, 4824, 63, 793, 275, 1052, 199, 32483, 275, 942, 199, 199, 318, 664, 63, 32483, 63, 1224, 837, 199, 198, 2966, 1022, 452, 13807, 199, 198, 893, 26, 507, 198, 70, 275, 1551, 4769, 4687, 15, 32483, 401, 298, 82, 531, 507, 198, 604, 835, 275, 378, 507, 198, 509, 1004, 315, 289, 26, 686, 198, 604, 835, 275, 1004, 835, 11, 17, 507, 198, 70, 14, 5507, 8, 16, 9, 199, 198, 2590, 26, 507, 198, 1107, 4388, 198, 74, 275, 378, 199, 198, 509, 1004, 315, 289, 26, 507, 198, 2102, 275, 1109, 8, 604, 14, 1294, 3430, 16, 467, 3193, 9, 507, 198, 354, 275, 1004, 14, 1294, 3430, 18, 61, 507, 198, 74, 275, 1335, 435, 17, 507, 198, 692, 3666, 74, 450, 2948, 9, 508, 378, 304, 686, 198, 1361, 1867, 82, 2, 435, 620, 8, 74, 9, 435, 10609, 435, 620, 8, 604, 835, 395, 507, 198, 32483, 14, 740, 2561, 283, 2102, 356, 4355, 12, 283, 354, 7, 520, 536, 1552, 421, 198, 1361, 1867, 82, 2, 435, 620, 8, 74, 9, 435, 10609, 435, 620, 8, 604, 835, 9, 199, 198, 32483, 14, 3191, 342, 199, 198, 1107, 199, 199, 318, 664, 63, 3840, 8, 83, 2102, 304, 199, 198, 2102, 275, 1109, 8, 83, 2102, 9, 199, 198, 509, 284, 315, 1022, 452, 13807, 26, 507, 198, 692, 334, 73, 459, 2102, 418, 2356, 4355, 304, 686, 198, 1107, 334, 73, 459, 354, 995, 284, 459, 2102, 418, 13, 2102, 9, 199, 198, 1107, 334, 403, 12, 378, 9, 199, 199, 318, 870, 63, 4824, 63, 1224, 837, 199, 198, 1361, 2071, 821, 83, 450, 821, 83, 450, 821, 83, 2, 450, 1689, 16575, 401, 298, 14839, 401, 298, 8760, 531, 199, 198, 509, 284, 315, 5978, 63, 793, 14, 1612, 837, 507, 198, 8, 3840, 12, 2331, 9, 275, 664, 63, 3840, 8, 73, 9, 507, 198, 692, 4678, 508, 488, 26, 686, 198, 3840, 275, 284, 507, 198, 1361, 2071, 821, 83, 450, 821, 83, 450, 821, 83, 2, 450, 334, 3840, 12, 2331, 12, 5978, 63, 793, 59, 73, 566, 421, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14139, 3307, 334, 9778, 13, 35, 370, 5461, 2058, 2924, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 298, 39, 7404, 316, 1022, 452, 13807, 666, 2, 199, 198, 362, 63, 32483, 63, 1224, 342, 199, 198, 1361, 63, 4824, 63, 1224, 342, 199, 199, 3, 2797, 687, 8582, 12, 1380, 652, 17651, 282, 1970, 470, 555, 688, 316, 1566, 199, 318, 11448, 363, 22197, 63, 6852, 8, 354, 12, 1067, 12, 5033, 12, 6513, 12, 14256, 12, 4422, 12, 1923, 12, 686, 198, 13664, 12, 4113, 12, 2909, 304, 199, 198, 83, 1985, 275, 620, 8, 1985, 9, 199, 198, 893, 26, 507, 198, 4824, 63, 793, 59, 83, 1985, 61, 275, 5978, 63, 793, 59, 83, 1985, 61, 435, 413, 199, 198, 2590, 26, 507, 198, 4824, 63, 793, 59, 83, 1985, 61, 275, 413, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
DamCB/tyssue
tyssue/draw/ipv_draw.py
2
8114
"""3D visualisation inside the notebook. """ import warnings import numpy as np import pandas as pd from matplotlib import cm from ipywidgets import interact from ..config.draw import sheet_spec from ..utils.utils import spec_updater, get_sub_eptm try: import ipyvolume as ipv except ImportError: print( """ This module needs ipyvolume to work. You can install it with: $ conda install -c conda-forge ipyvolume """ ) def browse_history(history, coords=["x", "y", "z"], **draw_specs_kw): times = history.time_stamps num_frames = times.size draw_specs = sheet_spec() spec_updater(draw_specs, draw_specs_kw) sheet = history.retrieve(0) ipv.clear() fig, meshes = sheet_view(sheet, coords, **draw_specs_kw) lim_inf = sheet.vert_df[sheet.coords].min().min() lim_sup = sheet.vert_df[sheet.coords].max().max() ipv.xyzlim(lim_inf, lim_sup) def set_frame(i=0): fig.animation = 0 t = times[i] meshes = _get_meshes(history.retrieve(t), coords, draw_specs) update_view(fig, meshes) ipv.show() interact(set_frame, i=(0, num_frames - 1)) def update_view(fig, meshes): for old, new in zip(fig.meshes, meshes): old.x = new.x old.y = new.y old.z = new.z old.color = new.color old.triangles = new.triangles old.lines = new.lines def sheet_view(sheet, coords=["x", "y", "z"], **draw_specs_kw): """ Creates a javascript renderer of the edge lines to be displayed in Jupyter Notebooks Returns ------- fig: a :class:`ipyvolume.widgets.Figure` widget mesh: a :class:`ipyvolume.widgets.Mesh` mesh widget """ # ipv.style.use(["dark", "minimal"]) draw_specs = sheet_spec() spec_updater(draw_specs, draw_specs_kw) fig = ipv.gcf() fig.meshes = fig.meshes + _get_meshes(sheet, coords, draw_specs) box_size = max(*(np.ptp(sheet.vert_df[u]) for u in sheet.coords)) border = 0.05 * box_size lim_inf = sheet.vert_df[sheet.coords].min().min() - border lim_sup = sheet.vert_df[sheet.coords].max().max() + border ipv.xyzlim(lim_inf, lim_sup) return fig, fig.meshes def view_ipv(sheet, coords=["x", "y", "z"], **edge_specs): """ Creates a javascript renderer of the edge lines to be displayed in Jupyter Notebooks Returns ------- fig: a :class:`ipyvolume.widgets.Figure` widget mesh: a :class:`ipyvolume.widgets.Mesh` mesh widget """ warnings.warn("`view_ipv` is deprecated, use the more generic `sheet_view`") mesh = edge_mesh(sheet, coords, **edge_specs) fig = ipv.gcf() fig.meshes = fig.meshes + [mesh] box_size = max(*(np.ptp(sheet.vert_df[u]) for u in sheet.coords)) border = 0.05 * box_size lim_inf = sheet.vert_df[sheet.coords].min().min() - border lim_sup = sheet.vert_df[sheet.coords].max().max() + border ipv.xyzlim(lim_inf, lim_sup) return fig, mesh def edge_mesh(sheet, coords, **edge_specs): """ Creates a ipyvolume Mesh of the edge lines to be displayed in Jupyter Notebooks Returns ------- mesh: a :class:`ipyvolume.widgets.Mesh` mesh widget """ spec = sheet_spec()["edge"] spec.update(**edge_specs) if callable(spec["color"]): spec["color"] = spec["color"](sheet) if isinstance(spec["color"], str): color = spec["color"] elif hasattr(spec["color"], "__len__"): color = _wire_color_from_sequence(spec, sheet)[:, :3] u, v, w = coords mesh = ipv.Mesh( x=sheet.vert_df[u], y=sheet.vert_df[v], z=sheet.vert_df[w], lines=sheet.edge_df[["srce", "trgt"]].astype(dtype=np.uint32), color=color, ) return mesh def face_mesh(sheet, coords, **face_draw_specs): """ Creates a ipyvolume Mesh of the face polygons """ Ne, Nf = sheet.Ne, sheet.Nf if callable(face_draw_specs["color"]): face_draw_specs["color"] = face_draw_specs["color"](sheet) if isinstance(face_draw_specs["color"], str): color = face_draw_specs["color"] elif hasattr(face_draw_specs["color"], "__len__"): color = _face_color_from_sequence(face_draw_specs, sheet)[:, :3] if "visible" in sheet.face_df.columns: edges = sheet.edge_df[sheet.upcast_face(sheet.face_df["visible"])].index _sheet = get_sub_eptm(sheet, edges) if _sheet is not None: sheet = _sheet if isinstance(color, np.ndarray): faces = sheet.face_df["face_o"].values.astype(np.uint32) edges = edges.values.astype(np.uint32) indexer = np.concatenate([faces, edges + Nf, edges + Ne + Nf]) color = color.take(indexer, axis=0) epsilon = face_draw_specs.get("epsilon", 0) up_srce = sheet.edge_df[["s" + c for c in coords]] up_trgt = sheet.edge_df[["t" + c for c in coords]] Ne, Nf = sheet.Ne, sheet.Nf if epsilon > 0: up_face = sheet.edge_df[["f" + c for c in coords]].values up_srce = (up_srce - up_face) * (1 - epsilon) + up_face up_trgt = (up_trgt - up_face) * (1 - epsilon) + up_face mesh_ = np.concatenate( [sheet.face_df[coords].values, up_srce.values, up_trgt.values] ) triangles = np.vstack( [sheet.edge_df["face"], np.arange(Ne) + Nf, np.arange(Ne) + Ne + Nf] ).T.astype(dtype=np.uint32) mesh = ipv.Mesh( x=mesh_[:, 0], y=mesh_[:, 1], z=mesh_[:, 2], triangles=triangles, color=color ) return mesh def _wire_color_from_sequence(edge_spec, sheet): """ """ color_ = edge_spec["color"] cmap = cm.get_cmap(edge_spec.get("colormap", "viridis")) if color_.shape in [(sheet.Nv, 3), (sheet.Nv, 4)]: return np.asarray(color_) if color_.shape == (sheet.Nv,): if np.ptp(color_) < 1e-10: return np.ones((sheet.Nv, 3)) * 0.7 return cmap((color_ - color_.min()) / np.ptp(color_)) if color_.shape in [(sheet.Ne, 3), (sheet.Ne, 4)]: color_ = pd.DataFrame(color_, index=sheet.edge_df.index) color_["srce"] = sheet.edge_df["srce"] color_ = color_.groupby("srce").mean().values return color_ if color_.shape == (sheet.Ne,): color_ = pd.DataFrame(color_, index=sheet.edge_df.index) color_["srce"] = sheet.edge_df["srce"] color_ = color_.groupby("srce").mean().values.ravel() if np.ptp(color_) < 1e-10: warnings.warn("Attempting to draw a colormap " "with a uniform value") return np.ones((sheet.Nv, 3)) * 0.7 return cmap((color_ - color_.min()) / np.ptp(color_)) else: raise ValueError("The 'color' value of the spec doesn't have a correct shape.") def _face_color_from_sequence(face_spec, sheet): color_ = face_spec["color"] cmap = cm.get_cmap(face_spec.get("colormap", "viridis")) Nf, Ne = sheet.Nf, sheet.Ne color_min, color_max = face_spec.get("color_range", (color_.min(), color_.max())) face_mesh_shape = Nf + 2 * Ne if color_.shape in [(sheet.Nf, 3), (sheet.Nf, 4)]: return np.concatenate([color_, color_, color_]) elif color_.shape == (sheet.Nf,): if np.ptp(color_) < 1e-10: # warnings.warn("Attempting to draw a colormap with a uniform value") return np.ones((face_mesh_shape, 3)) * 0.5 normed = (color_ - color_min) / (color_max - color_min) up_color = sheet.upcast_face(normed).values return cmap(np.concatenate([normed, up_color, up_color])) else: raise ValueError( "shape of `face_spec['color']` must be either (Nf, 3), (Nf, 4) or (Nf,)" ) def _get_meshes(sheet, coords, draw_specs): meshes = [] edge_spec = draw_specs["edge"] if edge_spec["visible"]: edges = edge_mesh(sheet, coords, **edge_spec) meshes.append(edges) else: edges = None face_spec = draw_specs["face"] if face_spec["visible"]: faces = face_mesh(sheet, coords, **face_spec) meshes.append(faces) else: faces = None return meshes
gpl-3.0
[ 624, 19, 36, 13104, 19914, 6272, 314, 20751, 14, 199, 624, 199, 646, 3598, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 504, 8027, 492, 6904, 199, 504, 284, 647, 8583, 492, 17232, 199, 199, 504, 2508, 888, 14, 5485, 492, 12083, 63, 1650, 199, 504, 2508, 1208, 14, 1208, 492, 3158, 63, 29645, 12, 664, 63, 954, 63, 69, 541, 77, 199, 199, 893, 26, 272, 492, 284, 647, 2405, 465, 3278, 199, 2590, 3545, 26, 272, 870, 8, 267, 408, 199, 2765, 859, 4839, 284, 647, 2405, 370, 1736, 14, 199, 5556, 883, 3907, 652, 543, 26, 199, 4, 406, 983, 3907, 446, 67, 406, 983, 13, 16677, 284, 647, 2405, 199, 624, 272, 776, 421, 199, 318, 19249, 63, 5570, 8, 5570, 12, 13259, 6270, 88, 401, 298, 89, 401, 298, 90, 2255, 1011, 5485, 63, 7273, 63, 829, 304, 339, 5431, 275, 7994, 14, 521, 63, 2359, 83, 272, 1967, 63, 8444, 275, 5431, 14, 890, 272, 5954, 63, 7273, 275, 12083, 63, 1650, 342, 272, 3158, 63, 29645, 8, 5485, 63, 7273, 12, 5954, 63, 7273, 63, 829, 9, 272, 12083, 275, 7994, 14, 14270, 8, 16, 9, 272, 3278, 14, 3584, 342, 272, 6085, 12, 9364, 397, 275, 12083, 63, 1345, 8, 5069, 12, 13259, 12, 1011, 5485, 63, 7273, 63, 829, 9, 339, 1212, 77, 63, 4904, 275, 12083, 14, 1884, 63, 1587, 59, 5069, 14, 8032, 1055, 827, 1252, 827, 342, 272, 1212, 77, 63, 1961, 275, 12083, 14, 1884, 63, 1587, 59, 5069, 14, 8032, 1055, 988, 1252, 988, 342, 272, 3278, 14, 8568, 4175, 8, 4175, 63, 4904, 12, 1212, 77, 63, 1961, 9, 339, 347, 663, 63, 1943, 8, 73, 29, 16, 304, 267, 6085, 14, 22228, 275, 378, 267, 307, 275, 5431, 59, 73, 61, 267, 9364, 397, 275, 485, 362, 63, 6480, 397, 8, 5570, 14, 14270, 8, 84, 395, 13259, 12, 5954, 63, 7273, 9, 267, 1678, 63, 1345, 8, 592, 12, 9364, 397, 9, 339, 3278, 14, 2384, 342, 272, 17232, 8, 409, 63, 1943, 12, 284, 2687, 16, 12, 1967, 63, 8444, 446, 413, 430, 421, 199, 318, 1678, 63, 1345, 8, 592, 12, 9364, 397, 304, 339, 367, 2269, 12, 892, 315, 3482, 8, 592, 14, 6480, 397, 12, 9364, 397, 304, 267, 2269, 14, 88, 275, 892, 14, 88, 267, 2269, 14, 89, 275, 892, 14, 89, 267, 2269, 14, 90, 275, 892, 14, 90, 267, 2269, 14, 2326, 275, 892, 14, 2326, 267, 2269, 14, 599, 13162, 275, 892, 14, 599, 13162, 267, 2269, 14, 1278, 275, 892, 14, 1278, 421, 199, 318, 12083, 63, 1345, 8, 5069, 12, 13259, 6270, 88, 401, 298, 89, 401, 298, 90, 2255, 1011, 5485, 63, 7273, 63, 829, 304, 272, 408, 272, 10560, 282, 18910, 11889, 402, 314, 6275, 2385, 370, 506, 9080, 272, 315, 1603, 28022, 351, 3390, 8858, 339, 1803, 272, 5514, 339, 6085, 26, 282, 520, 533, 1705, 73, 647, 2405, 14, 8583, 14, 25590, 64, 3938, 272, 9364, 26, 282, 520, 533, 1705, 73, 647, 2405, 14, 8583, 14, 12241, 64, 9364, 3938, 339, 408, 339, 327, 3278, 14, 2487, 14, 1180, 5234, 13625, 401, 298, 21508, 3135, 272, 5954, 63, 7273, 275, 12083, 63, 1650, 342, 272, 3158, 63, 29645, 8, 5485, 63, 7273, 12, 5954, 63, 7273, 63, 829, 9, 272, 6085, 275, 3278, 14, 71, 2177, 342, 272, 6085, 14, 6480, 397, 275, 6085, 14, 6480, 397, 435, 485, 362, 63, 6480, 397, 8, 5069, 12, 13259, 12, 5954, 63, 7273, 9, 272, 5689, 63, 890, 275, 1390, 29316, 1590, 14, 541, 80, 8, 5069, 14, 1884, 63, 1587, 59, 85, 566, 367, 399, 315, 12083, 14, 8032, 430, 272, 9162, 275, 378, 14, 1717, 627, 5689, 63, 890, 272, 1212, 77, 63, 4904, 275, 12083, 14, 1884, 63, 1587, 59, 5069, 14, 8032, 1055, 827, 1252, 827, 342, 446, 9162, 272, 1212, 77, 63, 1961, 275, 12083, 14, 1884, 63, 1587, 59, 5069, 14, 8032, 1055, 988, 1252, 988, 342, 435, 9162, 272, 3278, 14, 8568, 4175, 8, 4175, 63, 4904, 12, 1212, 77, 63, 1961, 9, 272, 372, 6085, 12, 6085, 14, 6480, 397, 421, 199, 318, 2455, 63, 4774, 8, 5069, 12, 13259, 6270, 88, 401, 298, 89, 401, 298, 90, 2255, 1011, 5173, 63, 7273, 304, 272, 408, 272, 10560, 282, 18910, 11889, 402, 314, 6275, 2385, 370, 506, 9080, 272, 315, 1603, 28022, 351, 3390, 8858, 339, 1803, 272, 5514, 339, 6085, 26, 282, 520, 533, 1705, 73, 647, 2405, 14, 8583, 14, 25590, 64, 3938, 272, 9364, 26, 282, 520, 533, 1705, 73, 647, 2405, 14, 8583, 14, 12241, 64, 9364, 3938, 339, 408, 272, 3598, 14, 4050, 32684, 1345, 63, 4774, 64, 365, 5906, 12, 675, 314, 1655, 7809, 658, 5069, 63, 1345, 22446, 272, 9364, 275, 6275, 63, 6480, 8, 5069, 12, 13259, 12, 1011, 5173, 63, 7273, 9, 272, 6085, 275, 3278, 14, 71, 2177, 342, 272, 6085, 14, 6480, 397, 275, 6085, 14, 6480, 397, 435, 359, 6480, 61, 272, 5689, 63, 890, 275, 1390, 29316, 1590, 14, 541, 80, 8, 5069, 14, 1884, 63, 1587, 59, 85, 566, 367, 399, 315, 12083, 14, 8032, 430, 272, 9162, 275, 378, 14, 1717, 627, 5689, 63, 890, 272, 1212, 77, 63, 4904, 275, 12083, 14, 1884, 63, 1587, 59, 5069, 14, 8032, 1055, 827, 1252, 827, 342, 446, 9162, 272, 1212, 77, 63, 1961, 275, 12083, 14, 1884, 63, 1587, 59, 5069, 14, 8032, 1055, 988, 1252, 988, 342, 435, 9162, 272, 3278, 14, 8568, 4175, 8, 4175, 63, 4904, 12, 1212, 77, 63, 1961, 9, 339, 372, 6085, 12, 9364, 421, 199, 318, 6275, 63, 6480, 8, 5069, 12, 13259, 12, 1011, 5173, 63, 7273, 304, 272, 408, 272, 10560, 282, 284, 647, 2405, 603, 10613, 402, 314, 6275, 2385, 370, 506, 9080, 272, 315, 1603, 28022, 351, 3390, 8858, 339, 1803, 272, 5514, 272, 9364, 26, 282, 520, 533, 1705, 73, 647, 2405, 14, 8583, 14, 12241, 64, 9364, 3938, 339, 408, 272, 3158, 275, 12083, 63, 1650, 22957, 5173, 937, 272, 3158, 14, 873, 3682, 5173, 63, 7273, 9, 272, 340, 4550, 8, 1650, 905, 2326 ]
[ 19, 36, 13104, 19914, 6272, 314, 20751, 14, 199, 624, 199, 646, 3598, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 504, 8027, 492, 6904, 199, 504, 284, 647, 8583, 492, 17232, 199, 199, 504, 2508, 888, 14, 5485, 492, 12083, 63, 1650, 199, 504, 2508, 1208, 14, 1208, 492, 3158, 63, 29645, 12, 664, 63, 954, 63, 69, 541, 77, 199, 199, 893, 26, 272, 492, 284, 647, 2405, 465, 3278, 199, 2590, 3545, 26, 272, 870, 8, 267, 408, 199, 2765, 859, 4839, 284, 647, 2405, 370, 1736, 14, 199, 5556, 883, 3907, 652, 543, 26, 199, 4, 406, 983, 3907, 446, 67, 406, 983, 13, 16677, 284, 647, 2405, 199, 624, 272, 776, 421, 199, 318, 19249, 63, 5570, 8, 5570, 12, 13259, 6270, 88, 401, 298, 89, 401, 298, 90, 2255, 1011, 5485, 63, 7273, 63, 829, 304, 339, 5431, 275, 7994, 14, 521, 63, 2359, 83, 272, 1967, 63, 8444, 275, 5431, 14, 890, 272, 5954, 63, 7273, 275, 12083, 63, 1650, 342, 272, 3158, 63, 29645, 8, 5485, 63, 7273, 12, 5954, 63, 7273, 63, 829, 9, 272, 12083, 275, 7994, 14, 14270, 8, 16, 9, 272, 3278, 14, 3584, 342, 272, 6085, 12, 9364, 397, 275, 12083, 63, 1345, 8, 5069, 12, 13259, 12, 1011, 5485, 63, 7273, 63, 829, 9, 339, 1212, 77, 63, 4904, 275, 12083, 14, 1884, 63, 1587, 59, 5069, 14, 8032, 1055, 827, 1252, 827, 342, 272, 1212, 77, 63, 1961, 275, 12083, 14, 1884, 63, 1587, 59, 5069, 14, 8032, 1055, 988, 1252, 988, 342, 272, 3278, 14, 8568, 4175, 8, 4175, 63, 4904, 12, 1212, 77, 63, 1961, 9, 339, 347, 663, 63, 1943, 8, 73, 29, 16, 304, 267, 6085, 14, 22228, 275, 378, 267, 307, 275, 5431, 59, 73, 61, 267, 9364, 397, 275, 485, 362, 63, 6480, 397, 8, 5570, 14, 14270, 8, 84, 395, 13259, 12, 5954, 63, 7273, 9, 267, 1678, 63, 1345, 8, 592, 12, 9364, 397, 9, 339, 3278, 14, 2384, 342, 272, 17232, 8, 409, 63, 1943, 12, 284, 2687, 16, 12, 1967, 63, 8444, 446, 413, 430, 421, 199, 318, 1678, 63, 1345, 8, 592, 12, 9364, 397, 304, 339, 367, 2269, 12, 892, 315, 3482, 8, 592, 14, 6480, 397, 12, 9364, 397, 304, 267, 2269, 14, 88, 275, 892, 14, 88, 267, 2269, 14, 89, 275, 892, 14, 89, 267, 2269, 14, 90, 275, 892, 14, 90, 267, 2269, 14, 2326, 275, 892, 14, 2326, 267, 2269, 14, 599, 13162, 275, 892, 14, 599, 13162, 267, 2269, 14, 1278, 275, 892, 14, 1278, 421, 199, 318, 12083, 63, 1345, 8, 5069, 12, 13259, 6270, 88, 401, 298, 89, 401, 298, 90, 2255, 1011, 5485, 63, 7273, 63, 829, 304, 272, 408, 272, 10560, 282, 18910, 11889, 402, 314, 6275, 2385, 370, 506, 9080, 272, 315, 1603, 28022, 351, 3390, 8858, 339, 1803, 272, 5514, 339, 6085, 26, 282, 520, 533, 1705, 73, 647, 2405, 14, 8583, 14, 25590, 64, 3938, 272, 9364, 26, 282, 520, 533, 1705, 73, 647, 2405, 14, 8583, 14, 12241, 64, 9364, 3938, 339, 408, 339, 327, 3278, 14, 2487, 14, 1180, 5234, 13625, 401, 298, 21508, 3135, 272, 5954, 63, 7273, 275, 12083, 63, 1650, 342, 272, 3158, 63, 29645, 8, 5485, 63, 7273, 12, 5954, 63, 7273, 63, 829, 9, 272, 6085, 275, 3278, 14, 71, 2177, 342, 272, 6085, 14, 6480, 397, 275, 6085, 14, 6480, 397, 435, 485, 362, 63, 6480, 397, 8, 5069, 12, 13259, 12, 5954, 63, 7273, 9, 272, 5689, 63, 890, 275, 1390, 29316, 1590, 14, 541, 80, 8, 5069, 14, 1884, 63, 1587, 59, 85, 566, 367, 399, 315, 12083, 14, 8032, 430, 272, 9162, 275, 378, 14, 1717, 627, 5689, 63, 890, 272, 1212, 77, 63, 4904, 275, 12083, 14, 1884, 63, 1587, 59, 5069, 14, 8032, 1055, 827, 1252, 827, 342, 446, 9162, 272, 1212, 77, 63, 1961, 275, 12083, 14, 1884, 63, 1587, 59, 5069, 14, 8032, 1055, 988, 1252, 988, 342, 435, 9162, 272, 3278, 14, 8568, 4175, 8, 4175, 63, 4904, 12, 1212, 77, 63, 1961, 9, 272, 372, 6085, 12, 6085, 14, 6480, 397, 421, 199, 318, 2455, 63, 4774, 8, 5069, 12, 13259, 6270, 88, 401, 298, 89, 401, 298, 90, 2255, 1011, 5173, 63, 7273, 304, 272, 408, 272, 10560, 282, 18910, 11889, 402, 314, 6275, 2385, 370, 506, 9080, 272, 315, 1603, 28022, 351, 3390, 8858, 339, 1803, 272, 5514, 339, 6085, 26, 282, 520, 533, 1705, 73, 647, 2405, 14, 8583, 14, 25590, 64, 3938, 272, 9364, 26, 282, 520, 533, 1705, 73, 647, 2405, 14, 8583, 14, 12241, 64, 9364, 3938, 339, 408, 272, 3598, 14, 4050, 32684, 1345, 63, 4774, 64, 365, 5906, 12, 675, 314, 1655, 7809, 658, 5069, 63, 1345, 22446, 272, 9364, 275, 6275, 63, 6480, 8, 5069, 12, 13259, 12, 1011, 5173, 63, 7273, 9, 272, 6085, 275, 3278, 14, 71, 2177, 342, 272, 6085, 14, 6480, 397, 275, 6085, 14, 6480, 397, 435, 359, 6480, 61, 272, 5689, 63, 890, 275, 1390, 29316, 1590, 14, 541, 80, 8, 5069, 14, 1884, 63, 1587, 59, 85, 566, 367, 399, 315, 12083, 14, 8032, 430, 272, 9162, 275, 378, 14, 1717, 627, 5689, 63, 890, 272, 1212, 77, 63, 4904, 275, 12083, 14, 1884, 63, 1587, 59, 5069, 14, 8032, 1055, 827, 1252, 827, 342, 446, 9162, 272, 1212, 77, 63, 1961, 275, 12083, 14, 1884, 63, 1587, 59, 5069, 14, 8032, 1055, 988, 1252, 988, 342, 435, 9162, 272, 3278, 14, 8568, 4175, 8, 4175, 63, 4904, 12, 1212, 77, 63, 1961, 9, 339, 372, 6085, 12, 9364, 421, 199, 318, 6275, 63, 6480, 8, 5069, 12, 13259, 12, 1011, 5173, 63, 7273, 304, 272, 408, 272, 10560, 282, 284, 647, 2405, 603, 10613, 402, 314, 6275, 2385, 370, 506, 9080, 272, 315, 1603, 28022, 351, 3390, 8858, 339, 1803, 272, 5514, 272, 9364, 26, 282, 520, 533, 1705, 73, 647, 2405, 14, 8583, 14, 12241, 64, 9364, 3938, 339, 408, 272, 3158, 275, 12083, 63, 1650, 22957, 5173, 937, 272, 3158, 14, 873, 3682, 5173, 63, 7273, 9, 272, 340, 4550, 8, 1650, 905, 2326, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
IndonesiaX/edx-platform
cms/djangoapps/contentstore/tests/test_request_event.py
234
1654
"""Tests for CMS's requests to logs""" import mock from django.test import TestCase from django.core.urlresolvers import reverse from contentstore.views.helpers import event as cms_user_track class CMSLogTest(TestCase): """ Tests that request to logs from CMS return 204s """ def test_post_answers_to_log(self): """ Checks that student answer requests submitted to cms's "/event" url via POST are correctly returned as 204s """ requests = [ {"event": "my_event", "event_type": "my_event_type", "page": "my_page"}, {"event": "{'json': 'object'}", "event_type": unichr(512), "page": "my_page"} ] with mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_SQL_TRACKING_LOGS': True}): for request_params in requests: response = self.client.post(reverse(cms_user_track), request_params) self.assertEqual(response.status_code, 204) def test_get_answers_to_log(self): """ Checks that student answer requests submitted to cms's "/event" url via GET are correctly returned as 204s """ requests = [ {"event": "my_event", "event_type": "my_event_type", "page": "my_page"}, {"event": "{'json': 'object'}", "event_type": unichr(512), "page": "my_page"} ] with mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_SQL_TRACKING_LOGS': True}): for request_params in requests: response = self.client.get(reverse(cms_user_track), request_params) self.assertEqual(response.status_code, 204)
agpl-3.0
[ 624, 2925, 367, 29554, 1159, 4145, 370, 9610, 624, 199, 646, 1683, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 23061, 14, 4196, 14, 7546, 492, 1566, 465, 19240, 63, 751, 63, 3885, 421, 199, 533, 29554, 2445, 774, 8, 1746, 304, 272, 408, 272, 6496, 626, 1056, 370, 9610, 687, 29554, 372, 14785, 83, 272, 408, 339, 347, 511, 63, 1932, 63, 13379, 63, 475, 63, 793, 8, 277, 304, 267, 408, 267, 13813, 626, 6474, 6385, 4145, 16930, 370, 19240, 1159, 3286, 1430, 2, 1166, 267, 4799, 8761, 787, 6657, 2138, 465, 14785, 83, 267, 408, 267, 4145, 275, 359, 288, 2420, 1430, 582, 298, 1662, 63, 1430, 401, 298, 1430, 63, 466, 582, 298, 1662, 63, 1430, 63, 466, 401, 298, 1606, 582, 298, 1662, 63, 1606, 6018, 288, 2420, 1430, 582, 298, 1445, 1001, 356, 283, 785, 936, 401, 298, 1430, 63, 466, 582, 17742, 8, 7736, 395, 298, 1606, 582, 298, 1662, 63, 1606, 3570, 267, 1622, 267, 543, 1683, 14, 2068, 14, 807, 360, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 791, 8898, 63, 4657, 63, 19755, 1206, 63, 4947, 51, 356, 715, 22558, 288, 367, 1056, 63, 1162, 315, 4145, 26, 355, 1177, 275, 291, 14, 1258, 14, 1932, 8, 4471, 8, 10781, 63, 751, 63, 3885, 395, 1056, 63, 1162, 9, 355, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 14785, 9, 339, 347, 511, 63, 362, 63, 13379, 63, 475, 63, 793, 8, 277, 304, 267, 408, 267, 13813, 626, 6474, 6385, 4145, 16930, 370, 19240, 1159, 3286, 1430, 2, 1166, 267, 4799, 9576, 787, 6657, 2138, 465, 14785, 83, 267, 408, 267, 4145, 275, 359, 288, 2420, 1430, 582, 298, 1662, 63, 1430, 401, 298, 1430, 63, 466, 582, 298, 1662, 63, 1430, 63, 466, 401, 298, 1606, 582, 298, 1662, 63, 1606, 6018, 288, 2420, 1430, 582, 298, 1445, 1001, 356, 283, 785, 936, 401, 298, 1430, 63, 466, 582, 17742, 8, 7736, 395, 298, 1606, 582, 298, 1662, 63, 1606, 3570, 267, 1622, 267, 543, 1683, 14, 2068, 14, 807, 360, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 791, 8898, 63, 4657, 63, 19755, 1206, 63, 4947, 51, 356, 715, 22558, 288, 367, 1056, 63, 1162, 315, 4145, 26, 355, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 8, 10781, 63, 751, 63, 3885, 395, 1056, 63, 1162, 9, 355, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 14785, 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 ]
[ 2925, 367, 29554, 1159, 4145, 370, 9610, 624, 199, 646, 1683, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 23061, 14, 4196, 14, 7546, 492, 1566, 465, 19240, 63, 751, 63, 3885, 421, 199, 533, 29554, 2445, 774, 8, 1746, 304, 272, 408, 272, 6496, 626, 1056, 370, 9610, 687, 29554, 372, 14785, 83, 272, 408, 339, 347, 511, 63, 1932, 63, 13379, 63, 475, 63, 793, 8, 277, 304, 267, 408, 267, 13813, 626, 6474, 6385, 4145, 16930, 370, 19240, 1159, 3286, 1430, 2, 1166, 267, 4799, 8761, 787, 6657, 2138, 465, 14785, 83, 267, 408, 267, 4145, 275, 359, 288, 2420, 1430, 582, 298, 1662, 63, 1430, 401, 298, 1430, 63, 466, 582, 298, 1662, 63, 1430, 63, 466, 401, 298, 1606, 582, 298, 1662, 63, 1606, 6018, 288, 2420, 1430, 582, 298, 1445, 1001, 356, 283, 785, 936, 401, 298, 1430, 63, 466, 582, 17742, 8, 7736, 395, 298, 1606, 582, 298, 1662, 63, 1606, 3570, 267, 1622, 267, 543, 1683, 14, 2068, 14, 807, 360, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 791, 8898, 63, 4657, 63, 19755, 1206, 63, 4947, 51, 356, 715, 22558, 288, 367, 1056, 63, 1162, 315, 4145, 26, 355, 1177, 275, 291, 14, 1258, 14, 1932, 8, 4471, 8, 10781, 63, 751, 63, 3885, 395, 1056, 63, 1162, 9, 355, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 14785, 9, 339, 347, 511, 63, 362, 63, 13379, 63, 475, 63, 793, 8, 277, 304, 267, 408, 267, 13813, 626, 6474, 6385, 4145, 16930, 370, 19240, 1159, 3286, 1430, 2, 1166, 267, 4799, 9576, 787, 6657, 2138, 465, 14785, 83, 267, 408, 267, 4145, 275, 359, 288, 2420, 1430, 582, 298, 1662, 63, 1430, 401, 298, 1430, 63, 466, 582, 298, 1662, 63, 1430, 63, 466, 401, 298, 1606, 582, 298, 1662, 63, 1606, 6018, 288, 2420, 1430, 582, 298, 1445, 1001, 356, 283, 785, 936, 401, 298, 1430, 63, 466, 582, 17742, 8, 7736, 395, 298, 1606, 582, 298, 1662, 63, 1606, 3570, 267, 1622, 267, 543, 1683, 14, 2068, 14, 807, 360, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 791, 8898, 63, 4657, 63, 19755, 1206, 63, 4947, 51, 356, 715, 22558, 288, 367, 1056, 63, 1162, 315, 4145, 26, 355, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 8, 10781, 63, 751, 63, 3885, 395, 1056, 63, 1162, 9, 355, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 14785, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Kagee/youtube-dl
youtube_dl/extractor/vh1.py
199
9798
from __future__ import unicode_literals from .mtv import MTVIE import re from ..utils import fix_xml_ampersands class VH1IE(MTVIE): IE_NAME = 'vh1.com' _FEED_URL = 'http://www.vh1.com/player/embed/AS3/fullepisode/rss/' _TESTS = [{ 'url': 'http://www.vh1.com/video/metal-evolution/full-episodes/progressive-metal/1678612/playlist.jhtml', 'playlist': [ { 'md5': '7827a7505f59633983165bbd2c119b52', 'info_dict': { 'id': '731565', 'ext': 'mp4', 'title': 'Metal Evolution: Ep. 11 Act 1', 'description': 'Many rock academics have proclaimed that the truly progressive musicianship of the last 20 years has been found right here in the world of heavy metal, rather than obvious locales such as jazz, fusion or progressive rock. It stands to reason then, that much of this jaw-dropping virtuosity occurs within what\'s known as progressive metal, a genre that takes root with the likes of Rush in the \'70s, Queensryche and Fates Warning in the \'80s, and Dream Theater in the \'90s. Since then, the genre has exploded with creativity, spawning mind-bending, genre-defying acts such as Tool, Mastodon, Coheed And Cambria, Porcupine Tree, Meshuggah, A Perfect Circle and Opeth. Episode 12 looks at the extreme musicianship of these bands, as well as their often extreme literary prowess and conceptual strength, the end result being a rich level of respect and attention such challenging acts have brought upon the world of heavy metal, from a critical community usually dismissive of the form.' } }, { 'md5': '34fb4b7321c546b54deda2102a61821f', 'info_dict': { 'id': '731567', 'ext': 'mp4', 'title': 'Metal Evolution: Ep. 11 Act 2', 'description': 'Many rock academics have proclaimed that the truly progressive musicianship of the last 20 years has been found right here in the world of heavy metal, rather than obvious locales such as jazz, fusion or progressive rock. It stands to reason then, that much of this jaw-dropping virtuosity occurs within what\'s known as progressive metal, a genre that takes root with the likes of Rush in the \'70s, Queensryche and Fates Warning in the \'80s, and Dream Theater in the \'90s. Since then, the genre has exploded with creativity, spawning mind-bending, genre-defying acts such as Tool, Mastodon, Coheed And Cambria, Porcupine Tree, Meshuggah, A Perfect Circle and Opeth. Episode 11 looks at the extreme musicianship of these bands, as well as their often extreme literary prowess and conceptual strength, the end result being a rich level of respect and attention such challenging acts have brought upon the world of heavy metal, from a critical community usually dismissive of the form.' } }, { 'md5': '813f38dba4c1b8647196135ebbf7e048', 'info_dict': { 'id': '731568', 'ext': 'mp4', 'title': 'Metal Evolution: Ep. 11 Act 3', 'description': 'Many rock academics have proclaimed that the truly progressive musicianship of the last 20 years has been found right here in the world of heavy metal, rather than obvious locales such as jazz, fusion or progressive rock. It stands to reason then, that much of this jaw-dropping virtuosity occurs within what\'s known as progressive metal, a genre that takes root with the likes of Rush in the \'70s, Queensryche and Fates Warning in the \'80s, and Dream Theater in the \'90s. Since then, the genre has exploded with creativity, spawning mind-bending, genre-defying acts such as Tool, Mastodon, Coheed And Cambria, Porcupine Tree, Meshuggah, A Perfect Circle and Opeth. Episode 11 looks at the extreme musicianship of these bands, as well as their often extreme literary prowess and conceptual strength, the end result being a rich level of respect and attention such challenging acts have brought upon the world of heavy metal, from a critical community usually dismissive of the form.' } }, { 'md5': '51adb72439dfaed11c799115d76e497f', 'info_dict': { 'id': '731569', 'ext': 'mp4', 'title': 'Metal Evolution: Ep. 11 Act 4', 'description': 'Many rock academics have proclaimed that the truly progressive musicianship of the last 20 years has been found right here in the world of heavy metal, rather than obvious locales such as jazz, fusion or progressive rock. It stands to reason then, that much of this jaw-dropping virtuosity occurs within what\'s known as progressive metal, a genre that takes root with the likes of Rush in the \'70s, Queensryche and Fates Warning in the \'80s, and Dream Theater in the \'90s. Since then, the genre has exploded with creativity, spawning mind-bending, genre-defying acts such as Tool, Mastodon, Coheed And Cambria, Porcupine Tree, Meshuggah, A Perfect Circle and Opeth. Episode 11 looks at the extreme musicianship of these bands, as well as their often extreme literary prowess and conceptual strength, the end result being a rich level of respect and attention such challenging acts have brought upon the world of heavy metal, from a critical community usually dismissive of the form.' } }, { 'md5': '93d554aaf79320703b73a95288c76a6e', 'info_dict': { 'id': '731570', 'ext': 'mp4', 'title': 'Metal Evolution: Ep. 11 Act 5', 'description': 'Many rock academics have proclaimed that the truly progressive musicianship of the last 20 years has been found right here in the world of heavy metal, rather than obvious locales such as jazz, fusion or progressive rock. It stands to reason then, that much of this jaw-dropping virtuosity occurs within what\'s known as progressive metal, a genre that takes root with the likes of Rush in the \'70s, Queensryche and Fates Warning in the \'80s, and Dream Theater in the \'90s. Since then, the genre has exploded with creativity, spawning mind-bending, genre-defying acts such as Tool, Mastodon, Coheed And Cambria, Porcupine Tree, Meshuggah, A Perfect Circle and Opeth. Episode 11 looks at the extreme musicianship of these bands, as well as their often extreme literary prowess and conceptual strength, the end result being a rich level of respect and attention such challenging acts have brought upon the world of heavy metal, from a critical community usually dismissive of the form.' } } ], 'skip': 'Blocked outside the US', }, { # Clip 'url': 'http://www.vh1.com/video/misc/706675/metal-evolution-episode-1-pre-metal-show-clip.jhtml#id=1674118', 'md5': '7d67cf6d9cdc6b4f3d3ac97a55403844', 'info_dict': { 'id': '706675', 'ext': 'mp4', 'title': 'Metal Evolution: Episode 1 Pre-Metal Show Clip', 'description': 'The greatest documentary ever made about Heavy Metal begins as our host Sam Dunn travels the globe to seek out the origins and influences that helped create Heavy Metal. Sam speaks to legends like Kirk Hammett, Alice Cooper, Slash, Bill Ward, Geezer Butler, Tom Morello, Ace Frehley, Lemmy Kilmister, Dave Davies, and many many more. This episode is the prologue for the 11 hour series, and Sam goes back to the very beginning to reveal how Heavy Metal was created.' }, 'skip': 'Blocked outside the US', }, { # Short link 'url': 'http://www.vh1.com/video/play.jhtml?id=1678353', 'md5': '853192b87ad978732b67dd8e549b266a', 'info_dict': { 'id': '730355', 'ext': 'mp4', 'title': 'Metal Evolution: Episode 11 Progressive Metal Sneak', 'description': 'In Metal Evolution\'s finale sneak, Sam sits with Michael Giles of King Crimson and gets feedback from Metallica guitarist Kirk Hammett on why the group was influential.' }, 'skip': 'Blocked outside the US', }, { 'url': 'http://www.vh1.com/video/macklemore-ryan-lewis/900535/cant-hold-us-ft-ray-dalton.jhtml', 'md5': 'b1bcb5b4380c9d7f544065589432dee7', 'info_dict': { 'id': '900535', 'ext': 'mp4', 'title': 'Macklemore & Ryan Lewis - "Can\'t Hold Us ft. Ray Dalton"', 'description': 'The Heist' }, 'skip': 'Blocked outside the US', }] _VALID_URL = r'''(?x) https?://www\.vh1\.com/video/ (?: .+?/full-episodes/.+?/(?P<playlist_id>[^/]+)/playlist\.jhtml | (?: play.jhtml\?id=| misc/.+?/.+?\.jhtml\#id= ) (?P<video_id>[0-9]+)$ | [^/]+/(?P<music_id>[0-9]+)/[^/]+? ) ''' def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) if mobj.group('music_id'): id_field = 'vid' video_id = mobj.group('music_id') else: video_id = mobj.group('playlist_id') or mobj.group('video_id') id_field = 'id' doc_url = '%s?%s=%s' % (self._FEED_URL, id_field, video_id) idoc = self._download_xml( doc_url, video_id, 'Downloading info', transform_source=fix_xml_ampersands) return self.playlist_result( [self._get_video_info(item) for item in idoc.findall('.//item')], playlist_id=video_id, )
unlicense
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2037, 86, 492, 603, 12764, 4332, 199, 199, 646, 295, 199, 504, 2508, 1208, 492, 5325, 63, 1652, 63, 5282, 1192, 5915, 421, 199, 533, 812, 40, 17, 4332, 8, 5747, 54, 4332, 304, 272, 15292, 63, 2339, 275, 283, 20369, 17, 14, 957, 7, 272, 485, 18068, 63, 2632, 275, 283, 1014, 921, 1544, 14, 20369, 17, 14, 957, 15, 6147, 15, 6427, 15, 1179, 19, 15, 1893, 274, 80, 6045, 15, 13614, 4805, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 20369, 17, 14, 957, 15, 3722, 15, 22420, 13, 6857, 3347, 15, 2861, 13, 22027, 15, 6595, 470, 3398, 13, 22420, 15, 10806, 1184, 713, 15, 10411, 14, 74, 1360, 297, 267, 283, 10411, 356, 359, 288, 469, 355, 283, 1064, 21, 356, 283, 2277, 1465, 65, 23, 13938, 70, 15112, 11870, 2658, 10355, 32737, 18, 67, 7119, 66, 2528, 297, 355, 283, 815, 63, 807, 356, 469, 490, 283, 344, 356, 283, 2898, 1046, 2182, 297, 490, 283, 832, 356, 283, 311, 20, 297, 490, 283, 1213, 356, 283, 4015, 279, 662, 86, 3347, 26, 27255, 14, 4119, 18982, 413, 297, 490, 283, 1802, 356, 283, 4089, 882, 346, 282, 9490, 77, 2932, 1172, 557, 31563, 626, 314, 5651, 21797, 557, 25787, 8504, 338, 559, 290, 3319, 402, 314, 2061, 3388, 17399, 965, 2757, 1911, 2451, 2348, 315, 314, 6701, 402, 946, 22421, 7647, 279, 12, 7830, 2419, 25259, 24847, 4066, 465, 1335, 65, 4348, 12, 289, 12444, 503, 557, 25787, 882, 346, 14, 2779, 410, 5915, 370, 4499, 2066, 12, 626, 8298, 402, 642, 1335, 10084, 13, 17264, 3637, 12043, 13780, 3677, 11058, 4453, 4052, 3985, 83, 6040, 465, 557, 25787, 7647, 279, 12, 282, 28749, 626, 6181, 1738, 543, 314, 1212, 9246, 402, 820, 2084, 315, 314, 8891, 2760, 83, 12, 1413, 310, 8764, 651, 595, 436, 481, 2335, 15902, 315, 314, 8891, 1257, 83, 12, 436, 577, 1091, 710, 6618, 315, 314, 8891, 2710, 83, 14, 9336, 2066, 12, 314, 28749, 965, 15868, 770, 543, 2837, 2159, 18936, 12, 5844, 87, 1835, 25169, 13, 66, 3219, 12, 28749, 13, 318, 22440, 17795, 4066, 465, 15650, 12, 603, 1810, 364, 265, 12, 1849, 426, 379, 6061, 445, 455, 9660, 65, 12, 510, 269, 17500, 1132, 12178, 12, 603, 10613, 1518, 5294, 72, 12, 437, 31778, 449, 445, 12571, 436, 593, 321, 273, 14, 27255, 6045, 3144, 10734, 737, 314, 30503, 8504, 338, 559, 290, 3319, 402, 3520, 30565, 12, 465, 5521, 465, 3932, 14115, 30503, 7142, 695, 557, 1129, 385, 436, 19834, 1061, 410, 15796, 12, 314, 1284, 754, 3769, 282, 30162, 2166, 402, 14021, 436, 22814, 4066, 682, 7670, 1540, 17795, 1172, 330, 7930, 913, 12188, 314, 6701, 402, 946, 22421, 7647, 279, 12, 687, 282, 19698, 23633, 9987, 2153, 32237, 402, 314, 1824, 3530, 355, 789, 288, 1660, 288, 469, 355, 283, 1064, 21, 356, 283, 1082, 4675, 20, 66, 23, 12638, 67, 18163, 66, 1477, 770, 65, 18, 7759, 65, 31872, 2025, 70, 297, 355, 283, 815, 63, 807, 356, 469, 490, 283, 344, 356, 283, 2898, 1046, 1822, 297, 490, 283, 832, 356, 283, 311, 20, 297, 490, 283, 1213, 356, 283, 4015, 279, 662, 86, 3347, 26, 27255, 14, 4119, 18982, 499, 297, 490, 283, 1802, 356, 283, 4089, 882, 346, 282, 9490, 77, 2932, 1172, 557, 31563, 626, 314, 5651, 21797, 557, 25787, 8504, 338, 559, 290, 3319, 402, 314, 2061, 3388, 17399, 965, 2757, 1911, 2451, 2348, 315, 314, 6701, 402, 946, 22421, 7647, 279, 12, 7830, 2419, 25259, 24847, 4066, 465, 1335, 65, 4348, 12, 289, 12444, 503, 557, 25787, 882, 346, 14, 2779, 410, 5915, 370, 4499, 2066, 12, 626, 8298, 402, 642, 1335, 10084, 13, 17264, 3637, 12043, 13780, 3677, 11058, 4453, 4052, 3985, 83, 6040, 465, 557, 25787, 7647, 279, 12, 282, 28749, 626, 6181, 1738, 543, 314, 1212, 9246, 402, 820, 2084, 315, 314, 8891, 2760, 83, 12, 1413, 310, 8764, 651, 595, 436, 481, 2335, 15902, 315, 314, 8891, 1257, 83, 12, 436, 577, 1091, 710, 6618, 315, 314, 8891, 2710, 83, 14, 9336, 2066, 12, 314, 28749, 965, 15868, 770, 543, 2837, 2159, 18936, 12, 5844, 87, 1835, 25169, 13, 66, 3219, 12, 28749, 13, 318, 22440, 17795, 4066, 465, 15650, 12, 603, 1810, 364, 265, 12, 1849, 426, 379, 6061, 445, 455, 9660, 65, 12, 510, 269, 17500, 1132, 12178, 12, 603, 10613, 1518, 5294, 72, 12, 437, 31778, 449, 445, 12571, 436, 593, 321, 273, 14, 27255, 6045, 4119, 10734, 737, 314, 30503, 8504, 338, 559, 290, 3319, 402, 3520, 30565, 12, 465, 5521, 465, 3932, 14115, 30503, 7142, 695, 557, 1129, 385, 436, 19834, 1061, 410, 15796, 12, 314, 1284, 754, 3769, 282, 30162, 2166, 402, 14021, 436, 22814, 4066, 682, 7670, 1540, 17795, 1172, 330, 7930, 913, 12188, 314, 6701, 402, 946, 22421, 7647, 279, 12, 687, 282, 19698, 23633, 9987, 2153, 32237, 402, 314, 1824, 3530, 355, 789, 288, 1660, 288, 469, 355, 283, 1064, 21, 356, 283, 24, 969, 70, 1703, 27634, 20, 67, 17, 66, 24, 8557, 10800, 8312, 69, 31319, 23, 69, 9941, 297, 355, 283, 815, 63, 807, 356, 469, 490, 283, 344, 356, 283, 2898, 1046, 2333, 297, 490, 283, 832, 356, 283, 311, 20, 297, 490, 283, 1213, 356, 283, 4015, 279, 662, 86, 3347, 26, 27255, 14, 4119, 18982, 650, 297, 490, 283, 1802, 356, 283, 4089, 882, 346, 282, 9490, 77, 2932, 1172, 557, 31563, 626, 314, 5651, 21797, 557, 25787, 8504, 338, 559, 290, 3319, 402, 314, 2061, 3388, 17399, 965, 2757, 1911, 2451, 2348, 315, 314, 6701, 402, 946, 22421, 7647, 279, 12, 7830, 2419, 25259, 24847, 4066, 465, 1335, 65, 4348, 12, 289, 12444, 503, 557, 25787, 882, 346, 14, 2779, 410, 5915, 370, 4499, 2066, 12, 626, 8298, 402, 642, 1335, 10084, 13, 17264, 3637, 12043, 13780, 3677, 11058, 4453, 4052, 3985, 83, 6040, 465, 557, 25787, 7647, 279, 12, 282, 28749, 626, 6181, 1738, 543, 314, 1212, 9246, 402, 820, 2084, 315, 314, 8891, 2760, 83, 12, 1413, 310, 8764, 651, 595, 436, 481, 2335, 15902, 315, 314 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2037, 86, 492, 603, 12764, 4332, 199, 199, 646, 295, 199, 504, 2508, 1208, 492, 5325, 63, 1652, 63, 5282, 1192, 5915, 421, 199, 533, 812, 40, 17, 4332, 8, 5747, 54, 4332, 304, 272, 15292, 63, 2339, 275, 283, 20369, 17, 14, 957, 7, 272, 485, 18068, 63, 2632, 275, 283, 1014, 921, 1544, 14, 20369, 17, 14, 957, 15, 6147, 15, 6427, 15, 1179, 19, 15, 1893, 274, 80, 6045, 15, 13614, 4805, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 20369, 17, 14, 957, 15, 3722, 15, 22420, 13, 6857, 3347, 15, 2861, 13, 22027, 15, 6595, 470, 3398, 13, 22420, 15, 10806, 1184, 713, 15, 10411, 14, 74, 1360, 297, 267, 283, 10411, 356, 359, 288, 469, 355, 283, 1064, 21, 356, 283, 2277, 1465, 65, 23, 13938, 70, 15112, 11870, 2658, 10355, 32737, 18, 67, 7119, 66, 2528, 297, 355, 283, 815, 63, 807, 356, 469, 490, 283, 344, 356, 283, 2898, 1046, 2182, 297, 490, 283, 832, 356, 283, 311, 20, 297, 490, 283, 1213, 356, 283, 4015, 279, 662, 86, 3347, 26, 27255, 14, 4119, 18982, 413, 297, 490, 283, 1802, 356, 283, 4089, 882, 346, 282, 9490, 77, 2932, 1172, 557, 31563, 626, 314, 5651, 21797, 557, 25787, 8504, 338, 559, 290, 3319, 402, 314, 2061, 3388, 17399, 965, 2757, 1911, 2451, 2348, 315, 314, 6701, 402, 946, 22421, 7647, 279, 12, 7830, 2419, 25259, 24847, 4066, 465, 1335, 65, 4348, 12, 289, 12444, 503, 557, 25787, 882, 346, 14, 2779, 410, 5915, 370, 4499, 2066, 12, 626, 8298, 402, 642, 1335, 10084, 13, 17264, 3637, 12043, 13780, 3677, 11058, 4453, 4052, 3985, 83, 6040, 465, 557, 25787, 7647, 279, 12, 282, 28749, 626, 6181, 1738, 543, 314, 1212, 9246, 402, 820, 2084, 315, 314, 8891, 2760, 83, 12, 1413, 310, 8764, 651, 595, 436, 481, 2335, 15902, 315, 314, 8891, 1257, 83, 12, 436, 577, 1091, 710, 6618, 315, 314, 8891, 2710, 83, 14, 9336, 2066, 12, 314, 28749, 965, 15868, 770, 543, 2837, 2159, 18936, 12, 5844, 87, 1835, 25169, 13, 66, 3219, 12, 28749, 13, 318, 22440, 17795, 4066, 465, 15650, 12, 603, 1810, 364, 265, 12, 1849, 426, 379, 6061, 445, 455, 9660, 65, 12, 510, 269, 17500, 1132, 12178, 12, 603, 10613, 1518, 5294, 72, 12, 437, 31778, 449, 445, 12571, 436, 593, 321, 273, 14, 27255, 6045, 3144, 10734, 737, 314, 30503, 8504, 338, 559, 290, 3319, 402, 3520, 30565, 12, 465, 5521, 465, 3932, 14115, 30503, 7142, 695, 557, 1129, 385, 436, 19834, 1061, 410, 15796, 12, 314, 1284, 754, 3769, 282, 30162, 2166, 402, 14021, 436, 22814, 4066, 682, 7670, 1540, 17795, 1172, 330, 7930, 913, 12188, 314, 6701, 402, 946, 22421, 7647, 279, 12, 687, 282, 19698, 23633, 9987, 2153, 32237, 402, 314, 1824, 3530, 355, 789, 288, 1660, 288, 469, 355, 283, 1064, 21, 356, 283, 1082, 4675, 20, 66, 23, 12638, 67, 18163, 66, 1477, 770, 65, 18, 7759, 65, 31872, 2025, 70, 297, 355, 283, 815, 63, 807, 356, 469, 490, 283, 344, 356, 283, 2898, 1046, 1822, 297, 490, 283, 832, 356, 283, 311, 20, 297, 490, 283, 1213, 356, 283, 4015, 279, 662, 86, 3347, 26, 27255, 14, 4119, 18982, 499, 297, 490, 283, 1802, 356, 283, 4089, 882, 346, 282, 9490, 77, 2932, 1172, 557, 31563, 626, 314, 5651, 21797, 557, 25787, 8504, 338, 559, 290, 3319, 402, 314, 2061, 3388, 17399, 965, 2757, 1911, 2451, 2348, 315, 314, 6701, 402, 946, 22421, 7647, 279, 12, 7830, 2419, 25259, 24847, 4066, 465, 1335, 65, 4348, 12, 289, 12444, 503, 557, 25787, 882, 346, 14, 2779, 410, 5915, 370, 4499, 2066, 12, 626, 8298, 402, 642, 1335, 10084, 13, 17264, 3637, 12043, 13780, 3677, 11058, 4453, 4052, 3985, 83, 6040, 465, 557, 25787, 7647, 279, 12, 282, 28749, 626, 6181, 1738, 543, 314, 1212, 9246, 402, 820, 2084, 315, 314, 8891, 2760, 83, 12, 1413, 310, 8764, 651, 595, 436, 481, 2335, 15902, 315, 314, 8891, 1257, 83, 12, 436, 577, 1091, 710, 6618, 315, 314, 8891, 2710, 83, 14, 9336, 2066, 12, 314, 28749, 965, 15868, 770, 543, 2837, 2159, 18936, 12, 5844, 87, 1835, 25169, 13, 66, 3219, 12, 28749, 13, 318, 22440, 17795, 4066, 465, 15650, 12, 603, 1810, 364, 265, 12, 1849, 426, 379, 6061, 445, 455, 9660, 65, 12, 510, 269, 17500, 1132, 12178, 12, 603, 10613, 1518, 5294, 72, 12, 437, 31778, 449, 445, 12571, 436, 593, 321, 273, 14, 27255, 6045, 4119, 10734, 737, 314, 30503, 8504, 338, 559, 290, 3319, 402, 3520, 30565, 12, 465, 5521, 465, 3932, 14115, 30503, 7142, 695, 557, 1129, 385, 436, 19834, 1061, 410, 15796, 12, 314, 1284, 754, 3769, 282, 30162, 2166, 402, 14021, 436, 22814, 4066, 682, 7670, 1540, 17795, 1172, 330, 7930, 913, 12188, 314, 6701, 402, 946, 22421, 7647, 279, 12, 687, 282, 19698, 23633, 9987, 2153, 32237, 402, 314, 1824, 3530, 355, 789, 288, 1660, 288, 469, 355, 283, 1064, 21, 356, 283, 24, 969, 70, 1703, 27634, 20, 67, 17, 66, 24, 8557, 10800, 8312, 69, 31319, 23, 69, 9941, 297, 355, 283, 815, 63, 807, 356, 469, 490, 283, 344, 356, 283, 2898, 1046, 2333, 297, 490, 283, 832, 356, 283, 311, 20, 297, 490, 283, 1213, 356, 283, 4015, 279, 662, 86, 3347, 26, 27255, 14, 4119, 18982, 650, 297, 490, 283, 1802, 356, 283, 4089, 882, 346, 282, 9490, 77, 2932, 1172, 557, 31563, 626, 314, 5651, 21797, 557, 25787, 8504, 338, 559, 290, 3319, 402, 314, 2061, 3388, 17399, 965, 2757, 1911, 2451, 2348, 315, 314, 6701, 402, 946, 22421, 7647, 279, 12, 7830, 2419, 25259, 24847, 4066, 465, 1335, 65, 4348, 12, 289, 12444, 503, 557, 25787, 882, 346, 14, 2779, 410, 5915, 370, 4499, 2066, 12, 626, 8298, 402, 642, 1335, 10084, 13, 17264, 3637, 12043, 13780, 3677, 11058, 4453, 4052, 3985, 83, 6040, 465, 557, 25787, 7647, 279, 12, 282, 28749, 626, 6181, 1738, 543, 314, 1212, 9246, 402, 820, 2084, 315, 314, 8891, 2760, 83, 12, 1413, 310, 8764, 651, 595, 436, 481, 2335, 15902, 315, 314, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
eXcomm/cjdns
node_build/dependencies/libuv/build/gyp/test/rules/gyptest-all.py
221
1753
#!/usr/bin/env python # Copyright (c) 2011 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ Verifies simple rules when using an explicit build target of 'all'. """ import TestGyp test = TestGyp.TestGyp() test.run_gyp('no_action_with_rules_fails.gyp', chdir='src/noaction', status=1, stderr=None) test.run_gyp('actions.gyp', chdir='src') test.relocate('src', 'relocate/src') test.build('actions.gyp', test.ALL, chdir='relocate/src') expect = """\ Hello from program.c Hello from function1.in Hello from function2.in """ if test.format == 'xcode': chdir = 'relocate/src/subdir1' else: chdir = 'relocate/src' test.run_built_executable('program', chdir=chdir, stdout=expect) expect = """\ Hello from program.c Hello from function3.in """ if test.format == 'xcode': chdir = 'relocate/src/subdir3' else: chdir = 'relocate/src' test.run_built_executable('program2', chdir=chdir, stdout=expect) test.must_match('relocate/src/subdir2/file1.out', 'Hello from file1.in\n') test.must_match('relocate/src/subdir2/file2.out', 'Hello from file2.in\n') test.must_match('relocate/src/subdir2/file1.out2', 'Hello from file1.in\n') test.must_match('relocate/src/subdir2/file2.out2', 'Hello from file2.in\n') test.must_match('relocate/src/external/file1.external_rules.out', 'Hello from file1.in\n') test.must_match('relocate/src/external/file2.external_rules.out', 'Hello from file2.in\n') expect = """\ Hello from program.c Got 41. """ if test.format == 'xcode': chdir = 'relocate/src/subdir4' else: chdir = 'relocate/src' test.run_built_executable('program4', chdir=chdir, stdout=expect) test.pass_test()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 7760, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 21168, 3486, 4713, 1380, 1808, 376, 5027, 1900, 1347, 402, 283, 452, 1370, 199, 624, 199, 199, 646, 25688, 199, 199, 396, 275, 25688, 14, 774, 13899, 342, 199, 199, 396, 14, 1065, 63, 6179, 360, 889, 63, 1287, 63, 1045, 63, 4423, 63, 15762, 14, 6179, 297, 13097, 534, 2164, 15, 889, 1287, 297, 2004, 29, 17, 12, 1467, 4635, 29, 403, 9, 199, 199, 396, 14, 1065, 63, 6179, 360, 3723, 14, 6179, 297, 13097, 534, 2164, 358, 199, 199, 396, 14, 18919, 360, 2164, 297, 283, 18919, 15, 2164, 358, 199, 199, 396, 14, 1506, 360, 3723, 14, 6179, 297, 511, 14, 1761, 12, 13097, 534, 18919, 15, 2164, 358, 199, 199, 4921, 275, 9638, 199, 6257, 687, 2240, 14, 67, 199, 6257, 687, 805, 17, 14, 262, 199, 6257, 687, 805, 18, 14, 262, 199, 624, 199, 199, 692, 511, 14, 908, 508, 283, 8701, 356, 523, 13097, 275, 283, 18919, 15, 2164, 15, 10622, 17, 7, 199, 2836, 26, 523, 13097, 275, 283, 18919, 15, 2164, 7, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 6815, 297, 13097, 29, 8563, 12, 3839, 29, 4921, 9, 199, 199, 4921, 275, 9638, 199, 6257, 687, 2240, 14, 67, 199, 6257, 687, 805, 19, 14, 262, 199, 624, 199, 199, 692, 511, 14, 908, 508, 283, 8701, 356, 523, 13097, 275, 283, 18919, 15, 2164, 15, 10622, 19, 7, 199, 2836, 26, 523, 13097, 275, 283, 18919, 15, 2164, 7, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 6815, 18, 297, 13097, 29, 8563, 12, 3839, 29, 4921, 9, 199, 199, 396, 14, 7790, 63, 1431, 360, 18919, 15, 2164, 15, 10622, 18, 15, 493, 17, 14, 548, 297, 283, 6257, 687, 570, 17, 14, 262, 60, 78, 358, 199, 396, 14, 7790, 63, 1431, 360, 18919, 15, 2164, 15, 10622, 18, 15, 493, 18, 14, 548, 297, 283, 6257, 687, 570, 18, 14, 262, 60, 78, 358, 199, 199, 396, 14, 7790, 63, 1431, 360, 18919, 15, 2164, 15, 10622, 18, 15, 493, 17, 14, 548, 18, 297, 283, 6257, 687, 570, 17, 14, 262, 60, 78, 358, 199, 396, 14, 7790, 63, 1431, 360, 18919, 15, 2164, 15, 10622, 18, 15, 493, 18, 14, 548, 18, 297, 283, 6257, 687, 570, 18, 14, 262, 60, 78, 358, 199, 199, 396, 14, 7790, 63, 1431, 360, 18919, 15, 2164, 15, 5159, 15, 493, 17, 14, 5159, 63, 4423, 14, 548, 297, 355, 283, 6257, 687, 570, 17, 14, 262, 60, 78, 358, 199, 396, 14, 7790, 63, 1431, 360, 18919, 15, 2164, 15, 5159, 15, 493, 18, 14, 5159, 63, 4423, 14, 548, 297, 355, 283, 6257, 687, 570, 18, 14, 262, 60, 78, 358, 199, 199, 4921, 275, 9638, 199, 6257, 687, 2240, 14, 67, 199, 13662, 13385, 14, 199, 624, 199, 199, 692, 511, 14, 908, 508, 283, 8701, 356, 523, 13097, 275, 283, 18919, 15, 2164, 15, 10622, 20, 7, 199, 2836, 26, 523, 13097, 275, 283, 18919, 15, 2164, 7, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 6815, 20, 297, 13097, 29, 8563, 12, 3839, 29, 4921, 9, 199, 199, 396, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 7760, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 21168, 3486, 4713, 1380, 1808, 376, 5027, 1900, 1347, 402, 283, 452, 1370, 199, 624, 199, 199, 646, 25688, 199, 199, 396, 275, 25688, 14, 774, 13899, 342, 199, 199, 396, 14, 1065, 63, 6179, 360, 889, 63, 1287, 63, 1045, 63, 4423, 63, 15762, 14, 6179, 297, 13097, 534, 2164, 15, 889, 1287, 297, 2004, 29, 17, 12, 1467, 4635, 29, 403, 9, 199, 199, 396, 14, 1065, 63, 6179, 360, 3723, 14, 6179, 297, 13097, 534, 2164, 358, 199, 199, 396, 14, 18919, 360, 2164, 297, 283, 18919, 15, 2164, 358, 199, 199, 396, 14, 1506, 360, 3723, 14, 6179, 297, 511, 14, 1761, 12, 13097, 534, 18919, 15, 2164, 358, 199, 199, 4921, 275, 9638, 199, 6257, 687, 2240, 14, 67, 199, 6257, 687, 805, 17, 14, 262, 199, 6257, 687, 805, 18, 14, 262, 199, 624, 199, 199, 692, 511, 14, 908, 508, 283, 8701, 356, 523, 13097, 275, 283, 18919, 15, 2164, 15, 10622, 17, 7, 199, 2836, 26, 523, 13097, 275, 283, 18919, 15, 2164, 7, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 6815, 297, 13097, 29, 8563, 12, 3839, 29, 4921, 9, 199, 199, 4921, 275, 9638, 199, 6257, 687, 2240, 14, 67, 199, 6257, 687, 805, 19, 14, 262, 199, 624, 199, 199, 692, 511, 14, 908, 508, 283, 8701, 356, 523, 13097, 275, 283, 18919, 15, 2164, 15, 10622, 19, 7, 199, 2836, 26, 523, 13097, 275, 283, 18919, 15, 2164, 7, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 6815, 18, 297, 13097, 29, 8563, 12, 3839, 29, 4921, 9, 199, 199, 396, 14, 7790, 63, 1431, 360, 18919, 15, 2164, 15, 10622, 18, 15, 493, 17, 14, 548, 297, 283, 6257, 687, 570, 17, 14, 262, 60, 78, 358, 199, 396, 14, 7790, 63, 1431, 360, 18919, 15, 2164, 15, 10622, 18, 15, 493, 18, 14, 548, 297, 283, 6257, 687, 570, 18, 14, 262, 60, 78, 358, 199, 199, 396, 14, 7790, 63, 1431, 360, 18919, 15, 2164, 15, 10622, 18, 15, 493, 17, 14, 548, 18, 297, 283, 6257, 687, 570, 17, 14, 262, 60, 78, 358, 199, 396, 14, 7790, 63, 1431, 360, 18919, 15, 2164, 15, 10622, 18, 15, 493, 18, 14, 548, 18, 297, 283, 6257, 687, 570, 18, 14, 262, 60, 78, 358, 199, 199, 396, 14, 7790, 63, 1431, 360, 18919, 15, 2164, 15, 5159, 15, 493, 17, 14, 5159, 63, 4423, 14, 548, 297, 355, 283, 6257, 687, 570, 17, 14, 262, 60, 78, 358, 199, 396, 14, 7790, 63, 1431, 360, 18919, 15, 2164, 15, 5159, 15, 493, 18, 14, 5159, 63, 4423, 14, 548, 297, 355, 283, 6257, 687, 570, 18, 14, 262, 60, 78, 358, 199, 199, 4921, 275, 9638, 199, 6257, 687, 2240, 14, 67, 199, 13662, 13385, 14, 199, 624, 199, 199, 692, 511, 14, 908, 508, 283, 8701, 356, 523, 13097, 275, 283, 18919, 15, 2164, 15, 10622, 20, 7, 199, 2836, 26, 523, 13097, 275, 283, 18919, 15, 2164, 7, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 6815, 20, 297, 13097, 29, 8563, 12, 3839, 29, 4921, 9, 199, 199, 396, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Triv90/Heat
heat/tests/test_parameters.py
1
12606
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # 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 unittest from nose.plugins.attrib import attr import json from heat.engine import parameters @attr(tag=['unit', 'parameters']) @attr(speed='fast') class ParameterTest(unittest.TestCase): def test_new_string(self): p = parameters.Parameter('p', {'Type': 'String'}) self.assertTrue(isinstance(p, parameters.StringParam)) def test_new_number(self): p = parameters.Parameter('p', {'Type': 'Number'}) self.assertTrue(isinstance(p, parameters.NumberParam)) def test_new_list(self): p = parameters.Parameter('p', {'Type': 'CommaDelimitedList'}) self.assertTrue(isinstance(p, parameters.CommaDelimitedListParam)) def test_new_bad_type(self): self.assertRaises(ValueError, parameters.Parameter, 'p', {'Type': 'List'}) def test_new_no_type(self): self.assertRaises(KeyError, parameters.Parameter, 'p', {'Default': 'blarg'}) def test_default_no_override(self): p = parameters.Parameter('defaulted', {'Type': 'String', 'Default': 'blarg'}) self.assertTrue(p.has_default()) self.assertEqual(p.default(), 'blarg') self.assertEqual(p.value(), 'blarg') def test_default_override(self): p = parameters.Parameter('defaulted', {'Type': 'String', 'Default': 'blarg'}, 'wibble') self.assertTrue(p.has_default()) self.assertEqual(p.default(), 'blarg') self.assertEqual(p.value(), 'wibble') def test_default_invalid(self): schema = {'Type': 'String', 'AllowedValues': ['foo'], 'ConstraintDescription': 'wibble', 'Default': 'bar'} try: parameters.Parameter('p', schema, 'foo') except ValueError as ve: msg = str(ve) self.assertNotEqual(msg.find('wibble'), -1) else: self.fail('ValueError not raised') def test_no_echo_true(self): p = parameters.Parameter('anechoic', {'Type': 'String', 'NoEcho': 'true'}, 'wibble') self.assertTrue(p.no_echo()) self.assertNotEqual(str(p), 'wibble') def test_no_echo_true_caps(self): p = parameters.Parameter('anechoic', {'Type': 'String', 'NoEcho': 'TrUe'}, 'wibble') self.assertTrue(p.no_echo()) self.assertNotEqual(str(p), 'wibble') def test_no_echo_false(self): p = parameters.Parameter('echoic', {'Type': 'String', 'NoEcho': 'false'}, 'wibble') self.assertFalse(p.no_echo()) self.assertEqual(str(p), 'wibble') def test_description(self): description = 'Description of the parameter' p = parameters.Parameter('p', {'Type': 'String', 'Description': description}) self.assertEqual(p.description(), description) def test_no_description(self): p = parameters.Parameter('p', {'Type': 'String'}) self.assertEqual(p.description(), '') def test_string_len_good(self): schema = {'Type': 'String', 'MinLength': '3', 'MaxLength': '3'} p = parameters.Parameter('p', schema, 'foo') self.assertEqual(p.value(), 'foo') def test_string_underflow(self): schema = {'Type': 'String', 'ConstraintDescription': 'wibble', 'MinLength': '4'} try: parameters.Parameter('p', schema, 'foo') except ValueError as ve: msg = str(ve) self.assertNotEqual(msg.find('wibble'), -1) else: self.fail('ValueError not raised') def test_string_overflow(self): schema = {'Type': 'String', 'ConstraintDescription': 'wibble', 'MaxLength': '2'} try: parameters.Parameter('p', schema, 'foo') except ValueError as ve: msg = str(ve) self.assertNotEqual(msg.find('wibble'), -1) else: self.fail('ValueError not raised') def test_string_pattern_good(self): schema = {'Type': 'String', 'AllowedPattern': '[a-z]*'} p = parameters.Parameter('p', schema, 'foo') self.assertEqual(p.value(), 'foo') def test_string_pattern_bad_prefix(self): schema = {'Type': 'String', 'ConstraintDescription': 'wibble', 'AllowedPattern': '[a-z]*'} try: parameters.Parameter('p', schema, '1foo') except ValueError as ve: msg = str(ve) self.assertNotEqual(msg.find('wibble'), -1) else: self.fail('ValueError not raised') def test_string_pattern_bad_suffix(self): schema = {'Type': 'String', 'ConstraintDescription': 'wibble', 'AllowedPattern': '[a-z]*'} try: parameters.Parameter('p', schema, 'foo1') except ValueError as ve: msg = str(ve) self.assertNotEqual(msg.find('wibble'), -1) else: self.fail('ValueError not raised') def test_string_value_list_good(self): schema = {'Type': 'String', 'AllowedValues': ['foo', 'bar', 'baz']} p = parameters.Parameter('p', schema, 'bar') self.assertEqual(p.value(), 'bar') def test_string_value_list_bad(self): schema = {'Type': 'String', 'ConstraintDescription': 'wibble', 'AllowedValues': ['foo', 'bar', 'baz']} try: parameters.Parameter('p', schema, 'blarg') except ValueError as ve: msg = str(ve) self.assertNotEqual(msg.find('wibble'), -1) else: self.fail('ValueError not raised') def test_number_int_good(self): schema = {'Type': 'Number', 'MinValue': '3', 'MaxValue': '3'} p = parameters.Parameter('p', schema, '3') self.assertEqual(p.value(), '3') def test_number_float_good(self): schema = {'Type': 'Number', 'MinValue': '3.0', 'MaxValue': '3.0'} p = parameters.Parameter('p', schema, '3.0') self.assertEqual(p.value(), '3.0') def test_number_low(self): schema = {'Type': 'Number', 'ConstraintDescription': 'wibble', 'MinValue': '4'} try: parameters.Parameter('p', schema, '3') except ValueError as ve: msg = str(ve) self.assertNotEqual(msg.find('wibble'), -1) else: self.fail('ValueError not raised') def test_number_high(self): schema = {'Type': 'Number', 'ConstraintDescription': 'wibble', 'MaxValue': '2'} try: parameters.Parameter('p', schema, '3') except ValueError as ve: msg = str(ve) self.assertNotEqual(msg.find('wibble'), -1) else: self.fail('ValueError not raised') def test_number_value_list_good(self): schema = {'Type': 'Number', 'AllowedValues': ['1', '3', '5']} p = parameters.Parameter('p', schema, '5') self.assertEqual(p.value(), '5') def test_number_value_list_bad(self): schema = {'Type': 'Number', 'ConstraintDescription': 'wibble', 'AllowedValues': ['1', '3', '5']} try: parameters.Parameter('p', schema, '2') except ValueError as ve: msg = str(ve) self.assertNotEqual(msg.find('wibble'), -1) else: self.fail('ValueError not raised') def test_list_value_list_good(self): schema = {'Type': 'CommaDelimitedList', 'AllowedValues': ['foo', 'bar', 'baz']} p = parameters.Parameter('p', schema, 'baz,foo,bar') self.assertEqual(p.value(), 'baz,foo,bar') def test_list_value_list_bad(self): schema = {'Type': 'CommaDelimitedList', 'ConstraintDescription': 'wibble', 'AllowedValues': ['foo', 'bar', 'baz']} try: parameters.Parameter('p', schema, 'foo,baz,blarg') except ValueError as ve: msg = str(ve) self.assertNotEqual(msg.find('wibble'), -1) else: self.fail('ValueError not raised') params_schema = json.loads('''{ "Parameters" : { "User" : { "Type": "String" }, "Defaulted" : { "Type": "String", "Default": "foobar" } } }''') @attr(tag=['unit', 'parameters']) @attr(speed='fast') class ParametersTest(unittest.TestCase): def test_pseudo_params(self): params = parameters.Parameters('test_stack', {"Parameters": {}}) self.assertEqual(params['AWS::StackName'], 'test_stack') self.assertEqual(params['AWS::StackId'], 'None') self.assertTrue('AWS::Region' in params) def test_pseudo_param_stackid(self): params = parameters.Parameters('test_stack', {'Parameters': {}}, stack_id='123::foo') self.assertEqual(params['AWS::StackId'], '123::foo') params.set_stack_id('456::bar') self.assertEqual(params['AWS::StackId'], '456::bar') def test_user_param(self): user_params = {'User': 'wibble'} params = parameters.Parameters('test', params_schema, user_params) self.assertEqual(params.user_parameters(), user_params) def test_user_param_nonexist(self): params = parameters.Parameters('test', params_schema) self.assertEqual(params.user_parameters(), {}) def test_schema_invariance(self): params1 = parameters.Parameters('test', params_schema, {'Defaulted': 'wibble'}) self.assertEqual(params1['Defaulted'], 'wibble') params2 = parameters.Parameters('test', params_schema) self.assertEqual(params2['Defaulted'], 'foobar') def test_to_dict(self): template = {'Parameters': {'Foo': {'Type': 'String'}, 'Bar': {'Type': 'Number', 'Default': '42'}}} params = parameters.Parameters('test_params', template, {'Foo': 'foo'}) as_dict = dict(params) self.assertEqual(as_dict['Foo'], 'foo') self.assertEqual(as_dict['Bar'], '42') self.assertEqual(as_dict['AWS::StackName'], 'test_params') self.assertTrue('AWS::Region' in as_dict) def test_map(self): template = {'Parameters': {'Foo': {'Type': 'String'}, 'Bar': {'Type': 'Number', 'Default': '42'}}} params = parameters.Parameters('test_params', template, {'Foo': 'foo'}) expected = {'Foo': False, 'Bar': True, 'AWS::Region': True, 'AWS::StackId': True, 'AWS::StackName': True} self.assertEqual(params.map(lambda p: p.has_default()), expected) def test_map_str(self): template = {'Parameters': {'Foo': {'Type': 'String'}, 'Bar': {'Type': 'Number'}}} params = parameters.Parameters('test_params', template, { 'Foo': 'foo', 'Bar': 42}) expected = {'Foo': 'foo', 'Bar': '42', 'AWS::Region': 'ap-southeast-1', 'AWS::StackId': 'None', 'AWS::StackName': 'test_params'} self.assertEqual(params.map(str), expected)
apache-2.0
[ 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 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, 421, 199, 646, 2882, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 646, 2022, 199, 199, 504, 20408, 14, 3908, 492, 2633, 421, 199, 32, 962, 8, 1450, 2968, 3248, 297, 283, 3214, 1105, 199, 32, 962, 8, 7625, 534, 7015, 358, 199, 533, 12009, 774, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 1222, 63, 875, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 80, 297, 791, 804, 356, 283, 1558, 3071, 267, 291, 14, 1815, 8, 6074, 8, 80, 12, 2633, 14, 1558, 4098, 430, 339, 347, 511, 63, 1222, 63, 1955, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 80, 297, 791, 804, 356, 283, 3259, 3071, 267, 291, 14, 1815, 8, 6074, 8, 80, 12, 2633, 14, 3259, 4098, 430, 339, 347, 511, 63, 1222, 63, 513, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 80, 297, 791, 804, 356, 283, 25732, 872, 14136, 1296, 3071, 267, 291, 14, 1815, 8, 6074, 8, 80, 12, 2633, 14, 25732, 872, 14136, 1296, 4098, 430, 339, 347, 511, 63, 1222, 63, 4087, 63, 466, 8, 277, 304, 267, 291, 14, 1855, 8, 3393, 12, 2633, 14, 4720, 12, 2079, 283, 80, 297, 791, 804, 356, 283, 1296, 3071, 339, 347, 511, 63, 1222, 63, 889, 63, 466, 8, 277, 304, 267, 291, 14, 1855, 8, 10230, 12, 2633, 14, 4720, 12, 2079, 283, 80, 297, 791, 2698, 356, 283, 3345, 1273, 3071, 339, 347, 511, 63, 885, 63, 889, 63, 4415, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 27205, 471, 297, 791, 804, 356, 283, 1558, 297, 6901, 283, 2698, 356, 283, 3345, 1273, 3071, 267, 291, 14, 1815, 8, 80, 14, 1989, 63, 885, 1012, 267, 291, 14, 629, 8, 80, 14, 885, 1062, 283, 3345, 1273, 358, 267, 291, 14, 629, 8, 80, 14, 585, 1062, 283, 3345, 1273, 358, 339, 347, 511, 63, 885, 63, 4415, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 27205, 471, 297, 639, 791, 804, 356, 283, 1558, 297, 3303, 283, 2698, 356, 283, 3345, 1273, 2267, 639, 283, 87, 30012, 358, 267, 291, 14, 1815, 8, 80, 14, 1989, 63, 885, 1012, 267, 291, 14, 629, 8, 80, 14, 885, 1062, 283, 3345, 1273, 358, 267, 291, 14, 629, 8, 80, 14, 585, 1062, 283, 87, 30012, 358, 339, 347, 511, 63, 885, 63, 3197, 8, 277, 304, 267, 4177, 275, 791, 804, 356, 283, 1558, 297, 2116, 283, 16070, 6550, 356, 788, 1421, 995, 2116, 283, 8463, 5831, 356, 283, 87, 30012, 297, 2116, 283, 2698, 356, 283, 1700, 936, 267, 862, 26, 288, 2633, 14, 4720, 360, 80, 297, 4177, 12, 283, 1421, 358, 267, 871, 1722, 465, 11199, 26, 288, 1499, 275, 620, 8, 432, 9, 288, 291, 14, 7418, 8, 1328, 14, 1623, 360, 87, 30012, 659, 446, 17, 9, 267, 587, 26, 288, 291, 14, 1633, 360, 3393, 440, 4915, 358, 339, 347, 511, 63, 889, 63, 7878, 63, 2052, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 5865, 2239, 530, 297, 639, 791, 804, 356, 283, 1558, 297, 639, 283, 1944, 18690, 356, 283, 2052, 2267, 639, 283, 87, 30012, 358, 267, 291, 14, 1815, 8, 80, 14, 889, 63, 7878, 1012, 267, 291, 14, 7418, 8, 495, 8, 80, 395, 283, 87, 30012, 358, 339, 347, 511, 63, 889, 63, 7878, 63, 2052, 63, 12029, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 5865, 2239, 530, 297, 639, 791, 804, 356, 283, 1558, 297, 639, 283, 1944, 18690, 356, 283, 14064, 53, 69, 2267, 639, 283, 87, 30012, 358, 267, 291, 14, 1815, 8, 80, 14, 889, 63, 7878, 1012, 267, 291, 14, 7418, 8, 495, 8, 80, 395, 283, 87, 30012, 358, 339, 347, 511, 63, 889, 63, 7878, 63, 3910, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 7878, 530, 297, 639, 791, 804, 356, 283, 1558, 297, 639, 283, 1944, 18690, 356, 283, 3910, 2267, 639, 283, 87, 30012, 358, 267, 291, 14, 3334, 8, 80, 14, 889, 63, 7878, 1012, 267, 291, 14, 629, 8, 495, 8, 80, 395, 283, 87, 30012, 358, 339, 347, 511, 63, 1802, 8, 277, 304, 267, 1369, 275, 283, 5831, 402, 314, 2725, 7, 267, 299, 275, 2633, 14, 4720, 360, 80, 297, 791, 804, 356, 283, 1558, 297, 4318, 283, 5831, 356, 1369, 1552, 267, 291, 14, 629, 8, 80, 14, 1802, 1062, 1369, 9, 339, 347, 511, 63, 889, 63, 1802, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 80, 297, 791, 804, 356, 283, 1558, 3071, 267, 291, 14, 629, 8, 80, 14, 1802, 1062, 4074, 339, 347, 511, 63, 875, 63, 552, 63, 8302, 8, 277, 304, 267, 4177, 275, 791, 804, 356, 283, 1558, 297, 2116, 283, 4649, 4625, 356, 283, 19, 297, 2116, 283, 4261, 4625, 356, 283, 19, 936, 267, 299, 275, 2633, 14, 4720, 360, 80, 297, 4177, 12, 283, 1421, 358, 267, 291, 14, 629, 8, 80, 14, 585, 1062, 283, 1421, 358, 339, 347, 511, 63, 875, 63, 7138, 1659, 8, 277, 304, 267, 4177, 275, 791, 804, 356, 283, 1558, 297, 2116, 283, 8463, 5831, 356, 283, 87, 30012, 297, 2116, 283, 4649 ]
[ 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 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, 421, 199, 646, 2882, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 646, 2022, 199, 199, 504, 20408, 14, 3908, 492, 2633, 421, 199, 32, 962, 8, 1450, 2968, 3248, 297, 283, 3214, 1105, 199, 32, 962, 8, 7625, 534, 7015, 358, 199, 533, 12009, 774, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 1222, 63, 875, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 80, 297, 791, 804, 356, 283, 1558, 3071, 267, 291, 14, 1815, 8, 6074, 8, 80, 12, 2633, 14, 1558, 4098, 430, 339, 347, 511, 63, 1222, 63, 1955, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 80, 297, 791, 804, 356, 283, 3259, 3071, 267, 291, 14, 1815, 8, 6074, 8, 80, 12, 2633, 14, 3259, 4098, 430, 339, 347, 511, 63, 1222, 63, 513, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 80, 297, 791, 804, 356, 283, 25732, 872, 14136, 1296, 3071, 267, 291, 14, 1815, 8, 6074, 8, 80, 12, 2633, 14, 25732, 872, 14136, 1296, 4098, 430, 339, 347, 511, 63, 1222, 63, 4087, 63, 466, 8, 277, 304, 267, 291, 14, 1855, 8, 3393, 12, 2633, 14, 4720, 12, 2079, 283, 80, 297, 791, 804, 356, 283, 1296, 3071, 339, 347, 511, 63, 1222, 63, 889, 63, 466, 8, 277, 304, 267, 291, 14, 1855, 8, 10230, 12, 2633, 14, 4720, 12, 2079, 283, 80, 297, 791, 2698, 356, 283, 3345, 1273, 3071, 339, 347, 511, 63, 885, 63, 889, 63, 4415, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 27205, 471, 297, 791, 804, 356, 283, 1558, 297, 6901, 283, 2698, 356, 283, 3345, 1273, 3071, 267, 291, 14, 1815, 8, 80, 14, 1989, 63, 885, 1012, 267, 291, 14, 629, 8, 80, 14, 885, 1062, 283, 3345, 1273, 358, 267, 291, 14, 629, 8, 80, 14, 585, 1062, 283, 3345, 1273, 358, 339, 347, 511, 63, 885, 63, 4415, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 27205, 471, 297, 639, 791, 804, 356, 283, 1558, 297, 3303, 283, 2698, 356, 283, 3345, 1273, 2267, 639, 283, 87, 30012, 358, 267, 291, 14, 1815, 8, 80, 14, 1989, 63, 885, 1012, 267, 291, 14, 629, 8, 80, 14, 885, 1062, 283, 3345, 1273, 358, 267, 291, 14, 629, 8, 80, 14, 585, 1062, 283, 87, 30012, 358, 339, 347, 511, 63, 885, 63, 3197, 8, 277, 304, 267, 4177, 275, 791, 804, 356, 283, 1558, 297, 2116, 283, 16070, 6550, 356, 788, 1421, 995, 2116, 283, 8463, 5831, 356, 283, 87, 30012, 297, 2116, 283, 2698, 356, 283, 1700, 936, 267, 862, 26, 288, 2633, 14, 4720, 360, 80, 297, 4177, 12, 283, 1421, 358, 267, 871, 1722, 465, 11199, 26, 288, 1499, 275, 620, 8, 432, 9, 288, 291, 14, 7418, 8, 1328, 14, 1623, 360, 87, 30012, 659, 446, 17, 9, 267, 587, 26, 288, 291, 14, 1633, 360, 3393, 440, 4915, 358, 339, 347, 511, 63, 889, 63, 7878, 63, 2052, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 5865, 2239, 530, 297, 639, 791, 804, 356, 283, 1558, 297, 639, 283, 1944, 18690, 356, 283, 2052, 2267, 639, 283, 87, 30012, 358, 267, 291, 14, 1815, 8, 80, 14, 889, 63, 7878, 1012, 267, 291, 14, 7418, 8, 495, 8, 80, 395, 283, 87, 30012, 358, 339, 347, 511, 63, 889, 63, 7878, 63, 2052, 63, 12029, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 5865, 2239, 530, 297, 639, 791, 804, 356, 283, 1558, 297, 639, 283, 1944, 18690, 356, 283, 14064, 53, 69, 2267, 639, 283, 87, 30012, 358, 267, 291, 14, 1815, 8, 80, 14, 889, 63, 7878, 1012, 267, 291, 14, 7418, 8, 495, 8, 80, 395, 283, 87, 30012, 358, 339, 347, 511, 63, 889, 63, 7878, 63, 3910, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 7878, 530, 297, 639, 791, 804, 356, 283, 1558, 297, 639, 283, 1944, 18690, 356, 283, 3910, 2267, 639, 283, 87, 30012, 358, 267, 291, 14, 3334, 8, 80, 14, 889, 63, 7878, 1012, 267, 291, 14, 629, 8, 495, 8, 80, 395, 283, 87, 30012, 358, 339, 347, 511, 63, 1802, 8, 277, 304, 267, 1369, 275, 283, 5831, 402, 314, 2725, 7, 267, 299, 275, 2633, 14, 4720, 360, 80, 297, 791, 804, 356, 283, 1558, 297, 4318, 283, 5831, 356, 1369, 1552, 267, 291, 14, 629, 8, 80, 14, 1802, 1062, 1369, 9, 339, 347, 511, 63, 889, 63, 1802, 8, 277, 304, 267, 299, 275, 2633, 14, 4720, 360, 80, 297, 791, 804, 356, 283, 1558, 3071, 267, 291, 14, 629, 8, 80, 14, 1802, 1062, 4074, 339, 347, 511, 63, 875, 63, 552, 63, 8302, 8, 277, 304, 267, 4177, 275, 791, 804, 356, 283, 1558, 297, 2116, 283, 4649, 4625, 356, 283, 19, 297, 2116, 283, 4261, 4625, 356, 283, 19, 936, 267, 299, 275, 2633, 14, 4720, 360, 80, 297, 4177, 12, 283, 1421, 358, 267, 291, 14, 629, 8, 80, 14, 585, 1062, 283, 1421, 358, 339, 347, 511, 63, 875, 63, 7138, 1659, 8, 277, 304, 267, 4177, 275, 791, 804, 356, 283, 1558, 297, 2116, 283, 8463, 5831, 356, 283, 87, 30012, 297, 2116, 283, 4649, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
fiji-flo/servo
tests/wpt/web-platform-tests/conformance-checkers/tools/ins-del-datetime.py
107
8420
# -*- coding: utf-8 -*- import os ccdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) template = """<!DOCTYPE html> <meta charset=utf-8> """ errors = { "date-year-0000": "0000-12-09", "date-month-00": "2002-00-15", "date-month-13": "2002-13-15", "date-0005-02-29": "0005-02-29", "date-1969-02-29": "1969-02-29", "date-1900-02-29": "1900-02-29", "date-2100-02-29": "2100-02-29", "date-2200-02-29": "2200-02-29", "date-2014-02-29": "2014-02-29", "date-day-04-31": "2002-04-31", "date-day-06-31": "2002-06-31", "date-day-09-31": "2002-09-31", "date-day-11-31": "2002-11-31", "date-day-01-32": "2002-01-32", "date-day-03-32": "2002-03-32", "date-day-05-32": "2002-05-32", "date-day-07-32": "2002-07-32", "date-day-08-32": "2002-08-32", "date-day-10-32": "2002-10-32", "date-day-12-32": "2002-12-32", "date-iso8601-YYYYMMDD-no-hyphen": "20020929", "date-leading-whitespace": " 2002-09-29", "date-trailing-whitespace": "2002-09-29 ", "date-month-one-digit": "2002-9-29", "date-month-three-digits": "2002-011-29", "date-year-three-digits": "782-09-29", "date-day-one-digit": "2002-09-9", "date-day-three-digits": "2002-11-009", "date-day-missing-separator": "2014-0220", "date-month-missing-separator": "201402-20", "date-non-ascii-digit": "2002-09-29", "date-trailing-U+0000": "2002-09-29&#x0000;", "date-trailing-pile-of-poo": "2002-09-29💩", "date-wrong-day-separator": "2014-02:20", "date-wrong-month-separator": "2014:02-20", "date-year-negative": "-2002-09-29", "date-leading-bom": "2002-09-29", "global-date-and-time-60-minutes": "2011-11-12T00:60:00+08:00", "global-date-and-time-60-seconds": "2011-11-12T00:00:60+08:00", "global-date-and-time-2400": "2011-11-12T24:00:00+08:00", "global-date-and-time-space-before-timezone": "2011-11-12T06:54:39 08:00", "global-date-and-time-hour-one-digit": "2011-11-12T6:54:39-08:00", "global-date-and-time-hour-three-digits": "2011-11-12T016:54:39-08:00", "global-date-and-time-minutes-one-digit": "2011-11-12T16:4:39-08:00", "global-date-and-time-minutes-three-digits": "2011-11-12T16:354:39-08:00", "global-date-and-time-seconds-one-digit": "2011-11-12T16:54:9-08:00", "global-date-and-time-seconds-three-digits": "2011-11-12T16:54:039-08:00", "global-date-and-time-timezone-with-seconds": "2011-11-12T06:54:39-08:00:00", "global-date-and-time-timezone-60-minutes": "2011-11-12T06:54:39-08:60", "global-date-and-time-timezone-one-digit-hour": "2011-11-12T06:54:39-5:00", "global-date-and-time-timezone-one-digit-minute": "2011-11-12T06:54:39-05:0", "global-date-and-time-timezone-three-digit-hour": "2011-11-12T06:54:39-005:00", "global-date-and-time-timezone-three-digit-minute": "2011-11-12T06:54:39-05:000", "global-date-and-time-nbsp": "2011-11-12 14:54Z", "global-date-and-time-missing-minutes-separator": "2011-11-12T1454Z", "global-date-and-time-missing-seconds-separator": "2011-11-12T14:5439Z", "global-date-and-time-wrong-minutes-separator": "2011-11-12T14-54Z", "global-date-and-time-wrong-seconds-separator": "2011-11-12T14:54-39Z", "global-date-and-time-lowercase-z": "2011-11-12T14:54z", "global-date-and-time-with-both-T-and-space": "2011-11-12T 14:54Z", "global-date-and-time-zero-digit-fraction": "2011-11-12T06:54:39.-08:00", "global-date-and-time-four-digit-fraction": "2011-11-12T06:54:39.9291-08:00", "global-date-and-time-bad-fraction-separator": "2011-11-12T14:54:39,929+0000", "global-date-and-time-timezone-non-T-character": "2011-11-12+14:54Z", "global-date-and-time-timezone-lowercase-t": "2011-11-12t14:54Z", "global-date-and-time-timezone-multiple-spaces": "2011-11-12 14:54Z", "global-date-and-time-timezone-offset-space-start": "2011-11-12T06:54:39.929 08:00", "global-date-and-time-timezone-offset-colon-start": "2011-11-12T06:54:39.929:08:00", "global-date-and-time-timezone-plus-2400": "2011-11-12T06:54:39-24:00", "global-date-and-time-timezone-minus-2400": "2011-11-12T06:54:39-24:00", "global-date-and-time-timezone-iso8601-two-digit": "2011-11-12T06:54:39-08", "global-date-and-time-iso8601-hhmmss-no-colon": "2011-11-12T145439Z", "global-date-and-time-iso8601-hhmm-no-colon": "2011-11-12T1454Z", "global-date-and-time-iso8601-hh": "2011-11-12T14Z", "year": "2006", "yearless-date": "07-15", "month": "2011-11", "week": "2011-W46", "time": "14:54:39", "local-date-and-time": "2011-11-12T14:54", "duration-P-form": "PT4H18M3S", "duration-time-component": "4h 18m 3s", } warnings = { "global-date-and-time-timezone-plus-1500": "2011-11-12T00:00:00+1500", "global-date-and-time-timezone-minus-1300": "2011-11-12T00:00:00-1300", "global-date-and-time-timezone-minutes-15": "2011-11-12T00:00:00+08:15", "date-0214-09-29": "0214-09-29", "date-20014-09-29": "20014-09-29", "date-0004-02-29": "0004-02-29", "date-year-five-digits": "12014-09-29", } non_errors = { "date": "2002-09-29", "date-2000-02-29": "2000-02-29", "date-2400-02-29": "2400-02-29", "date-1968-02-29": "1968-02-29", "date-1900-02-28": "1900-02-28", "date-2100-02-28": "2100-02-28", "date-2200-02-28": "2200-02-28", "date-2014-02-28": "2014-02-28", "date-day-01-31": "2002-01-31", "date-day-03-31": "2002-03-31", "date-day-05-31": "2002-05-31", "date-day-07-31": "2002-07-31", "date-day-08-31": "2002-08-31", "date-day-10-31": "2002-10-31", "date-day-12-31": "2002-12-31", "date-day-04-30": "2002-04-30", "date-day-06-30": "2002-06-30", "date-day-09-30": "2002-09-30", "date-day-11-30": "2002-11-30", "global-date-and-time-no-seconds": "2011-11-12T14:54Z", "global-date-and-time-with-seconds": "2011-11-12T14:54:39+0000", "global-date-and-time-with-one-digit-fraction": "2011-11-12T06:54:39.9-08:00", "global-date-and-time-with-two-digit-fraction": "2011-11-12T06:54:39.92+07:00", "global-date-and-time-with-three-digit-fraction": "2011-11-12T06:54:39.929-06:00", "global-date-and-time-space": "2011-11-12 14:54Z", "global-date-and-time-timezone": "2011-11-12T06:54:39+0900", "global-date-and-time-timezone-30": "2011-11-12T06:54:39-0830", "global-date-and-time-timezone-45": "2011-11-12T06:54:39-0845", "global-date-and-time-timezone-with-colon": "2011-11-12T06:54:39-08:00", "global-date-and-time-timezone-without-colon": "2011-11-12T06:54:39-0800", } for key in errors.keys(): error = errors[key] template_ins = template template_del = template template_ins += '<title>%s</title>\n' % key template_del += '<title>%s</title>\n' % key template_ins += '<ins datetime="%s"></ins>' % errors[key] template_del += '<del datetime="%s"></del>' % errors[key] ins_file = open(os.path.join(ccdir, "html/elements/ins/%s-novalid.html" % key), 'wb') ins_file.write(template_ins) ins_file.close() del_file = open(os.path.join(ccdir, "html/elements/del/%s-novalid.html" % key), 'wb') del_file.write(template_del) del_file.close() for key in warnings.keys(): non_error = warnings[key] template_ins = template template_del = template template_ins += '<title>%s</title>\n' % key template_del += '<title>%s</title>\n' % key template_ins += '<ins datetime="%s"></ins>' % warnings[key] template_del += '<del datetime="%s"></del>' % warnings[key] ins_file = open(os.path.join(ccdir, "html/elements/ins/%s-haswarn.html" % key), 'wb') ins_file.write(template_ins) ins_file.close() del_file = open(os.path.join(ccdir, "html/elements/del/%s-haswarn.html" % key), 'wb') del_file.write(template_del) del_file.close() ins_file = open(os.path.join(ccdir, "html/elements/ins/datetime-isvalid.html"), 'wb') del_file = open(os.path.join(ccdir, "html/elements/del/datetime-isvalid.html"), 'wb') ins_file.write(template + '<title>valid datetime</title>\n') del_file.write(template + '<title>valid datetime</title>\n') for key in non_errors.keys(): non_error = non_errors[key] ins_file.write('<ins datetime="%s"></ins> <!-- %s -->\n' % (non_errors[key], key)) del_file.write('<del datetime="%s"></del> <!-- %s -->\n' % (non_errors[key], key)) ins_file.close() del_file.close() # vim: ts=4:sw=4
mpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 747, 199, 2055, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 29658, 199, 1160, 275, 8894, 1, 16556, 3517, 30, 199, 28, 2024, 5960, 29, 1624, 13, 24, 30, 199, 624, 199, 2550, 275, 469, 272, 298, 602, 13, 3403, 13, 993, 582, 298, 993, 13, 713, 13, 1643, 401, 272, 298, 602, 13, 4482, 13, 383, 582, 298, 15135, 13, 383, 13, 1046, 401, 272, 298, 602, 13, 4482, 13, 969, 582, 298, 15135, 13, 969, 13, 1046, 401, 272, 298, 602, 13, 15646, 13, 996, 13, 1398, 582, 298, 15646, 13, 996, 13, 1398, 401, 272, 298, 602, 13, 1167, 1876, 13, 996, 13, 1398, 582, 298, 1167, 1876, 13, 996, 13, 1398, 401, 272, 298, 602, 13, 26631, 13, 996, 13, 1398, 582, 298, 26631, 13, 996, 13, 1398, 401, 272, 298, 602, 13, 18, 1960, 13, 996, 13, 1398, 582, 298, 18, 1960, 13, 996, 13, 1398, 401, 272, 298, 602, 13, 1081, 383, 13, 996, 13, 1398, 582, 298, 1081, 383, 13, 996, 13, 1398, 401, 272, 298, 602, 13, 7280, 13, 996, 13, 1398, 582, 298, 7280, 13, 996, 13, 1398, 401, 272, 298, 602, 13, 2977, 13, 966, 13, 2192, 582, 298, 15135, 13, 966, 13, 2192, 401, 272, 298, 602, 13, 2977, 13, 1690, 13, 2192, 582, 298, 15135, 13, 1690, 13, 2192, 401, 272, 298, 602, 13, 2977, 13, 1643, 13, 2192, 582, 298, 15135, 13, 1643, 13, 2192, 401, 272, 298, 602, 13, 2977, 13, 845, 13, 2192, 582, 298, 15135, 13, 845, 13, 2192, 401, 272, 298, 602, 13, 2977, 13, 614, 13, 708, 582, 298, 15135, 13, 614, 13, 708, 401, 272, 298, 602, 13, 2977, 13, 1644, 13, 708, 582, 298, 15135, 13, 1644, 13, 708, 401, 272, 298, 602, 13, 2977, 13, 1717, 13, 708, 582, 298, 15135, 13, 1717, 13, 708, 401, 272, 298, 602, 13, 2977, 13, 1780, 13, 708, 582, 298, 15135, 13, 1780, 13, 708, 401, 272, 298, 602, 13, 2977, 13, 2036, 13, 708, 582, 298, 15135, 13, 2036, 13, 708, 401, 272, 298, 602, 13, 2977, 13, 709, 13, 708, 582, 298, 15135, 13, 709, 13, 708, 401, 272, 298, 602, 13, 2977, 13, 713, 13, 708, 582, 298, 15135, 13, 713, 13, 708, 401, 272, 298, 602, 13, 4595, 15363, 13, 15703, 3218, 5745, 13, 889, 13, 30215, 582, 298, 1840, 11303, 1398, 401, 272, 298, 602, 13, 16812, 13, 8506, 582, 298, 14790, 13, 1643, 13, 1398, 401, 272, 298, 602, 13, 15910, 13, 8506, 582, 298, 15135, 13, 1643, 13, 1398, 3872, 272, 298, 602, 13, 4482, 13, 368, 13, 8573, 582, 298, 15135, 13, 25, 13, 1398, 401, 272, 298, 602, 13, 4482, 13, 10480, 13, 7022, 582, 298, 15135, 13, 13059, 13, 1398, 401, 272, 298, 602, 13, 3403, 13, 10480, 13, 7022, 582, 298, 23199, 13, 1643, 13, 1398, 401, 272, 298, 602, 13, 2977, 13, 368, 13, 8573, 582, 298, 15135, 13, 1643, 13, 25, 401, 272, 298, 602, 13, 2977, 13, 10480, 13, 7022, 582, 298, 15135, 13, 845, 13, 8581, 401, 272, 298, 602, 13, 2977, 13, 4752, 13, 9896, 582, 298, 7280, 13, 996, 1165, 401, 272, 298, 602, 13, 4482, 13, 4752, 13, 9896, 582, 298, 7280, 996, 13, 1165, 401, 272, 298, 602, 13, 2865, 13, 4371, 13, 8573, 582, 298, 15135, 13, 1643, 13, 18, 8454, 248, 401, 272, 298, 602, 13, 15910, 13, 53, 11, 993, 582, 298, 15135, 13, 1643, 13, 1398, 7997, 88, 993, 17259, 272, 298, 602, 13, 15910, 13, 80, 441, 13, 1618, 13, 555, 79, 582, 298, 15135, 13, 1643, 13, 1398, 173, 254, 241, 103, 401, 272, 298, 602, 13, 10603, 13, 2977, 13, 9896, 582, 298, 7280, 13, 996, 26, 1165, 401, 272, 298, 602, 13, 10603, 13, 4482, 13, 9896, 582, 298, 7280, 26, 996, 13, 1165, 401, 272, 298, 602, 13, 3403, 13, 7371, 582, 3905, 15135, 13, 1643, 13, 1398, 401, 272, 298, 602, 13, 16812, 13, 16302, 582, 298, 172, 120, 124, 15135, 13, 1643, 13, 1398, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 2259, 13, 10430, 582, 298, 8128, 13, 845, 13, 713, 52, 383, 26, 2259, 26, 383, 11, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 2259, 13, 4515, 582, 298, 8128, 13, 845, 13, 713, 52, 383, 26, 383, 26, 2259, 11, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 1194, 383, 582, 298, 8128, 13, 845, 13, 713, 52, 1194, 26, 383, 26, 383, 11, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 2638, 13, 5182, 13, 7145, 582, 298, 8128, 13, 845, 13, 713, 52, 1690, 26, 1477, 26, 1355, 19363, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 5180, 13, 368, 13, 8573, 582, 298, 8128, 13, 845, 13, 713, 52, 22, 26, 1477, 26, 1355, 13, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 5180, 13, 10480, 13, 7022, 582, 298, 8128, 13, 845, 13, 713, 52, 10882, 26, 1477, 26, 1355, 13, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 10430, 13, 368, 13, 8573, 582, 298, 8128, 13, 845, 13, 713, 52, 975, 26, 20, 26, 1355, 13, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 10430, 13, 10480, 13, 7022, 582, 298, 8128, 13, 845, 13, 713, 52, 975, 26, 12967, 26, 1355, 13, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 4515, 13, 368, 13, 8573, 582, 298, 8128, 13, 845, 13, 713, 52, 975, 26, 1477, 26, 25, 13, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 4515, 13, 10480, 13, 7022, 582, 298, 8128, 13, 845, 13, 713, 52, 975, 26, 1477, 26, 10005, 13, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 747, 199, 2055, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 29658, 199, 1160, 275, 8894, 1, 16556, 3517, 30, 199, 28, 2024, 5960, 29, 1624, 13, 24, 30, 199, 624, 199, 2550, 275, 469, 272, 298, 602, 13, 3403, 13, 993, 582, 298, 993, 13, 713, 13, 1643, 401, 272, 298, 602, 13, 4482, 13, 383, 582, 298, 15135, 13, 383, 13, 1046, 401, 272, 298, 602, 13, 4482, 13, 969, 582, 298, 15135, 13, 969, 13, 1046, 401, 272, 298, 602, 13, 15646, 13, 996, 13, 1398, 582, 298, 15646, 13, 996, 13, 1398, 401, 272, 298, 602, 13, 1167, 1876, 13, 996, 13, 1398, 582, 298, 1167, 1876, 13, 996, 13, 1398, 401, 272, 298, 602, 13, 26631, 13, 996, 13, 1398, 582, 298, 26631, 13, 996, 13, 1398, 401, 272, 298, 602, 13, 18, 1960, 13, 996, 13, 1398, 582, 298, 18, 1960, 13, 996, 13, 1398, 401, 272, 298, 602, 13, 1081, 383, 13, 996, 13, 1398, 582, 298, 1081, 383, 13, 996, 13, 1398, 401, 272, 298, 602, 13, 7280, 13, 996, 13, 1398, 582, 298, 7280, 13, 996, 13, 1398, 401, 272, 298, 602, 13, 2977, 13, 966, 13, 2192, 582, 298, 15135, 13, 966, 13, 2192, 401, 272, 298, 602, 13, 2977, 13, 1690, 13, 2192, 582, 298, 15135, 13, 1690, 13, 2192, 401, 272, 298, 602, 13, 2977, 13, 1643, 13, 2192, 582, 298, 15135, 13, 1643, 13, 2192, 401, 272, 298, 602, 13, 2977, 13, 845, 13, 2192, 582, 298, 15135, 13, 845, 13, 2192, 401, 272, 298, 602, 13, 2977, 13, 614, 13, 708, 582, 298, 15135, 13, 614, 13, 708, 401, 272, 298, 602, 13, 2977, 13, 1644, 13, 708, 582, 298, 15135, 13, 1644, 13, 708, 401, 272, 298, 602, 13, 2977, 13, 1717, 13, 708, 582, 298, 15135, 13, 1717, 13, 708, 401, 272, 298, 602, 13, 2977, 13, 1780, 13, 708, 582, 298, 15135, 13, 1780, 13, 708, 401, 272, 298, 602, 13, 2977, 13, 2036, 13, 708, 582, 298, 15135, 13, 2036, 13, 708, 401, 272, 298, 602, 13, 2977, 13, 709, 13, 708, 582, 298, 15135, 13, 709, 13, 708, 401, 272, 298, 602, 13, 2977, 13, 713, 13, 708, 582, 298, 15135, 13, 713, 13, 708, 401, 272, 298, 602, 13, 4595, 15363, 13, 15703, 3218, 5745, 13, 889, 13, 30215, 582, 298, 1840, 11303, 1398, 401, 272, 298, 602, 13, 16812, 13, 8506, 582, 298, 14790, 13, 1643, 13, 1398, 401, 272, 298, 602, 13, 15910, 13, 8506, 582, 298, 15135, 13, 1643, 13, 1398, 3872, 272, 298, 602, 13, 4482, 13, 368, 13, 8573, 582, 298, 15135, 13, 25, 13, 1398, 401, 272, 298, 602, 13, 4482, 13, 10480, 13, 7022, 582, 298, 15135, 13, 13059, 13, 1398, 401, 272, 298, 602, 13, 3403, 13, 10480, 13, 7022, 582, 298, 23199, 13, 1643, 13, 1398, 401, 272, 298, 602, 13, 2977, 13, 368, 13, 8573, 582, 298, 15135, 13, 1643, 13, 25, 401, 272, 298, 602, 13, 2977, 13, 10480, 13, 7022, 582, 298, 15135, 13, 845, 13, 8581, 401, 272, 298, 602, 13, 2977, 13, 4752, 13, 9896, 582, 298, 7280, 13, 996, 1165, 401, 272, 298, 602, 13, 4482, 13, 4752, 13, 9896, 582, 298, 7280, 996, 13, 1165, 401, 272, 298, 602, 13, 2865, 13, 4371, 13, 8573, 582, 298, 15135, 13, 1643, 13, 18, 8454, 248, 401, 272, 298, 602, 13, 15910, 13, 53, 11, 993, 582, 298, 15135, 13, 1643, 13, 1398, 7997, 88, 993, 17259, 272, 298, 602, 13, 15910, 13, 80, 441, 13, 1618, 13, 555, 79, 582, 298, 15135, 13, 1643, 13, 1398, 173, 254, 241, 103, 401, 272, 298, 602, 13, 10603, 13, 2977, 13, 9896, 582, 298, 7280, 13, 996, 26, 1165, 401, 272, 298, 602, 13, 10603, 13, 4482, 13, 9896, 582, 298, 7280, 26, 996, 13, 1165, 401, 272, 298, 602, 13, 3403, 13, 7371, 582, 3905, 15135, 13, 1643, 13, 1398, 401, 272, 298, 602, 13, 16812, 13, 16302, 582, 298, 172, 120, 124, 15135, 13, 1643, 13, 1398, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 2259, 13, 10430, 582, 298, 8128, 13, 845, 13, 713, 52, 383, 26, 2259, 26, 383, 11, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 2259, 13, 4515, 582, 298, 8128, 13, 845, 13, 713, 52, 383, 26, 383, 26, 2259, 11, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 1194, 383, 582, 298, 8128, 13, 845, 13, 713, 52, 1194, 26, 383, 26, 383, 11, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 2638, 13, 5182, 13, 7145, 582, 298, 8128, 13, 845, 13, 713, 52, 1690, 26, 1477, 26, 1355, 19363, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 5180, 13, 368, 13, 8573, 582, 298, 8128, 13, 845, 13, 713, 52, 22, 26, 1477, 26, 1355, 13, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 5180, 13, 10480, 13, 7022, 582, 298, 8128, 13, 845, 13, 713, 52, 10882, 26, 1477, 26, 1355, 13, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 10430, 13, 368, 13, 8573, 582, 298, 8128, 13, 845, 13, 713, 52, 975, 26, 20, 26, 1355, 13, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 10430, 13, 10480, 13, 7022, 582, 298, 8128, 13, 845, 13, 713, 52, 975, 26, 12967, 26, 1355, 13, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 4515, 13, 368, 13, 8573, 582, 298, 8128, 13, 845, 13, 713, 52, 975, 26, 1477, 26, 25, 13, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 460, 13, 521, 13, 4515, 13, 10480, 13, 7022, 582, 298, 8128, 13, 845, 13, 713, 52, 975, 26, 1477, 26, 10005, 13, 2036, 26, 383, 401, 272, 298, 2966, 13, 602, 13, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ZLLab-Mooc/edx-platform
openedx/core/lib/api/permissions.py
19
3809
""" API library for Django REST Framework permissions-oriented workflows """ from django.conf import settings from django.http import Http404 from rest_framework import permissions from student.roles import CourseStaffRole class ApiKeyHeaderPermission(permissions.BasePermission): """ Django REST Framework permissions class used to manage API Key integrations """ def has_permission(self, request, view): """ Check for permissions by matching the configured API key and header If settings.DEBUG is True and settings.EDX_API_KEY is not set or None, then allow the request. Otherwise, allow the request if and only if settings.EDX_API_KEY is set and the X-Edx-Api-Key HTTP header is present in the request and matches the setting. """ api_key = getattr(settings, "EDX_API_KEY", None) return ( (settings.DEBUG and api_key is None) or (api_key is not None and request.META.get("HTTP_X_EDX_API_KEY") == api_key) ) class ApiKeyHeaderPermissionIsAuthenticated(ApiKeyHeaderPermission, permissions.IsAuthenticated): """ Allow someone to access the view if they have the API key OR they are authenticated. See ApiKeyHeaderPermission for more information how the API key portion is implemented. """ def has_permission(self, request, view): # TODO We can optimize this later on when we know which of these methods is used more often. api_permissions = ApiKeyHeaderPermission.has_permission(self, request, view) is_authenticated_permissions = permissions.IsAuthenticated.has_permission(self, request, view) return api_permissions or is_authenticated_permissions class IsUserInUrl(permissions.BasePermission): """ Permission that checks to see if the request user matches the user in the URL. """ def has_permission(self, request, view): """ Returns true if the current request is by the user themselves. Note: a 404 is returned for non-staff instead of a 403. This is to prevent users from being able to detect the existence of accounts. """ url_username = request.parser_context.get('kwargs', {}).get('username', '') if request.user.username.lower() != url_username.lower(): if request.user.is_staff: return False # staff gets 403 raise Http404() return True class IsUserInUrlOrStaff(IsUserInUrl): """ Permission that checks to see if the request user matches the user in the URL or has is_staff access. """ def has_permission(self, request, view): if request.user.is_staff: return True return super(IsUserInUrlOrStaff, self).has_permission(request, view) class IsStaffOrReadOnly(permissions.BasePermission): """Permission that checks to see if the user is global or course staff, permitting only read-only access if they are not. """ def has_object_permission(self, request, view, obj): return (request.user.is_staff or CourseStaffRole(obj.course_id).has_user(request.user) or request.method in permissions.SAFE_METHODS) class IsStaffOrOwner(permissions.BasePermission): """ Permission that allows access to admin users or the owner of an object. The owner is considered the User object represented by obj.user. """ def has_object_permission(self, request, view, obj): return request.user.is_staff or obj.user == request.user def has_permission(self, request, view): user = request.user return user.is_staff \ or (user.username == request.GET.get('username')) \ or (user.username == getattr(request, 'data', {}).get('username'))
agpl-3.0
[ 624, 199, 3735, 3555, 367, 5634, 14880, 22545, 3443, 13, 16039, 287, 471, 10431, 83, 199, 624, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 4618, 63, 4857, 492, 3443, 199, 199, 504, 6474, 14, 8050, 492, 5531, 18963, 7422, 421, 199, 533, 13986, 1197, 2567, 7980, 8, 6060, 14, 1563, 7980, 304, 272, 408, 272, 5634, 14880, 22545, 3443, 1021, 1202, 370, 9635, 3261, 2606, 4661, 926, 852, 272, 408, 339, 347, 965, 63, 5693, 8, 277, 12, 1056, 12, 2455, 304, 267, 408, 267, 2670, 367, 3443, 701, 4877, 314, 7526, 3261, 790, 436, 1406, 398, 982, 2202, 14, 5287, 365, 715, 436, 2202, 14, 1149, 56, 63, 3735, 63, 3078, 365, 440, 663, 503, 488, 12, 267, 2066, 2040, 314, 1056, 14, 6630, 12, 2040, 314, 1056, 340, 436, 1454, 340, 267, 2202, 14, 1149, 56, 63, 3735, 63, 3078, 365, 663, 436, 314, 1323, 13, 37, 8373, 13, 7394, 13, 1197, 3101, 1406, 365, 267, 3451, 315, 314, 1056, 436, 4450, 314, 4260, 14, 267, 408, 267, 2986, 63, 498, 275, 2519, 8, 1751, 12, 298, 1149, 56, 63, 3735, 63, 3078, 401, 488, 9, 267, 372, 334, 288, 334, 1751, 14, 5287, 436, 2986, 63, 498, 365, 488, 9, 503, 288, 334, 1246, 63, 498, 365, 440, 488, 436, 1056, 14, 10614, 14, 362, 480, 2856, 63, 56, 63, 1149, 56, 63, 3735, 63, 3078, 531, 508, 2986, 63, 498, 9, 267, 776, 421, 199, 533, 13986, 1197, 2567, 7980, 1831, 30871, 8, 7394, 1197, 2567, 7980, 12, 3443, 14, 1831, 30871, 304, 272, 408, 272, 9812, 17122, 370, 2879, 314, 2455, 340, 2985, 1172, 314, 3261, 790, 1549, 2985, 787, 15082, 14, 339, 1666, 13986, 1197, 2567, 7980, 367, 1655, 2556, 4212, 314, 3261, 790, 18046, 365, 6366, 14, 272, 408, 339, 347, 965, 63, 5693, 8, 277, 12, 1056, 12, 2455, 304, 267, 327, 3254, 2136, 883, 13497, 642, 2945, 641, 1380, 781, 5715, 1314, 402, 3520, 3102, 365, 1202, 1655, 14115, 14, 267, 2986, 63, 6060, 275, 13986, 1197, 2567, 7980, 14, 1989, 63, 5693, 8, 277, 12, 1056, 12, 2455, 9, 267, 365, 63, 12177, 63, 6060, 275, 3443, 14, 1831, 30871, 14, 1989, 63, 5693, 8, 277, 12, 1056, 12, 2455, 9, 267, 372, 2986, 63, 6060, 503, 365, 63, 12177, 63, 6060, 421, 199, 533, 6596, 1899, 607, 6417, 8, 6060, 14, 1563, 7980, 304, 272, 408, 272, 8779, 626, 5920, 370, 1937, 340, 314, 1056, 922, 4450, 314, 922, 315, 314, 2851, 14, 272, 408, 339, 347, 965, 63, 5693, 8, 277, 12, 1056, 12, 2455, 304, 267, 408, 267, 1803, 2549, 340, 314, 1453, 1056, 365, 701, 314, 922, 17279, 14, 398, 3390, 26, 282, 7901, 365, 2138, 367, 2222, 13, 7018, 3140, 402, 282, 13269, 14, 961, 365, 370, 7981, 267, 4390, 687, 3769, 7688, 370, 9696, 314, 23780, 402, 12639, 14, 267, 408, 267, 1166, 63, 2473, 275, 1056, 14, 2087, 63, 1100, 14, 362, 360, 958, 297, 13056, 362, 360, 2473, 297, 4074, 267, 340, 1056, 14, 751, 14, 2473, 14, 2325, 342, 1137, 1166, 63, 2473, 14, 2325, 837, 288, 340, 1056, 14, 751, 14, 374, 63, 7018, 26, 355, 372, 756, 221, 327, 12622, 7545, 13269, 288, 746, 4760, 5188, 342, 267, 372, 715, 421, 199, 533, 6596, 1899, 607, 6417, 2844, 18963, 8, 1831, 1899, 607, 6417, 304, 272, 408, 272, 8779, 626, 5920, 370, 1937, 340, 314, 1056, 922, 4450, 314, 922, 315, 314, 2851, 503, 965, 365, 63, 7018, 2879, 14, 272, 408, 339, 347, 965, 63, 5693, 8, 277, 12, 1056, 12, 2455, 304, 267, 340, 1056, 14, 751, 14, 374, 63, 7018, 26, 288, 372, 715, 398, 372, 1613, 8, 1831, 1899, 607, 6417, 2844, 18963, 12, 291, 680, 1989, 63, 5693, 8, 1069, 12, 2455, 9, 421, 199, 533, 6596, 18963, 2844, 22210, 8, 6060, 14, 1563, 7980, 304, 272, 408, 7980, 626, 5920, 370, 1937, 340, 314, 922, 365, 2288, 503, 2518, 272, 12622, 12, 11291, 1337, 1454, 1586, 13, 2118, 2879, 340, 2985, 787, 440, 14, 272, 408, 339, 347, 965, 63, 785, 63, 5693, 8, 277, 12, 1056, 12, 2455, 12, 1559, 304, 267, 372, 334, 1069, 14, 751, 14, 374, 63, 7018, 503, 355, 5531, 18963, 7422, 8, 1113, 14, 1972, 63, 344, 680, 1989, 63, 751, 8, 1069, 14, 751, 9, 503, 355, 1056, 14, 765, 315, 3443, 14, 27657, 63, 18383, 9, 421, 199, 533, 6596, 18963, 2844, 14919, 8, 6060, 14, 1563, 7980, 304, 272, 408, 272, 8779, 626, 6127, 2879, 370, 4628, 4390, 503, 314, 5771, 402, 376, 909, 14, 272, 710, 5771, 365, 8652, 314, 2876, 909, 11159, 701, 1559, 14, 751, 14, 272, 408, 339, 347, 965, 63, 785, 63, 5693, 8, 277, 12, 1056, 12, 2455, 12, 1559, 304, 267, 372, 1056, 14, 751, 14, 374, 63, 7018, 503, 1559, 14, 751, 508, 1056, 14, 751, 339, 347, 965, 63, 5693, 8, 277, 12, 1056, 12, 2455, 304, 267, 922, 275, 1056, 14, 751, 267, 372, 922, 14, 374, 63, 7018, 971, 288, 503, 334, 751, 14, 2473, 508, 1056, 14, 2970, 14, 362, 360, 2473, 1333, 971, 288, 503, 334, 751, 14, 2473, 508, 2519, 8, 1069, 12, 283, 576, 297, 13056, 362, 360, 2473, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 3735, 3555, 367, 5634, 14880, 22545, 3443, 13, 16039, 287, 471, 10431, 83, 199, 624, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 4618, 63, 4857, 492, 3443, 199, 199, 504, 6474, 14, 8050, 492, 5531, 18963, 7422, 421, 199, 533, 13986, 1197, 2567, 7980, 8, 6060, 14, 1563, 7980, 304, 272, 408, 272, 5634, 14880, 22545, 3443, 1021, 1202, 370, 9635, 3261, 2606, 4661, 926, 852, 272, 408, 339, 347, 965, 63, 5693, 8, 277, 12, 1056, 12, 2455, 304, 267, 408, 267, 2670, 367, 3443, 701, 4877, 314, 7526, 3261, 790, 436, 1406, 398, 982, 2202, 14, 5287, 365, 715, 436, 2202, 14, 1149, 56, 63, 3735, 63, 3078, 365, 440, 663, 503, 488, 12, 267, 2066, 2040, 314, 1056, 14, 6630, 12, 2040, 314, 1056, 340, 436, 1454, 340, 267, 2202, 14, 1149, 56, 63, 3735, 63, 3078, 365, 663, 436, 314, 1323, 13, 37, 8373, 13, 7394, 13, 1197, 3101, 1406, 365, 267, 3451, 315, 314, 1056, 436, 4450, 314, 4260, 14, 267, 408, 267, 2986, 63, 498, 275, 2519, 8, 1751, 12, 298, 1149, 56, 63, 3735, 63, 3078, 401, 488, 9, 267, 372, 334, 288, 334, 1751, 14, 5287, 436, 2986, 63, 498, 365, 488, 9, 503, 288, 334, 1246, 63, 498, 365, 440, 488, 436, 1056, 14, 10614, 14, 362, 480, 2856, 63, 56, 63, 1149, 56, 63, 3735, 63, 3078, 531, 508, 2986, 63, 498, 9, 267, 776, 421, 199, 533, 13986, 1197, 2567, 7980, 1831, 30871, 8, 7394, 1197, 2567, 7980, 12, 3443, 14, 1831, 30871, 304, 272, 408, 272, 9812, 17122, 370, 2879, 314, 2455, 340, 2985, 1172, 314, 3261, 790, 1549, 2985, 787, 15082, 14, 339, 1666, 13986, 1197, 2567, 7980, 367, 1655, 2556, 4212, 314, 3261, 790, 18046, 365, 6366, 14, 272, 408, 339, 347, 965, 63, 5693, 8, 277, 12, 1056, 12, 2455, 304, 267, 327, 3254, 2136, 883, 13497, 642, 2945, 641, 1380, 781, 5715, 1314, 402, 3520, 3102, 365, 1202, 1655, 14115, 14, 267, 2986, 63, 6060, 275, 13986, 1197, 2567, 7980, 14, 1989, 63, 5693, 8, 277, 12, 1056, 12, 2455, 9, 267, 365, 63, 12177, 63, 6060, 275, 3443, 14, 1831, 30871, 14, 1989, 63, 5693, 8, 277, 12, 1056, 12, 2455, 9, 267, 372, 2986, 63, 6060, 503, 365, 63, 12177, 63, 6060, 421, 199, 533, 6596, 1899, 607, 6417, 8, 6060, 14, 1563, 7980, 304, 272, 408, 272, 8779, 626, 5920, 370, 1937, 340, 314, 1056, 922, 4450, 314, 922, 315, 314, 2851, 14, 272, 408, 339, 347, 965, 63, 5693, 8, 277, 12, 1056, 12, 2455, 304, 267, 408, 267, 1803, 2549, 340, 314, 1453, 1056, 365, 701, 314, 922, 17279, 14, 398, 3390, 26, 282, 7901, 365, 2138, 367, 2222, 13, 7018, 3140, 402, 282, 13269, 14, 961, 365, 370, 7981, 267, 4390, 687, 3769, 7688, 370, 9696, 314, 23780, 402, 12639, 14, 267, 408, 267, 1166, 63, 2473, 275, 1056, 14, 2087, 63, 1100, 14, 362, 360, 958, 297, 13056, 362, 360, 2473, 297, 4074, 267, 340, 1056, 14, 751, 14, 2473, 14, 2325, 342, 1137, 1166, 63, 2473, 14, 2325, 837, 288, 340, 1056, 14, 751, 14, 374, 63, 7018, 26, 355, 372, 756, 221, 327, 12622, 7545, 13269, 288, 746, 4760, 5188, 342, 267, 372, 715, 421, 199, 533, 6596, 1899, 607, 6417, 2844, 18963, 8, 1831, 1899, 607, 6417, 304, 272, 408, 272, 8779, 626, 5920, 370, 1937, 340, 314, 1056, 922, 4450, 314, 922, 315, 314, 2851, 503, 965, 365, 63, 7018, 2879, 14, 272, 408, 339, 347, 965, 63, 5693, 8, 277, 12, 1056, 12, 2455, 304, 267, 340, 1056, 14, 751, 14, 374, 63, 7018, 26, 288, 372, 715, 398, 372, 1613, 8, 1831, 1899, 607, 6417, 2844, 18963, 12, 291, 680, 1989, 63, 5693, 8, 1069, 12, 2455, 9, 421, 199, 533, 6596, 18963, 2844, 22210, 8, 6060, 14, 1563, 7980, 304, 272, 408, 7980, 626, 5920, 370, 1937, 340, 314, 922, 365, 2288, 503, 2518, 272, 12622, 12, 11291, 1337, 1454, 1586, 13, 2118, 2879, 340, 2985, 787, 440, 14, 272, 408, 339, 347, 965, 63, 785, 63, 5693, 8, 277, 12, 1056, 12, 2455, 12, 1559, 304, 267, 372, 334, 1069, 14, 751, 14, 374, 63, 7018, 503, 355, 5531, 18963, 7422, 8, 1113, 14, 1972, 63, 344, 680, 1989, 63, 751, 8, 1069, 14, 751, 9, 503, 355, 1056, 14, 765, 315, 3443, 14, 27657, 63, 18383, 9, 421, 199, 533, 6596, 18963, 2844, 14919, 8, 6060, 14, 1563, 7980, 304, 272, 408, 272, 8779, 626, 6127, 2879, 370, 4628, 4390, 503, 314, 5771, 402, 376, 909, 14, 272, 710, 5771, 365, 8652, 314, 2876, 909, 11159, 701, 1559, 14, 751, 14, 272, 408, 339, 347, 965, 63, 785, 63, 5693, 8, 277, 12, 1056, 12, 2455, 12, 1559, 304, 267, 372, 1056, 14, 751, 14, 374, 63, 7018, 503, 1559, 14, 751, 508, 1056, 14, 751, 339, 347, 965, 63, 5693, 8, 277, 12, 1056, 12, 2455, 304, 267, 922, 275, 1056, 14, 751, 267, 372, 922, 14, 374, 63, 7018, 971, 288, 503, 334, 751, 14, 2473, 508, 1056, 14, 2970, 14, 362, 360, 2473, 1333, 971, 288, 503, 334, 751, 14, 2473, 508, 2519, 8, 1069, 12, 283, 576, 297, 13056, 362, 360, 2473, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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################## # The Original Code is Mozilla Communicator client code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### # Sampling from about 20M text materials include literature and computer technology # # Japanese frequency table, applied to both S-JIS and EUC-JP # They are sorted in order. # 128 --> 0.77094 # 256 --> 0.85710 # 512 --> 0.92635 # 1024 --> 0.97130 # 2048 --> 0.99431 # # Ideal Distribution Ratio = 0.92635 / (1-0.92635) = 12.58 # Random Distribution Ration = 512 / (2965+62+83+86-512) = 0.191 # # Typical Distribution Ratio, 25% of IDR JIS_TYPICAL_DISTRIBUTION_RATIO = 3.0 # Char to FreqOrder table , JIS_TABLE_SIZE = 4368 JISCharToFreqOrder = ( \ 40, 1, 6, 182, 152, 180, 295,2127, 285, 381,3295,4304,3068,4606,3165,3510, # 16 3511,1822,2785,4607,1193,2226,5070,4608, 171,2996,1247, 18, 179,5071, 856,1661, # 32 1262,5072, 619, 127,3431,3512,3230,1899,1700, 232, 228,1294,1298, 284, 283,2041, # 48 2042,1061,1062, 48, 49, 44, 45, 433, 434,1040,1041, 996, 787,2997,1255,4305, # 64 2108,4609,1684,1648,5073,5074,5075,5076,5077,5078,3687,5079,4610,5080,3927,3928, # 80 5081,3296,3432, 290,2285,1471,2187,5082,2580,2825,1303,2140,1739,1445,2691,3375, # 96 1691,3297,4306,4307,4611, 452,3376,1182,2713,3688,3069,4308,5083,5084,5085,5086, # 112 5087,5088,5089,5090,5091,5092,5093,5094,5095,5096,5097,5098,5099,5100,5101,5102, # 128 5103,5104,5105,5106,5107,5108,5109,5110,5111,5112,4097,5113,5114,5115,5116,5117, # 144 5118,5119,5120,5121,5122,5123,5124,5125,5126,5127,5128,5129,5130,5131,5132,5133, # 160 5134,5135,5136,5137,5138,5139,5140,5141,5142,5143,5144,5145,5146,5147,5148,5149, # 176 5150,5151,5152,4612,5153,5154,5155,5156,5157,5158,5159,5160,5161,5162,5163,5164, # 192 5165,5166,5167,5168,5169,5170,5171,5172,5173,5174,5175,1472, 598, 618, 820,1205, # 208 1309,1412,1858,1307,1692,5176,5177,5178,5179,5180,5181,5182,1142,1452,1234,1172, # 224 1875,2043,2149,1793,1382,2973, 925,2404,1067,1241, 960,1377,2935,1491, 919,1217, # 240 1865,2030,1406,1499,2749,4098,5183,5184,5185,5186,5187,5188,2561,4099,3117,1804, # 256 2049,3689,4309,3513,1663,5189,3166,3118,3298,1587,1561,3433,5190,3119,1625,2998, # 272 3299,4613,1766,3690,2786,4614,5191,5192,5193,5194,2161, 26,3377, 2,3929, 20, # 288 3691, 47,4100, 50, 17, 16, 35, 268, 27, 243, 42, 155, 24, 154, 29, 184, # 304 4, 91, 14, 92, 53, 396, 33, 289, 9, 37, 64, 620, 21, 39, 321, 5, # 320 12, 11, 52, 13, 3, 208, 138, 0, 7, 60, 526, 141, 151,1069, 181, 275, # 336 1591, 83, 132,1475, 126, 331, 829, 15, 69, 160, 59, 22, 157, 55,1079, 312, # 352 109, 38, 23, 25, 10, 19, 79,5195, 61, 382,1124, 8, 30,5196,5197,5198, # 368 5199,5200,5201,5202,5203,5204,5205,5206, 89, 62, 74, 34,2416, 112, 139, 196, # 384 271, 149, 84, 607, 131, 765, 46, 88, 153, 683, 76, 874, 101, 258, 57, 80, # 400 32, 364, 121,1508, 169,1547, 68, 235, 145,2999, 41, 360,3027, 70, 63, 31, # 416 43, 259, 262,1383, 99, 533, 194, 66, 93, 846, 217, 192, 56, 106, 58, 565, # 432 280, 272, 311, 256, 146, 82, 308, 71, 100, 128, 214, 655, 110, 261, 104,1140, # 448 54, 51, 36, 87, 67,3070, 185,2618,2936,2020, 28,1066,2390,2059,5207,5208, # 464 5209,5210,5211,5212,5213,5214,5215,5216,4615,5217,5218,5219,5220,5221,5222,5223, # 480 5224,5225,5226,5227,5228,5229,5230,5231,5232,5233,5234,5235,5236,3514,5237,5238, # 496 5239,5240,5241,5242,5243,5244,2297,2031,4616,4310,3692,5245,3071,5246,3598,5247, # 512 4617,3231,3515,5248,4101,4311,4618,3808,4312,4102,5249,4103,4104,3599,5250,5251, # 528 5252,5253,5254,5255,5256,5257,5258,5259,5260,5261,5262,5263,5264,5265,5266,5267, # 544 5268,5269,5270,5271,5272,5273,5274,5275,5276,5277,5278,5279,5280,5281,5282,5283, # 560 5284,5285,5286,5287,5288,5289,5290,5291,5292,5293,5294,5295,5296,5297,5298,5299, # 576 5300,5301,5302,5303,5304,5305,5306,5307,5308,5309,5310,5311,5312,5313,5314,5315, # 592 5316,5317,5318,5319,5320,5321,5322,5323,5324,5325,5326,5327,5328,5329,5330,5331, # 608 5332,5333,5334,5335,5336,5337,5338,5339,5340,5341,5342,5343,5344,5345,5346,5347, # 624 5348,5349,5350,5351,5352,5353,5354,5355,5356,5357,5358,5359,5360,5361,5362,5363, # 640 5364,5365,5366,5367,5368,5369,5370,5371,5372,5373,5374,5375,5376,5377,5378,5379, # 656 5380,5381, 363, 642,2787,2878,2788,2789,2316,3232,2317,3434,2011, 165,1942,3930, # 672 3931,3932,3933,5382,4619,5383,4620,5384,5385,5386,5387,5388,5389,5390,5391,5392, # 688 5393,5394,5395,5396,5397,5398,5399,5400,5401,5402,5403,5404,5405,5406,5407,5408, # 704 5409,5410,5411,5412,5413,5414,5415,5416,5417,5418,5419,5420,5421,5422,5423,5424, # 720 5425,5426,5427,5428,5429,5430,5431,5432,5433,5434,5435,5436,5437,5438,5439,5440, # 736 5441,5442,5443,5444,5445,5446,5447,5448,5449,5450,5451,5452,5453,5454,5455,5456, # 752 5457,5458,5459,5460,5461,5462,5463,5464,5465,5466,5467,5468,5469,5470,5471,5472, # 768 5473,5474,5475,5476,5477,5478,5479,5480,5481,5482,5483,5484,5485,5486,5487,5488, # 784 5489,5490,5491,5492,5493,5494,5495,5496,5497,5498,5499,5500,5501,5502,5503,5504, # 800 5505,5506,5507,5508,5509,5510,5511,5512,5513,5514,5515,5516,5517,5518,5519,5520, # 816 5521,5522,5523,5524,5525,5526,5527,5528,5529,5530,5531,5532,5533,5534,5535,5536, # 832 5537,5538,5539,5540,5541,5542,5543,5544,5545,5546,5547,5548,5549,5550,5551,5552, # 848 5553,5554,5555,5556,5557,5558,5559,5560,5561,5562,5563,5564,5565,5566,5567,5568, # 864 5569,5570,5571,5572,5573,5574,5575,5576,5577,5578,5579,5580,5581,5582,5583,5584, # 880 5585,5586,5587,5588,5589,5590,5591,5592,5593,5594,5595,5596,5597,5598,5599,5600, # 896 5601,5602,5603,5604,5605,5606,5607,5608,5609,5610,5611,5612,5613,5614,5615,5616, # 912 5617,5618,5619,5620,5621,5622,5623,5624,5625,5626,5627,5628,5629,5630,5631,5632, # 928 5633,5634,5635,5636,5637,5638,5639,5640,5641,5642,5643,5644,5645,5646,5647,5648, # 944 5649,5650,5651,5652,5653,5654,5655,5656,5657,5658,5659,5660,5661,5662,5663,5664, # 960 5665,5666,5667,5668,5669,5670,5671,5672,5673,5674,5675,5676,5677,5678,5679,5680, # 976 5681,5682,5683,5684,5685,5686,5687,5688,5689,5690,5691,5692,5693,5694,5695,5696, # 992 5697,5698,5699,5700,5701,5702,5703,5704,5705,5706,5707,5708,5709,5710,5711,5712, # 1008 5713,5714,5715,5716,5717,5718,5719,5720,5721,5722,5723,5724,5725,5726,5727,5728, # 1024 5729,5730,5731,5732,5733,5734,5735,5736,5737,5738,5739,5740,5741,5742,5743,5744, # 1040 5745,5746,5747,5748,5749,5750,5751,5752,5753,5754,5755,5756,5757,5758,5759,5760, # 1056 5761,5762,5763,5764,5765,5766,5767,5768,5769,5770,5771,5772,5773,5774,5775,5776, # 1072 5777,5778,5779,5780,5781,5782,5783,5784,5785,5786,5787,5788,5789,5790,5791,5792, # 1088 5793,5794,5795,5796,5797,5798,5799,5800,5801,5802,5803,5804,5805,5806,5807,5808, # 1104 5809,5810,5811,5812,5813,5814,5815,5816,5817,5818,5819,5820,5821,5822,5823,5824, # 1120 5825,5826,5827,5828,5829,5830,5831,5832,5833,5834,5835,5836,5837,5838,5839,5840, # 1136 5841,5842,5843,5844,5845,5846,5847,5848,5849,5850,5851,5852,5853,5854,5855,5856, # 1152 5857,5858,5859,5860,5861,5862,5863,5864,5865,5866,5867,5868,5869,5870,5871,5872, # 1168 5873,5874,5875,5876,5877,5878,5879,5880,5881,5882,5883,5884,5885,5886,5887,5888, # 1184 5889,5890,5891,5892,5893,5894,5895,5896,5897,5898,5899,5900,5901,5902,5903,5904, # 1200 5905,5906,5907,5908,5909,5910,5911,5912,5913,5914,5915,5916,5917,5918,5919,5920, # 1216 5921,5922,5923,5924,5925,5926,5927,5928,5929,5930,5931,5932,5933,5934,5935,5936, # 1232 5937,5938,5939,5940,5941,5942,5943,5944,5945,5946,5947,5948,5949,5950,5951,5952, # 1248 5953,5954,5955,5956,5957,5958,5959,5960,5961,5962,5963,5964,5965,5966,5967,5968, # 1264 5969,5970,5971,5972,5973,5974,5975,5976,5977,5978,5979,5980,5981,5982,5983,5984, # 1280 5985,5986,5987,5988,5989,5990,5991,5992,5993,5994,5995,5996,5997,5998,5999,6000, # 1296 6001,6002,6003,6004,6005,6006,6007,6008,6009,6010,6011,6012,6013,6014,6015,6016, # 1312 6017,6018,6019,6020,6021,6022,6023,6024,6025,6026,6027,6028,6029,6030,6031,6032, # 1328 6033,6034,6035,6036,6037,6038,6039,6040,6041,6042,6043,6044,6045,6046,6047,6048, # 1344 6049,6050,6051,6052,6053,6054,6055,6056,6057,6058,6059,6060,6061,6062,6063,6064, # 1360 6065,6066,6067,6068,6069,6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,6080, # 1376 6081,6082,6083,6084,6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,6096, # 1392 6097,6098,6099,6100,6101,6102,6103,6104,6105,6106,6107,6108,6109,6110,6111,6112, # 1408 6113,6114,2044,2060,4621, 997,1235, 473,1186,4622, 920,3378,6115,6116, 379,1108, # 1424 4313,2657,2735,3934,6117,3809, 636,3233, 573,1026,3693,3435,2974,3300,2298,4105, # 1440 854,2937,2463, 393,2581,2417, 539, 752,1280,2750,2480, 140,1161, 440, 708,1569, # 1456 665,2497,1746,1291,1523,3000, 164,1603, 847,1331, 537,1997, 486, 508,1693,2418, # 1472 1970,2227, 878,1220, 299,1030, 969, 652,2751, 624,1137,3301,2619, 65,3302,2045, # 1488 1761,1859,3120,1930,3694,3516, 663,1767, 852, 835,3695, 269, 767,2826,2339,1305, # 1504 896,1150, 770,1616,6118, 506,1502,2075,1012,2519, 775,2520,2975,2340,2938,4314, # 1520 3028,2086,1224,1943,2286,6119,3072,4315,2240,1273,1987,3935,1557, 175, 597, 985, # 1536 3517,2419,2521,1416,3029, 585, 938,1931,1007,1052,1932,1685,6120,3379,4316,4623, # 1552 804, 599,3121,1333,2128,2539,1159,1554,2032,3810, 687,2033,2904, 952, 675,1467, # 1568 3436,6121,2241,1096,1786,2440,1543,1924, 980,1813,2228, 781,2692,1879, 728,1918, # 1584 3696,4624, 548,1950,4625,1809,1088,1356,3303,2522,1944, 502, 972, 373, 513,2827, # 1600 586,2377,2391,1003,1976,1631,6122,2464,1084, 648,1776,4626,2141, 324, 962,2012, # 1616 2177,2076,1384, 742,2178,1448,1173,1810, 222, 102, 301, 445, 125,2420, 662,2498, # 1632 277, 200,1476,1165,1068, 224,2562,1378,1446, 450,1880, 659, 791, 582,4627,2939, # 1648 3936,1516,1274, 555,2099,3697,1020,1389,1526,3380,1762,1723,1787,2229, 412,2114, # 1664 1900,2392,3518, 512,2597, 427,1925,2341,3122,1653,1686,2465,2499, 697, 330, 273, # 1680 380,2162, 951, 832, 780, 991,1301,3073, 965,2270,3519, 668,2523,2636,1286, 535, # 1696 1407, 518, 671, 957,2658,2378, 267, 611,2197,3030,6123, 248,2299, 967,1799,2356, # 1712 850,1418,3437,1876,1256,1480,2828,1718,6124,6125,1755,1664,2405,6126,4628,2879, # 1728 2829, 499,2179, 676,4629, 557,2329,2214,2090, 325,3234, 464, 811,3001, 992,2342, # 1744 2481,1232,1469, 303,2242, 466,1070,2163, 603,1777,2091,4630,2752,4631,2714, 322, # 1760 2659,1964,1768, 481,2188,1463,2330,2857,3600,2092,3031,2421,4632,2318,2070,1849, # 1776 2598,4633,1302,2254,1668,1701,2422,3811,2905,3032,3123,2046,4106,1763,1694,4634, # 1792 1604, 943,1724,1454, 917, 868,2215,1169,2940, 552,1145,1800,1228,1823,1955, 316, # 1808 1080,2510, 361,1807,2830,4107,2660,3381,1346,1423,1134,4108,6127, 541,1263,1229, # 1824 1148,2540, 545, 465,1833,2880,3438,1901,3074,2482, 816,3937, 713,1788,2500, 122, # 1840 1575, 195,1451,2501,1111,6128, 859, 374,1225,2243,2483,4317, 390,1033,3439,3075, # 1856 2524,1687, 266, 793,1440,2599, 946, 779, 802, 507, 897,1081, 528,2189,1292, 711, # 1872 1866,1725,1167,1640, 753, 398,2661,1053, 246, 348,4318, 137,1024,3440,1600,2077, # 1888 2129, 825,4319, 698, 238, 521, 187,2300,1157,2423,1641,1605,1464,1610,1097,2541, # 1904 1260,1436, 759,2255,1814,2150, 705,3235, 409,2563,3304, 561,3033,2005,2564, 726, # 1920 1956,2343,3698,4109, 949,3812,3813,3520,1669, 653,1379,2525, 881,2198, 632,2256, # 1936 1027, 778,1074, 733,1957, 514,1481,2466, 554,2180, 702,3938,1606,1017,1398,6129, # 1952 1380,3521, 921, 993,1313, 594, 449,1489,1617,1166, 768,1426,1360, 495,1794,3601, # 1968 1177,3602,1170,4320,2344, 476, 425,3167,4635,3168,1424, 401,2662,1171,3382,1998, # 1984 1089,4110, 477,3169, 474,6130,1909, 596,2831,1842, 494, 693,1051,1028,1207,3076, # 2000 606,2115, 727,2790,1473,1115, 743,3522, 630, 805,1532,4321,2021, 366,1057, 838, # 2016 684,1114,2142,4322,2050,1492,1892,1808,2271,3814,2424,1971,1447,1373,3305,1090, # 2032 1536,3939,3523,3306,1455,2199, 336, 369,2331,1035, 584,2393, 902, 718,2600,6131, # 2048 2753, 463,2151,1149,1611,2467, 715,1308,3124,1268, 343,1413,3236,1517,1347,2663, # 2064 2093,3940,2022,1131,1553,2100,2941,1427,3441,2942,1323,2484,6132,1980, 872,2368, # 2080 2441,2943, 320,2369,2116,1082, 679,1933,3941,2791,3815, 625,1143,2023, 422,2200, # 2096 3816,6133, 730,1695, 356,2257,1626,2301,2858,2637,1627,1778, 937, 883,2906,2693, # 2112 3002,1769,1086, 400,1063,1325,3307,2792,4111,3077, 456,2345,1046, 747,6134,1524, # 2128 884,1094,3383,1474,2164,1059, 974,1688,2181,2258,1047, 345,1665,1187, 358, 875, # 2144 3170, 305, 660,3524,2190,1334,1135,3171,1540,1649,2542,1527, 927, 968,2793, 885, # 2160 1972,1850, 482, 500,2638,1218,1109,1085,2543,1654,2034, 876, 78,2287,1482,1277, # 2176 861,1675,1083,1779, 724,2754, 454, 397,1132,1612,2332, 893, 672,1237, 257,2259, # 2192 2370, 135,3384, 337,2244, 547, 352, 340, 709,2485,1400, 788,1138,2511, 540, 772, # 2208 1682,2260,2272,2544,2013,1843,1902,4636,1999,1562,2288,4637,2201,1403,1533, 407, # 2224 576,3308,1254,2071, 978,3385, 170, 136,1201,3125,2664,3172,2394, 213, 912, 873, # 2240 3603,1713,2202, 699,3604,3699, 813,3442, 493, 531,1054, 468,2907,1483, 304, 281, # 2256 4112,1726,1252,2094, 339,2319,2130,2639, 756,1563,2944, 748, 571,2976,1588,2425, # 2272 2715,1851,1460,2426,1528,1392,1973,3237, 288,3309, 685,3386, 296, 892,2716,2216, # 2288 1570,2245, 722,1747,2217, 905,3238,1103,6135,1893,1441,1965, 251,1805,2371,3700, # 2304 2601,1919,1078, 75,2182,1509,1592,1270,2640,4638,2152,6136,3310,3817, 524, 706, # 2320 1075, 292,3818,1756,2602, 317, 98,3173,3605,3525,1844,2218,3819,2502, 814, 567, # 2336 385,2908,1534,6137, 534,1642,3239, 797,6138,1670,1529, 953,4323, 188,1071, 538, # 2352 178, 729,3240,2109,1226,1374,2000,2357,2977, 731,2468,1116,2014,2051,6139,1261, # 2368 1593, 803,2859,2736,3443, 556, 682, 823,1541,6140,1369,2289,1706,2794, 845, 462, # 2384 2603,2665,1361, 387, 162,2358,1740, 739,1770,1720,1304,1401,3241,1049, 627,1571, # 2400 2427,3526,1877,3942,1852,1500, 431,1910,1503, 677, 297,2795, 286,1433,1038,1198, # 2416 2290,1133,1596,4113,4639,2469,1510,1484,3943,6141,2442, 108, 712,4640,2372, 866, # 2432 3701,2755,3242,1348, 834,1945,1408,3527,2395,3243,1811, 824, 994,1179,2110,1548, # 2448 1453, 790,3003, 690,4324,4325,2832,2909,3820,1860,3821, 225,1748, 310, 346,1780, # 2464 2470, 821,1993,2717,2796, 828, 877,3528,2860,2471,1702,2165,2910,2486,1789, 453, # 2480 359,2291,1676, 73,1164,1461,1127,3311, 421, 604, 314,1037, 589, 116,2487, 737, # 2496 837,1180, 111, 244, 735,6142,2261,1861,1362, 986, 523, 418, 581,2666,3822, 103, # 2512 855, 503,1414,1867,2488,1091, 657,1597, 979, 605,1316,4641,1021,2443,2078,2001, # 2528 1209, 96, 587,2166,1032, 260,1072,2153, 173, 94, 226,3244, 819,2006,4642,4114, # 2544 2203, 231,1744, 782, 97,2667, 786,3387, 887, 391, 442,2219,4326,1425,6143,2694, # 2560 633,1544,1202, 483,2015, 592,2052,1958,2472,1655, 419, 129,4327,3444,3312,1714, # 2576 1257,3078,4328,1518,1098, 865,1310,1019,1885,1512,1734, 469,2444, 148, 773, 436, # 2592 1815,1868,1128,1055,4329,1245,2756,3445,2154,1934,1039,4643, 579,1238, 932,2320, # 2608 353, 205, 801, 115,2428, 944,2321,1881, 399,2565,1211, 678, 766,3944, 335,2101, # 2624 1459,1781,1402,3945,2737,2131,1010, 844, 981,1326,1013, 550,1816,1545,2620,1335, # 2640 1008, 371,2881, 936,1419,1613,3529,1456,1395,2273,1834,2604,1317,2738,2503, 416, # 2656 1643,4330, 806,1126, 229, 591,3946,1314,1981,1576,1837,1666, 347,1790, 977,3313, # 2672 764,2861,1853, 688,2429,1920,1462, 77, 595, 415,2002,3034, 798,1192,4115,6144, # 2688 2978,4331,3035,2695,2582,2072,2566, 430,2430,1727, 842,1396,3947,3702, 613, 377, # 2704 278, 236,1417,3388,3314,3174, 757,1869, 107,3530,6145,1194, 623,2262, 207,1253, # 2720 2167,3446,3948, 492,1117,1935, 536,1838,2757,1246,4332, 696,2095,2406,1393,1572, # 2736 3175,1782, 583, 190, 253,1390,2230, 830,3126,3389, 934,3245,1703,1749,2979,1870, # 2752 2545,1656,2204, 869,2346,4116,3176,1817, 496,1764,4644, 942,1504, 404,1903,1122, # 2768 1580,3606,2945,1022, 515, 372,1735, 955,2431,3036,6146,2797,1110,2302,2798, 617, # 2784 6147, 441, 762,1771,3447,3607,3608,1904, 840,3037, 86, 939,1385, 572,1370,2445, # 2800 1336, 114,3703, 898, 294, 203,3315, 703,1583,2274, 429, 961,4333,1854,1951,3390, # 2816 2373,3704,4334,1318,1381, 966,1911,2322,1006,1155, 309, 989, 458,2718,1795,1372, # 2832 1203, 252,1689,1363,3177, 517,1936, 168,1490, 562, 193,3823,1042,4117,1835, 551, # 2848 470,4645, 395, 489,3448,1871,1465,2583,2641, 417,1493, 279,1295, 511,1236,1119, # 2864 72,1231,1982,1812,3004, 871,1564, 984,3449,1667,2696,2096,4646,2347,2833,1673, # 2880 3609, 695,3246,2668, 807,1183,4647, 890, 388,2333,1801,1457,2911,1765,1477,1031, # 2896 3316,3317,1278,3391,2799,2292,2526, 163,3450,4335,2669,1404,1802,6148,2323,2407, # 2912 1584,1728,1494,1824,1269, 298, 909,3318,1034,1632, 375, 776,1683,2061, 291, 210, # 2928 1123, 809,1249,1002,2642,3038, 206,1011,2132, 144, 975, 882,1565, 342, 667, 754, # 2944 1442,2143,1299,2303,2062, 447, 626,2205,1221,2739,2912,1144,1214,2206,2584, 760, # 2960 1715, 614, 950,1281,2670,2621, 810, 577,1287,2546,4648, 242,2168, 250,2643, 691, # 2976 123,2644, 647, 313,1029, 689,1357,2946,1650, 216, 771,1339,1306, 808,2063, 549, # 2992 913,1371,2913,2914,6149,1466,1092,1174,1196,1311,2605,2396,1783,1796,3079, 406, # 3008 2671,2117,3949,4649, 487,1825,2220,6150,2915, 448,2348,1073,6151,2397,1707, 130, # 3024 900,1598, 329, 176,1959,2527,1620,6152,2275,4336,3319,1983,2191,3705,3610,2155, # 3040 3706,1912,1513,1614,6153,1988, 646, 392,2304,1589,3320,3039,1826,1239,1352,1340, # 3056 2916, 505,2567,1709,1437,2408,2547, 906,6154,2672, 384,1458,1594,1100,1329, 710, # 3072 423,3531,2064,2231,2622,1989,2673,1087,1882, 333, 841,3005,1296,2882,2379, 580, # 3088 1937,1827,1293,2585, 601, 574, 249,1772,4118,2079,1120, 645, 901,1176,1690, 795, # 3104 2207, 478,1434, 516,1190,1530, 761,2080, 930,1264, 355, 435,1552, 644,1791, 987, # 3120 220,1364,1163,1121,1538, 306,2169,1327,1222, 546,2645, 218, 241, 610,1704,3321, # 3136 1984,1839,1966,2528, 451,6155,2586,3707,2568, 907,3178, 254,2947, 186,1845,4650, # 3152 745, 432,1757, 428,1633, 888,2246,2221,2489,3611,2118,1258,1265, 956,3127,1784, # 3168 4337,2490, 319, 510, 119, 457,3612, 274,2035,2007,4651,1409,3128, 970,2758, 590, # 3184 2800, 661,2247,4652,2008,3950,1420,1549,3080,3322,3951,1651,1375,2111, 485,2491, # 3200 1429,1156,6156,2548,2183,1495, 831,1840,2529,2446, 501,1657, 307,1894,3247,1341, # 3216 666, 899,2156,1539,2549,1559, 886, 349,2208,3081,2305,1736,3824,2170,2759,1014, # 3232 1913,1386, 542,1397,2948, 490, 368, 716, 362, 159, 282,2569,1129,1658,1288,1750, # 3248 2674, 276, 649,2016, 751,1496, 658,1818,1284,1862,2209,2087,2512,3451, 622,2834, # 3264 376, 117,1060,2053,1208,1721,1101,1443, 247,1250,3179,1792,3952,2760,2398,3953, # 3280 6157,2144,3708, 446,2432,1151,2570,3452,2447,2761,2835,1210,2448,3082, 424,2222, # 3296 1251,2449,2119,2836, 504,1581,4338, 602, 817, 857,3825,2349,2306, 357,3826,1470, # 3312 1883,2883, 255, 958, 929,2917,3248, 302,4653,1050,1271,1751,2307,1952,1430,2697, # 3328 2719,2359, 354,3180, 777, 158,2036,4339,1659,4340,4654,2308,2949,2248,1146,2232, # 3344 3532,2720,1696,2623,3827,6158,3129,1550,2698,1485,1297,1428, 637, 931,2721,2145, # 3360 914,2550,2587, 81,2450, 612, 827,2646,1242,4655,1118,2884, 472,1855,3181,3533, # 3376 3534, 569,1353,2699,1244,1758,2588,4119,2009,2762,2171,3709,1312,1531,6159,1152, # 3392 1938, 134,1830, 471,3710,2276,1112,1535,3323,3453,3535, 982,1337,2950, 488, 826, # 3408 674,1058,1628,4120,2017, 522,2399, 211, 568,1367,3454, 350, 293,1872,1139,3249, # 3424 1399,1946,3006,1300,2360,3324, 588, 736,6160,2606, 744, 669,3536,3828,6161,1358, # 3440 199, 723, 848, 933, 851,1939,1505,1514,1338,1618,1831,4656,1634,3613, 443,2740, # 3456 3829, 717,1947, 491,1914,6162,2551,1542,4121,1025,6163,1099,1223, 198,3040,2722, # 3472 370, 410,1905,2589, 998,1248,3182,2380, 519,1449,4122,1710, 947, 928,1153,4341, # 3488 2277, 344,2624,1511, 615, 105, 161,1212,1076,1960,3130,2054,1926,1175,1906,2473, # 3504 414,1873,2801,6164,2309, 315,1319,3325, 318,2018,2146,2157, 963, 631, 223,4342, # 3520 4343,2675, 479,3711,1197,2625,3712,2676,2361,6165,4344,4123,6166,2451,3183,1886, # 3536 2184,1674,1330,1711,1635,1506, 799, 219,3250,3083,3954,1677,3713,3326,2081,3614, # 3552 1652,2073,4657,1147,3041,1752, 643,1961, 147,1974,3955,6167,1716,2037, 918,3007, # 3568 1994, 120,1537, 118, 609,3184,4345, 740,3455,1219, 332,1615,3830,6168,1621,2980, # 3584 1582, 783, 212, 553,2350,3714,1349,2433,2082,4124, 889,6169,2310,1275,1410, 973, # 3600 166,1320,3456,1797,1215,3185,2885,1846,2590,2763,4658, 629, 822,3008, 763, 940, # 3616 1990,2862, 439,2409,1566,1240,1622, 926,1282,1907,2764, 654,2210,1607, 327,1130, # 3632 3956,1678,1623,6170,2434,2192, 686, 608,3831,3715, 903,3957,3042,6171,2741,1522, # 3648 1915,1105,1555,2552,1359, 323,3251,4346,3457, 738,1354,2553,2311,2334,1828,2003, # 3664 3832,1753,2351,1227,6172,1887,4125,1478,6173,2410,1874,1712,1847, 520,1204,2607, # 3680 264,4659, 836,2677,2102, 600,4660,3833,2278,3084,6174,4347,3615,1342, 640, 532, # 3696 543,2608,1888,2400,2591,1009,4348,1497, 341,1737,3616,2723,1394, 529,3252,1321, # 3712 983,4661,1515,2120, 971,2592, 924, 287,1662,3186,4349,2700,4350,1519, 908,1948, # 3728 2452, 156, 796,1629,1486,2223,2055, 694,4126,1259,1036,3392,1213,2249,2742,1889, # 3744 1230,3958,1015, 910, 408, 559,3617,4662, 746, 725, 935,4663,3959,3009,1289, 563, # 3760 867,4664,3960,1567,2981,2038,2626, 988,2263,2381,4351, 143,2374, 704,1895,6175, # 3776 1188,3716,2088, 673,3085,2362,4352, 484,1608,1921,2765,2918, 215, 904,3618,3537, # 3792 894, 509, 976,3043,2701,3961,4353,2837,2982, 498,6176,6177,1102,3538,1332,3393, # 3808 1487,1636,1637, 233, 245,3962, 383, 650, 995,3044, 460,1520,1206,2352, 749,3327, # 3824 530, 700, 389,1438,1560,1773,3963,2264, 719,2951,2724,3834, 870,1832,1644,1000, # 3840 839,2474,3717, 197,1630,3394, 365,2886,3964,1285,2133, 734, 922, 818,1106, 732, # 3856 480,2083,1774,3458, 923,2279,1350, 221,3086, 85,2233,2234,3835,1585,3010,2147, # 3872 1387,1705,2382,1619,2475, 133, 239,2802,1991,1016,2084,2383, 411,2838,1113, 651, # 3888 1985,1160,3328, 990,1863,3087,1048,1276,2647, 265,2627,1599,3253,2056, 150, 638, # 3904 2019, 656, 853, 326,1479, 680,1439,4354,1001,1759, 413,3459,3395,2492,1431, 459, # 3920 4355,1125,3329,2265,1953,1450,2065,2863, 849, 351,2678,3131,3254,3255,1104,1577, # 3936 227,1351,1645,2453,2193,1421,2887, 812,2121, 634, 95,2435, 201,2312,4665,1646, # 3952 1671,2743,1601,2554,2702,2648,2280,1315,1366,2089,3132,1573,3718,3965,1729,1189, # 3968 328,2679,1077,1940,1136, 558,1283, 964,1195, 621,2074,1199,1743,3460,3619,1896, # 3984 1916,1890,3836,2952,1154,2112,1064, 862, 378,3011,2066,2113,2803,1568,2839,6178, # 4000 3088,2919,1941,1660,2004,1992,2194, 142, 707,1590,1708,1624,1922,1023,1836,1233, # 4016 1004,2313, 789, 741,3620,6179,1609,2411,1200,4127,3719,3720,4666,2057,3721, 593, # 4032 2840, 367,2920,1878,6180,3461,1521, 628,1168, 692,2211,2649, 300, 720,2067,2571, # 4048 2953,3396, 959,2504,3966,3539,3462,1977, 701,6181, 954,1043, 800, 681, 183,3722, # 4064 1803,1730,3540,4128,2103, 815,2314, 174, 467, 230,2454,1093,2134, 755,3541,3397, # 4080 1141,1162,6182,1738,2039, 270,3256,2513,1005,1647,2185,3837, 858,1679,1897,1719, # 4096 2954,2324,1806, 402, 670, 167,4129,1498,2158,2104, 750,6183, 915, 189,1680,1551, # 4112 455,4356,1501,2455, 405,1095,2955, 338,1586,1266,1819, 570, 641,1324, 237,1556, # 4128 2650,1388,3723,6184,1368,2384,1343,1978,3089,2436, 879,3724, 792,1191, 758,3012, # 4144 1411,2135,1322,4357, 240,4667,1848,3725,1574,6185, 420,3045,1546,1391, 714,4358, # 4160 1967, 941,1864, 863, 664, 426, 560,1731,2680,1785,2864,1949,2363, 403,3330,1415, # 4176 1279,2136,1697,2335, 204, 721,2097,3838, 90,6186,2085,2505, 191,3967, 124,2148, # 4192 1376,1798,1178,1107,1898,1405, 860,4359,1243,1272,2375,2983,1558,2456,1638, 113, # 4208 3621, 578,1923,2609, 880, 386,4130, 784,2186,2266,1422,2956,2172,1722, 497, 263, # 4224 2514,1267,2412,2610, 177,2703,3542, 774,1927,1344, 616,1432,1595,1018, 172,4360, # 4240 2325, 911,4361, 438,1468,3622, 794,3968,2024,2173,1681,1829,2957, 945, 895,3090, # 4256 575,2212,2476, 475,2401,2681, 785,2744,1745,2293,2555,1975,3133,2865, 394,4668, # 4272 3839, 635,4131, 639, 202,1507,2195,2766,1345,1435,2572,3726,1908,1184,1181,2457, # 4288 3727,3134,4362, 843,2611, 437, 916,4669, 234, 769,1884,3046,3047,3623, 833,6187, # 4304 1639,2250,2402,1355,1185,2010,2047, 999, 525,1732,1290,1488,2612, 948,1578,3728, # 4320 2413,2477,1216,2725,2159, 334,3840,1328,3624,2921,1525,4132, 564,1056, 891,4363, # 4336 1444,1698,2385,2251,3729,1365,2281,2235,1717,6188, 864,3841,2515, 444, 527,2767, # 4352 2922,3625, 544, 461,6189, 566, 209,2437,3398,2098,1065,2068,3331,3626,3257,2137, # 4368 #last 512 #Everything below is of no interest for detection purpose 2138,2122,3730,2888,1995,1820,1044,6190,6191,6192,6193,6194,6195,6196,6197,6198, # 4384 6199,6200,6201,6202,6203,6204,6205,4670,6206,6207,6208,6209,6210,6211,6212,6213, # 4400 6214,6215,6216,6217,6218,6219,6220,6221,6222,6223,6224,6225,6226,6227,6228,6229, # 4416 6230,6231,6232,6233,6234,6235,6236,6237,3187,6238,6239,3969,6240,6241,6242,6243, # 4432 6244,4671,6245,6246,4672,6247,6248,4133,6249,6250,4364,6251,2923,2556,2613,4673, # 4448 4365,3970,6252,6253,6254,6255,4674,6256,6257,6258,2768,2353,4366,4675,4676,3188, # 4464 4367,3463,6259,4134,4677,4678,6260,2267,6261,3842,3332,4368,3543,6262,6263,6264, # 4480 3013,1954,1928,4135,4679,6265,6266,2478,3091,6267,4680,4369,6268,6269,1699,6270, # 4496 3544,4136,4681,6271,4137,6272,4370,2804,6273,6274,2593,3971,3972,4682,6275,2236, # 4512 4683,6276,6277,4684,6278,6279,4138,3973,4685,6280,6281,3258,6282,6283,6284,6285, # 4528 3974,4686,2841,3975,6286,6287,3545,6288,6289,4139,4687,4140,6290,4141,6291,4142, # 4544 6292,6293,3333,6294,6295,6296,4371,6297,3399,6298,6299,4372,3976,6300,6301,6302, # 4560 4373,6303,6304,3843,3731,6305,4688,4374,6306,6307,3259,2294,6308,3732,2530,4143, # 4576 6309,4689,6310,6311,6312,3048,6313,6314,4690,3733,2237,6315,6316,2282,3334,6317, # 4592 6318,3844,6319,6320,4691,6321,3400,4692,6322,4693,6323,3049,6324,4375,6325,3977, # 4608 6326,6327,6328,3546,6329,4694,3335,6330,4695,4696,6331,6332,6333,6334,4376,3978, # 4624 6335,4697,3979,4144,6336,3980,4698,6337,6338,6339,6340,6341,4699,4700,4701,6342, # 4640 6343,4702,6344,6345,4703,6346,6347,4704,6348,4705,4706,3135,6349,4707,6350,4708, # 4656 6351,4377,6352,4709,3734,4145,6353,2506,4710,3189,6354,3050,4711,3981,6355,3547, # 4672 3014,4146,4378,3735,2651,3845,3260,3136,2224,1986,6356,3401,6357,4712,2594,3627, # 4688 3137,2573,3736,3982,4713,3628,4714,4715,2682,3629,4716,6358,3630,4379,3631,6359, # 4704 6360,6361,3983,6362,6363,6364,6365,4147,3846,4717,6366,6367,3737,2842,6368,4718, # 4720 2628,6369,3261,6370,2386,6371,6372,3738,3984,4719,3464,4720,3402,6373,2924,3336, # 4736 4148,2866,6374,2805,3262,4380,2704,2069,2531,3138,2806,2984,6375,2769,6376,4721, # 4752 4722,3403,6377,6378,3548,6379,6380,2705,3092,1979,4149,2629,3337,2889,6381,3338, # 4768 4150,2557,3339,4381,6382,3190,3263,3739,6383,4151,4723,4152,2558,2574,3404,3191, # 4784 6384,6385,4153,6386,4724,4382,6387,6388,4383,6389,6390,4154,6391,4725,3985,6392, # 4800 3847,4155,6393,6394,6395,6396,6397,3465,6398,4384,6399,6400,6401,6402,6403,6404, # 4816 4156,6405,6406,6407,6408,2123,6409,6410,2326,3192,4726,6411,6412,6413,6414,4385, # 4832 4157,6415,6416,4158,6417,3093,3848,6418,3986,6419,6420,3849,6421,6422,6423,4159, # 4848 6424,6425,4160,6426,3740,6427,6428,6429,6430,3987,6431,4727,6432,2238,6433,6434, # 4864 4386,3988,6435,6436,3632,6437,6438,2843,6439,6440,6441,6442,3633,6443,2958,6444, # 4880 6445,3466,6446,2364,4387,3850,6447,4388,2959,3340,6448,3851,6449,4728,6450,6451, # 4896 3264,4729,6452,3193,6453,4389,4390,2706,3341,4730,6454,3139,6455,3194,6456,3051, # 4912 2124,3852,1602,4391,4161,3853,1158,3854,4162,3989,4392,3990,4731,4732,4393,2040, # 4928 4163,4394,3265,6457,2807,3467,3855,6458,6459,6460,3991,3468,4733,4734,6461,3140, # 4944 2960,6462,4735,6463,6464,6465,6466,4736,4737,4738,4739,6467,6468,4164,2403,3856, # 4960 6469,6470,2770,2844,6471,4740,6472,6473,6474,6475,6476,6477,6478,3195,6479,4741, # 4976 4395,6480,2867,6481,4742,2808,6482,2493,4165,6483,6484,6485,6486,2295,4743,6487, # 4992 6488,6489,3634,6490,6491,6492,6493,6494,6495,6496,2985,4744,6497,6498,4745,6499, # 5008 6500,2925,3141,4166,6501,6502,4746,6503,6504,4747,6505,6506,6507,2890,6508,6509, # 5024 6510,6511,6512,6513,6514,6515,6516,6517,6518,6519,3469,4167,6520,6521,6522,4748, # 5040 4396,3741,4397,4749,4398,3342,2125,4750,6523,4751,4752,4753,3052,6524,2961,4168, # 5056 6525,4754,6526,4755,4399,2926,4169,6527,3857,6528,4400,4170,6529,4171,6530,6531, # 5072 2595,6532,6533,6534,6535,3635,6536,6537,6538,6539,6540,6541,6542,4756,6543,6544, # 5088 6545,6546,6547,6548,4401,6549,6550,6551,6552,4402,3405,4757,4403,6553,6554,6555, # 5104 4172,3742,6556,6557,6558,3992,3636,6559,6560,3053,2726,6561,3549,4173,3054,4404, # 5120 6562,6563,3993,4405,3266,3550,2809,4406,6564,6565,6566,4758,4759,6567,3743,6568, # 5136 4760,3744,4761,3470,6569,6570,6571,4407,6572,3745,4174,6573,4175,2810,4176,3196, # 5152 4762,6574,4177,6575,6576,2494,2891,3551,6577,6578,3471,6579,4408,6580,3015,3197, # 5168 6581,3343,2532,3994,3858,6582,3094,3406,4409,6583,2892,4178,4763,4410,3016,4411, # 5184 6584,3995,3142,3017,2683,6585,4179,6586,6587,4764,4412,6588,6589,4413,6590,2986, # 5200 6591,2962,3552,6592,2963,3472,6593,6594,4180,4765,6595,6596,2225,3267,4414,6597, # 5216 3407,3637,4766,6598,6599,3198,6600,4415,6601,3859,3199,6602,3473,4767,2811,4416, # 5232 1856,3268,3200,2575,3996,3997,3201,4417,6603,3095,2927,6604,3143,6605,2268,6606, # 5248 3998,3860,3096,2771,6607,6608,3638,2495,4768,6609,3861,6610,3269,2745,4769,4181, # 5264 3553,6611,2845,3270,6612,6613,6614,3862,6615,6616,4770,4771,6617,3474,3999,4418, # 5280 4419,6618,3639,3344,6619,4772,4182,6620,2126,6621,6622,6623,4420,4773,6624,3018, # 5296 6625,4774,3554,6626,4183,2025,3746,6627,4184,2707,6628,4421,4422,3097,1775,4185, # 5312 3555,6629,6630,2868,6631,6632,4423,6633,6634,4424,2414,2533,2928,6635,4186,2387, # 5328 6636,4775,6637,4187,6638,1891,4425,3202,3203,6639,6640,4776,6641,3345,6642,6643, # 5344 3640,6644,3475,3346,3641,4000,6645,3144,6646,3098,2812,4188,3642,3204,6647,3863, # 5360 3476,6648,3864,6649,4426,4001,6650,6651,6652,2576,6653,4189,4777,6654,6655,6656, # 5376 2846,6657,3477,3205,4002,6658,4003,6659,3347,2252,6660,6661,6662,4778,6663,6664, # 5392 6665,6666,6667,6668,6669,4779,4780,2048,6670,3478,3099,6671,3556,3747,4004,6672, # 5408 6673,6674,3145,4005,3748,6675,6676,6677,6678,6679,3408,6680,6681,6682,6683,3206, # 5424 3207,6684,6685,4781,4427,6686,4782,4783,4784,6687,6688,6689,4190,6690,6691,3479, # 5440 6692,2746,6693,4428,6694,6695,6696,6697,6698,6699,4785,6700,6701,3208,2727,6702, # 5456 3146,6703,6704,3409,2196,6705,4429,6706,6707,6708,2534,1996,6709,6710,6711,2747, # 5472 6712,6713,6714,4786,3643,6715,4430,4431,6716,3557,6717,4432,4433,6718,6719,6720, # 5488 6721,3749,6722,4006,4787,6723,6724,3644,4788,4434,6725,6726,4789,2772,6727,6728, # 5504 6729,6730,6731,2708,3865,2813,4435,6732,6733,4790,4791,3480,6734,6735,6736,6737, # 5520 4436,3348,6738,3410,4007,6739,6740,4008,6741,6742,4792,3411,4191,6743,6744,6745, # 5536 6746,6747,3866,6748,3750,6749,6750,6751,6752,6753,6754,6755,3867,6756,4009,6757, # 5552 4793,4794,6758,2814,2987,6759,6760,6761,4437,6762,6763,6764,6765,3645,6766,6767, # 5568 3481,4192,6768,3751,6769,6770,2174,6771,3868,3752,6772,6773,6774,4193,4795,4438, # 5584 3558,4796,4439,6775,4797,6776,6777,4798,6778,4799,3559,4800,6779,6780,6781,3482, # 5600 6782,2893,6783,6784,4194,4801,4010,6785,6786,4440,6787,4011,6788,6789,6790,6791, # 5616 6792,6793,4802,6794,6795,6796,4012,6797,6798,6799,6800,3349,4803,3483,6801,4804, # 5632 4195,6802,4013,6803,6804,4196,6805,4014,4015,6806,2847,3271,2848,6807,3484,6808, # 5648 6809,6810,4441,6811,4442,4197,4443,3272,4805,6812,3412,4016,1579,6813,6814,4017, # 5664 6815,3869,6816,2964,6817,4806,6818,6819,4018,3646,6820,6821,4807,4019,4020,6822, # 5680 6823,3560,6824,6825,4021,4444,6826,4198,6827,6828,4445,6829,6830,4199,4808,6831, # 5696 6832,6833,3870,3019,2458,6834,3753,3413,3350,6835,4809,3871,4810,3561,4446,6836, # 5712 6837,4447,4811,4812,6838,2459,4448,6839,4449,6840,6841,4022,3872,6842,4813,4814, # 5728 6843,6844,4815,4200,4201,4202,6845,4023,6846,6847,4450,3562,3873,6848,6849,4816, # 5744 4817,6850,4451,4818,2139,6851,3563,6852,6853,3351,6854,6855,3352,4024,2709,3414, # 5760 4203,4452,6856,4204,6857,6858,3874,3875,6859,6860,4819,6861,6862,6863,6864,4453, # 5776 3647,6865,6866,4820,6867,6868,6869,6870,4454,6871,2869,6872,6873,4821,6874,3754, # 5792 6875,4822,4205,6876,6877,6878,3648,4206,4455,6879,4823,6880,4824,3876,6881,3055, # 5808 4207,6882,3415,6883,6884,6885,4208,4209,6886,4210,3353,6887,3354,3564,3209,3485, # 5824 2652,6888,2728,6889,3210,3755,6890,4025,4456,6891,4825,6892,6893,6894,6895,4211, # 5840 6896,6897,6898,4826,6899,6900,4212,6901,4827,6902,2773,3565,6903,4828,6904,6905, # 5856 6906,6907,3649,3650,6908,2849,3566,6909,3567,3100,6910,6911,6912,6913,6914,6915, # 5872 4026,6916,3355,4829,3056,4457,3756,6917,3651,6918,4213,3652,2870,6919,4458,6920, # 5888 2438,6921,6922,3757,2774,4830,6923,3356,4831,4832,6924,4833,4459,3653,2507,6925, # 5904 4834,2535,6926,6927,3273,4027,3147,6928,3568,6929,6930,6931,4460,6932,3877,4461, # 5920 2729,3654,6933,6934,6935,6936,2175,4835,2630,4214,4028,4462,4836,4215,6937,3148, # 5936 4216,4463,4837,4838,4217,6938,6939,2850,4839,6940,4464,6941,6942,6943,4840,6944, # 5952 4218,3274,4465,6945,6946,2710,6947,4841,4466,6948,6949,2894,6950,6951,4842,6952, # 5968 4219,3057,2871,6953,6954,6955,6956,4467,6957,2711,6958,6959,6960,3275,3101,4843, # 5984 6961,3357,3569,6962,4844,6963,6964,4468,4845,3570,6965,3102,4846,3758,6966,4847, # 6000 3878,4848,4849,4029,6967,2929,3879,4850,4851,6968,6969,1733,6970,4220,6971,6972, # 6016 6973,6974,6975,6976,4852,6977,6978,6979,6980,6981,6982,3759,6983,6984,6985,3486, # 6032 3487,6986,3488,3416,6987,6988,6989,6990,6991,6992,6993,6994,6995,6996,6997,4853, # 6048 6998,6999,4030,7000,7001,3211,7002,7003,4221,7004,7005,3571,4031,7006,3572,7007, # 6064 2614,4854,2577,7008,7009,2965,3655,3656,4855,2775,3489,3880,4222,4856,3881,4032, # 6080 3882,3657,2730,3490,4857,7010,3149,7011,4469,4858,2496,3491,4859,2283,7012,7013, # 6096 7014,2365,4860,4470,7015,7016,3760,7017,7018,4223,1917,7019,7020,7021,4471,7022, # 6112 2776,4472,7023,7024,7025,7026,4033,7027,3573,4224,4861,4034,4862,7028,7029,1929, # 6128 3883,4035,7030,4473,3058,7031,2536,3761,3884,7032,4036,7033,2966,2895,1968,4474, # 6144 3276,4225,3417,3492,4226,2105,7034,7035,1754,2596,3762,4227,4863,4475,3763,4864, # 6160 3764,2615,2777,3103,3765,3658,3418,4865,2296,3766,2815,7036,7037,7038,3574,2872, # 6176 3277,4476,7039,4037,4477,7040,7041,4038,7042,7043,7044,7045,7046,7047,2537,7048, # 6192 7049,7050,7051,7052,7053,7054,4478,7055,7056,3767,3659,4228,3575,7057,7058,4229, # 6208 7059,7060,7061,3660,7062,3212,7063,3885,4039,2460,7064,7065,7066,7067,7068,7069, # 6224 7070,7071,7072,7073,7074,4866,3768,4867,7075,7076,7077,7078,4868,3358,3278,2653, # 6240 7079,7080,4479,3886,7081,7082,4869,7083,7084,7085,7086,7087,7088,2538,7089,7090, # 6256 7091,4040,3150,3769,4870,4041,2896,3359,4230,2930,7092,3279,7093,2967,4480,3213, # 6272 4481,3661,7094,7095,7096,7097,7098,7099,7100,7101,7102,2461,3770,7103,7104,4231, # 6288 3151,7105,7106,7107,4042,3662,7108,7109,4871,3663,4872,4043,3059,7110,7111,7112, # 6304 3493,2988,7113,4873,7114,7115,7116,3771,4874,7117,7118,4232,4875,7119,3576,2336, # 6320 4876,7120,4233,3419,4044,4877,4878,4482,4483,4879,4484,4234,7121,3772,4880,1045, # 6336 3280,3664,4881,4882,7122,7123,7124,7125,4883,7126,2778,7127,4485,4486,7128,4884, # 6352 3214,3887,7129,7130,3215,7131,4885,4045,7132,7133,4046,7134,7135,7136,7137,7138, # 6368 7139,7140,7141,7142,7143,4235,7144,4886,7145,7146,7147,4887,7148,7149,7150,4487, # 6384 4047,4488,7151,7152,4888,4048,2989,3888,7153,3665,7154,4049,7155,7156,7157,7158, # 6400 7159,7160,2931,4889,4890,4489,7161,2631,3889,4236,2779,7162,7163,4891,7164,3060, # 6416 7165,1672,4892,7166,4893,4237,3281,4894,7167,7168,3666,7169,3494,7170,7171,4050, # 6432 7172,7173,3104,3360,3420,4490,4051,2684,4052,7174,4053,7175,7176,7177,2253,4054, # 6448 7178,7179,4895,7180,3152,3890,3153,4491,3216,7181,7182,7183,2968,4238,4492,4055, # 6464 7184,2990,7185,2479,7186,7187,4493,7188,7189,7190,7191,7192,4896,7193,4897,2969, # 6480 4494,4898,7194,3495,7195,7196,4899,4495,7197,3105,2731,7198,4900,7199,7200,7201, # 6496 4056,7202,3361,7203,7204,4496,4901,4902,7205,4497,7206,7207,2315,4903,7208,4904, # 6512 7209,4905,2851,7210,7211,3577,7212,3578,4906,7213,4057,3667,4907,7214,4058,2354, # 6528 3891,2376,3217,3773,7215,7216,7217,7218,7219,4498,7220,4908,3282,2685,7221,3496, # 6544 4909,2632,3154,4910,7222,2337,7223,4911,7224,7225,7226,4912,4913,3283,4239,4499, # 6560 7227,2816,7228,7229,7230,7231,7232,7233,7234,4914,4500,4501,7235,7236,7237,2686, # 6576 7238,4915,7239,2897,4502,7240,4503,7241,2516,7242,4504,3362,3218,7243,7244,7245, # 6592 4916,7246,7247,4505,3363,7248,7249,7250,7251,3774,4506,7252,7253,4917,7254,7255, # 6608 3284,2991,4918,4919,3219,3892,4920,3106,3497,4921,7256,7257,7258,4922,7259,4923, # 6624 3364,4507,4508,4059,7260,4240,3498,7261,7262,4924,7263,2992,3893,4060,3220,7264, # 6640 7265,7266,7267,7268,7269,4509,3775,7270,2817,7271,4061,4925,4510,3776,7272,4241, # 6656 4511,3285,7273,7274,3499,7275,7276,7277,4062,4512,4926,7278,3107,3894,7279,7280, # 6672 4927,7281,4513,7282,7283,3668,7284,7285,4242,4514,4243,7286,2058,4515,4928,4929, # 6688 4516,7287,3286,4244,7288,4517,7289,7290,7291,3669,7292,7293,4930,4931,4932,2355, # 6704 4933,7294,2633,4518,7295,4245,7296,7297,4519,7298,7299,4520,4521,4934,7300,4246, # 6720 4522,7301,7302,7303,3579,7304,4247,4935,7305,4936,7306,7307,7308,7309,3777,7310, # 6736 4523,7311,7312,7313,4248,3580,7314,4524,3778,4249,7315,3581,7316,3287,7317,3221, # 6752 7318,4937,7319,7320,7321,7322,7323,7324,4938,4939,7325,4525,7326,7327,7328,4063, # 6768 7329,7330,4940,7331,7332,4941,7333,4526,7334,3500,2780,1741,4942,2026,1742,7335, # 6784 7336,3582,4527,2388,7337,7338,7339,4528,7340,4250,4943,7341,7342,7343,4944,7344, # 6800 7345,7346,3020,7347,4945,7348,7349,7350,7351,3895,7352,3896,4064,3897,7353,7354, # 6816 7355,4251,7356,7357,3898,7358,3779,7359,3780,3288,7360,7361,4529,7362,4946,4530, # 6832 2027,7363,3899,4531,4947,3222,3583,7364,4948,7365,7366,7367,7368,4949,3501,4950, # 6848 3781,4951,4532,7369,2517,4952,4252,4953,3155,7370,4954,4955,4253,2518,4533,7371, # 6864 7372,2712,4254,7373,7374,7375,3670,4956,3671,7376,2389,3502,4065,7377,2338,7378, # 6880 7379,7380,7381,3061,7382,4957,7383,7384,7385,7386,4958,4534,7387,7388,2993,7389, # 6896 3062,7390,4959,7391,7392,7393,4960,3108,4961,7394,4535,7395,4962,3421,4536,7396, # 6912 4963,7397,4964,1857,7398,4965,7399,7400,2176,3584,4966,7401,7402,3422,4537,3900, # 6928 3585,7403,3782,7404,2852,7405,7406,7407,4538,3783,2654,3423,4967,4539,7408,3784, # 6944 3586,2853,4540,4541,7409,3901,7410,3902,7411,7412,3785,3109,2327,3903,7413,7414, # 6960 2970,4066,2932,7415,7416,7417,3904,3672,3424,7418,4542,4543,4544,7419,4968,7420, # 6976 7421,4255,7422,7423,7424,7425,7426,4067,7427,3673,3365,4545,7428,3110,2559,3674, # 6992 7429,7430,3156,7431,7432,3503,7433,3425,4546,7434,3063,2873,7435,3223,4969,4547, # 7008 4548,2898,4256,4068,7436,4069,3587,3786,2933,3787,4257,4970,4971,3788,7437,4972, # 7024 3064,7438,4549,7439,7440,7441,7442,7443,4973,3905,7444,2874,7445,7446,7447,7448, # 7040 3021,7449,4550,3906,3588,4974,7450,7451,3789,3675,7452,2578,7453,4070,7454,7455, # 7056 7456,4258,3676,7457,4975,7458,4976,4259,3790,3504,2634,4977,3677,4551,4260,7459, # 7072 7460,7461,7462,3907,4261,4978,7463,7464,7465,7466,4979,4980,7467,7468,2213,4262, # 7088 7469,7470,7471,3678,4981,7472,2439,7473,4263,3224,3289,7474,3908,2415,4982,7475, # 7104 4264,7476,4983,2655,7477,7478,2732,4552,2854,2875,7479,7480,4265,7481,4553,4984, # 7120 7482,7483,4266,7484,3679,3366,3680,2818,2781,2782,3367,3589,4554,3065,7485,4071, # 7136 2899,7486,7487,3157,2462,4072,4555,4073,4985,4986,3111,4267,2687,3368,4556,4074, # 7152 3791,4268,7488,3909,2783,7489,2656,1962,3158,4557,4987,1963,3159,3160,7490,3112, # 7168 4988,4989,3022,4990,4991,3792,2855,7491,7492,2971,4558,7493,7494,4992,7495,7496, # 7184 7497,7498,4993,7499,3426,4559,4994,7500,3681,4560,4269,4270,3910,7501,4075,4995, # 7200 4271,7502,7503,4076,7504,4996,7505,3225,4997,4272,4077,2819,3023,7506,7507,2733, # 7216 4561,7508,4562,7509,3369,3793,7510,3590,2508,7511,7512,4273,3113,2994,2616,7513, # 7232 7514,7515,7516,7517,7518,2820,3911,4078,2748,7519,7520,4563,4998,7521,7522,7523, # 7248 7524,4999,4274,7525,4564,3682,2239,4079,4565,7526,7527,7528,7529,5000,7530,7531, # 7264 5001,4275,3794,7532,7533,7534,3066,5002,4566,3161,7535,7536,4080,7537,3162,7538, # 7280 7539,4567,7540,7541,7542,7543,7544,7545,5003,7546,4568,7547,7548,7549,7550,7551, # 7296 7552,7553,7554,7555,7556,5004,7557,7558,7559,5005,7560,3795,7561,4569,7562,7563, # 7312 7564,2821,3796,4276,4277,4081,7565,2876,7566,5006,7567,7568,2900,7569,3797,3912, # 7328 7570,7571,7572,4278,7573,7574,7575,5007,7576,7577,5008,7578,7579,4279,2934,7580, # 7344 7581,5009,7582,4570,7583,4280,7584,7585,7586,4571,4572,3913,7587,4573,3505,7588, # 7360 5010,7589,7590,7591,7592,3798,4574,7593,7594,5011,7595,4281,7596,7597,7598,4282, # 7376 5012,7599,7600,5013,3163,7601,5014,7602,3914,7603,7604,2734,4575,4576,4577,7605, # 7392 7606,7607,7608,7609,3506,5015,4578,7610,4082,7611,2822,2901,2579,3683,3024,4579, # 7408 3507,7612,4580,7613,3226,3799,5016,7614,7615,7616,7617,7618,7619,7620,2995,3290, # 7424 7621,4083,7622,5017,7623,7624,7625,7626,7627,4581,3915,7628,3291,7629,5018,7630, # 7440 7631,7632,7633,4084,7634,7635,3427,3800,7636,7637,4582,7638,5019,4583,5020,7639, # 7456 3916,7640,3801,5021,4584,4283,7641,7642,3428,3591,2269,7643,2617,7644,4585,3592, # 7472 7645,4586,2902,7646,7647,3227,5022,7648,4587,7649,4284,7650,7651,7652,4588,2284, # 7488 7653,5023,7654,7655,7656,4589,5024,3802,7657,7658,5025,3508,4590,7659,7660,7661, # 7504 1969,5026,7662,7663,3684,1821,2688,7664,2028,2509,4285,7665,2823,1841,7666,2689, # 7520 3114,7667,3917,4085,2160,5027,5028,2972,7668,5029,7669,7670,7671,3593,4086,7672, # 7536 4591,4087,5030,3803,7673,7674,7675,7676,7677,7678,7679,4286,2366,4592,4593,3067, # 7552 2328,7680,7681,4594,3594,3918,2029,4287,7682,5031,3919,3370,4288,4595,2856,7683, # 7568 3509,7684,7685,5032,5033,7686,7687,3804,2784,7688,7689,7690,7691,3371,7692,7693, # 7584 2877,5034,7694,7695,3920,4289,4088,7696,7697,7698,5035,7699,5036,4290,5037,5038, # 7600 5039,7700,7701,7702,5040,5041,3228,7703,1760,7704,5042,3229,4596,2106,4089,7705, # 7616 4597,2824,5043,2107,3372,7706,4291,4090,5044,7707,4091,7708,5045,3025,3805,4598, # 7632 4292,4293,4294,3373,7709,4599,7710,5046,7711,7712,5047,5048,3806,7713,7714,7715, # 7648 5049,7716,7717,7718,7719,4600,5050,7720,7721,7722,5051,7723,4295,3429,7724,7725, # 7664 7726,7727,3921,7728,3292,5052,4092,7729,7730,7731,7732,7733,7734,7735,5053,5054, # 7680 7736,7737,7738,7739,3922,3685,7740,7741,7742,7743,2635,5055,7744,5056,4601,7745, # 7696 7746,2560,7747,7748,7749,7750,3923,7751,7752,7753,7754,7755,4296,2903,7756,7757, # 7712 7758,7759,7760,3924,7761,5057,4297,7762,7763,5058,4298,7764,4093,7765,7766,5059, # 7728 3925,7767,7768,7769,7770,7771,7772,7773,7774,7775,7776,3595,7777,4299,5060,4094, # 7744 7778,3293,5061,7779,7780,4300,7781,7782,4602,7783,3596,7784,7785,3430,2367,7786, # 7760 3164,5062,5063,4301,7787,7788,4095,5064,5065,7789,3374,3115,7790,7791,7792,7793, # 7776 7794,7795,7796,3597,4603,7797,7798,3686,3116,3807,5066,7799,7800,5067,7801,7802, # 7792 4604,4302,5068,4303,4096,7803,7804,3294,7805,7806,5069,4605,2690,7807,3026,7808, # 7808 7809,7810,7811,7812,7813,7814,7815,7816,7817,7818,7819,7820,7821,7822,7823,7824, # 7824 7825,7826,7827,7828,7829,7830,7831,7832,7833,7834,7835,7836,7837,7838,7839,7840, # 7840 7841,7842,7843,7844,7845,7846,7847,7848,7849,7850,7851,7852,7853,7854,7855,7856, # 7856 7857,7858,7859,7860,7861,7862,7863,7864,7865,7866,7867,7868,7869,7870,7871,7872, # 7872 7873,7874,7875,7876,7877,7878,7879,7880,7881,7882,7883,7884,7885,7886,7887,7888, # 7888 7889,7890,7891,7892,7893,7894,7895,7896,7897,7898,7899,7900,7901,7902,7903,7904, # 7904 7905,7906,7907,7908,7909,7910,7911,7912,7913,7914,7915,7916,7917,7918,7919,7920, # 7920 7921,7922,7923,7924,3926,7925,7926,7927,7928,7929,7930,7931,7932,7933,7934,7935, # 7936 7936,7937,7938,7939,7940,7941,7942,7943,7944,7945,7946,7947,7948,7949,7950,7951, # 7952 7952,7953,7954,7955,7956,7957,7958,7959,7960,7961,7962,7963,7964,7965,7966,7967, # 7968 7968,7969,7970,7971,7972,7973,7974,7975,7976,7977,7978,7979,7980,7981,7982,7983, # 7984 7984,7985,7986,7987,7988,7989,7990,7991,7992,7993,7994,7995,7996,7997,7998,7999, # 8000 8000,8001,8002,8003,8004,8005,8006,8007,8008,8009,8010,8011,8012,8013,8014,8015, # 8016 8016,8017,8018,8019,8020,8021,8022,8023,8024,8025,8026,8027,8028,8029,8030,8031, # 8032 8032,8033,8034,8035,8036,8037,8038,8039,8040,8041,8042,8043,8044,8045,8046,8047, # 8048 8048,8049,8050,8051,8052,8053,8054,8055,8056,8057,8058,8059,8060,8061,8062,8063, # 8064 8064,8065,8066,8067,8068,8069,8070,8071,8072,8073,8074,8075,8076,8077,8078,8079, # 8080 8080,8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,8093,8094,8095, # 8096 8096,8097,8098,8099,8100,8101,8102,8103,8104,8105,8106,8107,8108,8109,8110,8111, # 8112 8112,8113,8114,8115,8116,8117,8118,8119,8120,8121,8122,8123,8124,8125,8126,8127, # 8128 8128,8129,8130,8131,8132,8133,8134,8135,8136,8137,8138,8139,8140,8141,8142,8143, # 8144 8144,8145,8146,8147,8148,8149,8150,8151,8152,8153,8154,8155,8156,8157,8158,8159, # 8160 8160,8161,8162,8163,8164,8165,8166,8167,8168,8169,8170,8171,8172,8173,8174,8175, # 8176 8176,8177,8178,8179,8180,8181,8182,8183,8184,8185,8186,8187,8188,8189,8190,8191, # 8192 8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8203,8204,8205,8206,8207, # 8208 8208,8209,8210,8211,8212,8213,8214,8215,8216,8217,8218,8219,8220,8221,8222,8223, # 8224 8224,8225,8226,8227,8228,8229,8230,8231,8232,8233,8234,8235,8236,8237,8238,8239, # 8240 8240,8241,8242,8243,8244,8245,8246,8247,8248,8249,8250,8251,8252,8253,8254,8255, # 8256 8256,8257,8258,8259,8260,8261,8262,8263,8264,8265,8266,8267,8268,8269,8270,8271) # 8272
mit
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 3, 428, 23144, 687, 3595, 3388, 45, 1318, 8418, 2387, 7142, 1463, 436, 24189, 1565, 24731, 199, 3, 199, 3, 1603, 30699, 9857, 1817, 12, 6781, 370, 3865, 428, 13, 22290, 436, 662, 13371, 13, 15819, 199, 3, 9322, 787, 3355, 315, 1865, 14, 9948, 199, 3, 7960, 221, 10541, 378, 14, 1138, 16285, 199, 3, 7633, 221, 10541, 378, 14, 25294, 709, 199, 3, 10574, 221, 10541, 378, 14, 27642, 1276, 199, 3, 6619, 10541, 378, 14, 2576, 9056, 199, 3, 18427, 10541, 378, 14, 14966, 2192, 199, 3, 199, 3, 473, 21245, 11839, 820, 32736, 275, 378, 14, 27642, 1276, 1182, 334, 17, 13, 16, 14, 27642, 1276, 9, 275, 3144, 14, 2010, 199, 3, 9571, 11839, 820, 425, 275, 10574, 1182, 334, 26163, 11, 2789, 11, 2658, 11, 1184, 13, 7736, 9, 275, 378, 14, 12632, 199, 3, 221, 199, 3, 29267, 11839, 820, 32736, 12, 5661, 5, 402, 2870, 50, 9948, 199, 22290, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 275, 650, 14, 16, 199, 199, 3, 6659, 370, 481, 2103, 4738, 1817, 2360, 221, 199, 22290, 63, 8723, 63, 4305, 275, 841, 10997, 199, 199, 22290, 18139, 13875, 4738, 275, 334, 971, 523, 6335, 12, 257, 413, 12, 257, 1227, 12, 413, 2564, 12, 413, 2528, 12, 13576, 12, 499, 2720, 12, 18, 4195, 12, 499, 2426, 12, 650, 2835, 12, 708, 2720, 12, 2824, 966, 12, 1216, 2333, 12, 2466, 1690, 12, 19, 10355, 12, 1276, 709, 12, 327, 257, 3193, 199, 1276, 845, 12, 1085, 1081, 12, 1465, 2426, 12, 2466, 1780, 12, 845, 3129, 12, 1081, 1479, 12, 1400, 2760, 12, 2466, 2036, 12, 413, 3172, 12, 10488, 22, 12, 713, 2417, 12, 221, 6155, 12, 31420, 12, 1400, 3172, 12, 1695, 1367, 12, 975, 2976, 12, 327, 257, 4337, 199, 713, 2789, 12, 1400, 2819, 12, 1227, 1167, 12, 12792, 12, 1082, 2192, 12, 1276, 713, 12, 708, 1216, 12, 1085, 1020, 12, 1196, 383, 12, 499, 708, 12, 499, 1651, 12, 713, 2635, 12, 713, 2905, 12, 499, 1349, 12, 499, 2658, 12, 6686, 17, 12, 327, 257, 9615, 199, 6686, 18, 12, 709, 2976, 12, 709, 2789, 12, 221, 9615, 12, 221, 12260, 12, 221, 10868, 12, 221, 10416, 12, 841, 1153, 12, 841, 1082, 12, 709, 2167, 12, 709, 2953, 12, 8806, 22, 12, 1520, 1555, 12, 10488, 23, 12, 20197, 12, 20, 11565, 12, 327, 257, 5049, 199, 18, 8079, 12, 2466, 1643, 12, 975, 1349, 12, 8982, 24, 12, 1400, 2898, 12, 1400, 1342, 12, 1400, 2194, 12, 1400, 2114, 12, 1400, 1138, 12, 1400, 2277, 12, 1344, 1555, 12, 1400, 1965, 12, 2466, 709, 12, 1400, 1257, 12, 1355, 1465, 12, 1355, 1651, 12, 327, 257, 5939, 199, 1400, 2835, 12, 708, 2534, 12, 1082, 708, 12, 499, 2710, 12, 1081, 2426, 12, 1079, 3172, 12, 9252, 23, 12, 1400, 2564, 12, 28936, 12, 1651, 821, 12, 969, 1644, 12, 6886, 16, 12, 1196, 1355, 12, 1079, 2322, 12, 1479, 3328, 12, 1153, 2194, 12, 327, 257, 15580, 199, 975, 3328, 12, 708, 2576, 12, 20, 11363, 12, 20, 11516, 12, 2466, 845, 12, 841, 2528, 12, 1153, 2114, 12, 845, 2564, 12, 1465, 969, 12, 1344, 1299, 12, 1216, 1876, 12, 20, 12127, 12, 1400, 2658, 12, 1400, 1349, 12, 1400, 2426, 12, 1400, 1184, 12, 327, 221, 20240, 199, 1400, 1555, 12, 1400, 1299, 12, 1400, 1407, 12, 1400, 2710, 12, 1400, 3328, 12, 1400, 2942, 12, 1400, 3129, 12, 1400, 2635, 12, 1400, 2720, 12, 1400, 2534, 12, 1400, 2576, 12, 1400, 2905, 12, 1400, 1020, 12, 21, 1960, 12, 2869, 614, 12, 21, 7759, 12, 327, 221, 7960, 199, 21, 8845, 12, 21, 6785, 12, 21, 7320, 12, 24966, 12, 21, 7555, 12, 21, 8079, 12, 21, 6996, 12, 2869, 709, 12, 21, 6673, 12, 2869, 713, 12, 12443, 23, 12, 21, 9225, 12, 21, 7636, 12, 21, 7680, 12, 21, 7524, 12, 21, 7362, 12, 327, 221, 21771, 199, 21, 7906, 12, 21, 7119, 12, 21, 6708, 12, 7736, 17, 12, 21, 7507, 12, 21, 4288, 12, 21, 7214, 12, 21, 6889, 12, 7736, 22, 12, 21, 4195, 12, 21, 3933, 12, 21, 7263, 12, 21, 9056, 12, 21, 11780, 12, 2869, 708, 12, 21, 10456, 12, 327, 221, 21235, 199, 21, 7582, 12, 21, 8312, 12, 21, 8138, 12, 21, 7498, 12, 21, 8527, 12, 21, 7491, 12, 21, 10037, 12, 21, 12735, 12, 21, 12199, 12, 21, 12289, 12, 21, 9862, 12, 21, 11731, 12, 21, 11432, 12, 21, 11160, 12, 21, 10834, 12, 21, 10721, 12, 327, 221, 27827, 199, 21, 8251, 12 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 3, 428, 23144, 687, 3595, 3388, 45, 1318, 8418, 2387, 7142, 1463, 436, 24189, 1565, 24731, 199, 3, 199, 3, 1603, 30699, 9857, 1817, 12, 6781, 370, 3865, 428, 13, 22290, 436, 662, 13371, 13, 15819, 199, 3, 9322, 787, 3355, 315, 1865, 14, 9948, 199, 3, 7960, 221, 10541, 378, 14, 1138, 16285, 199, 3, 7633, 221, 10541, 378, 14, 25294, 709, 199, 3, 10574, 221, 10541, 378, 14, 27642, 1276, 199, 3, 6619, 10541, 378, 14, 2576, 9056, 199, 3, 18427, 10541, 378, 14, 14966, 2192, 199, 3, 199, 3, 473, 21245, 11839, 820, 32736, 275, 378, 14, 27642, 1276, 1182, 334, 17, 13, 16, 14, 27642, 1276, 9, 275, 3144, 14, 2010, 199, 3, 9571, 11839, 820, 425, 275, 10574, 1182, 334, 26163, 11, 2789, 11, 2658, 11, 1184, 13, 7736, 9, 275, 378, 14, 12632, 199, 3, 221, 199, 3, 29267, 11839, 820, 32736, 12, 5661, 5, 402, 2870, 50, 9948, 199, 22290, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 275, 650, 14, 16, 199, 199, 3, 6659, 370, 481, 2103, 4738, 1817, 2360, 221, 199, 22290, 63, 8723, 63, 4305, 275, 841, 10997, 199, 199, 22290, 18139, 13875, 4738, 275, 334, 971, 523, 6335, 12, 257, 413, 12, 257, 1227, 12, 413, 2564, 12, 413, 2528, 12, 13576, 12, 499, 2720, 12, 18, 4195, 12, 499, 2426, 12, 650, 2835, 12, 708, 2720, 12, 2824, 966, 12, 1216, 2333, 12, 2466, 1690, 12, 19, 10355, 12, 1276, 709, 12, 327, 257, 3193, 199, 1276, 845, 12, 1085, 1081, 12, 1465, 2426, 12, 2466, 1780, 12, 845, 3129, 12, 1081, 1479, 12, 1400, 2760, 12, 2466, 2036, 12, 413, 3172, 12, 10488, 22, 12, 713, 2417, 12, 221, 6155, 12, 31420, 12, 1400, 3172, 12, 1695, 1367, 12, 975, 2976, 12, 327, 257, 4337, 199, 713, 2789, 12, 1400, 2819, 12, 1227, 1167, 12, 12792, 12, 1082, 2192, 12, 1276, 713, 12, 708, 1216, 12, 1085, 1020, 12, 1196, 383, 12, 499, 708, 12, 499, 1651, 12, 713, 2635, 12, 713, 2905, 12, 499, 1349, 12, 499, 2658, 12, 6686, 17, 12, 327, 257, 9615, 199, 6686, 18, 12, 709, 2976, 12, 709, 2789, 12, 221, 9615, 12, 221, 12260, 12, 221, 10868, 12, 221, 10416, 12, 841, 1153, 12, 841, 1082, 12, 709, 2167, 12, 709, 2953, 12, 8806, 22, 12, 1520, 1555, 12, 10488, 23, 12, 20197, 12, 20, 11565, 12, 327, 257, 5049, 199, 18, 8079, 12, 2466, 1643, 12, 975, 1349, 12, 8982, 24, 12, 1400, 2898, 12, 1400, 1342, 12, 1400, 2194, 12, 1400, 2114, 12, 1400, 1138, 12, 1400, 2277, 12, 1344, 1555, 12, 1400, 1965, 12, 2466, 709, 12, 1400, 1257, 12, 1355, 1465, 12, 1355, 1651, 12, 327, 257, 5939, 199, 1400, 2835, 12, 708, 2534, 12, 1082, 708, 12, 499, 2710, 12, 1081, 2426, 12, 1079, 3172, 12, 9252, 23, 12, 1400, 2564, 12, 28936, 12, 1651, 821, 12, 969, 1644, 12, 6886, 16, 12, 1196, 1355, 12, 1079, 2322, 12, 1479, 3328, 12, 1153, 2194, 12, 327, 257, 15580, 199, 975, 3328, 12, 708, 2576, 12, 20, 11363, 12, 20, 11516, 12, 2466, 845, 12, 841, 2528, 12, 1153, 2114, 12, 845, 2564, 12, 1465, 969, 12, 1344, 1299, 12, 1216, 1876, 12, 20, 12127, 12, 1400, 2658, 12, 1400, 1349, 12, 1400, 2426, 12, 1400, 1184, 12, 327, 221, 20240, 199, 1400, 1555, 12, 1400, 1299, 12, 1400, 1407, 12, 1400, 2710, 12, 1400, 3328, 12, 1400, 2942, 12, 1400, 3129, 12, 1400, 2635, 12, 1400, 2720, 12, 1400, 2534, 12, 1400, 2576, 12, 1400, 2905, 12, 1400, 1020, 12, 21, 1960, 12, 2869, 614, 12, 21, 7759, 12, 327, 221, 7960, 199, 21, 8845, 12, 21, 6785, 12, 21, 7320, 12, 24966, 12, 21, 7555, 12, 21, 8079, 12, 21, 6996, 12, 2869, 709, 12, 21, 6673, 12, 2869, 713, 12, 12443, 23, 12, 21, 9225, 12, 21, 7636, 12, 21, 7680, 12, 21, 7524, 12, 21, 7362, 12, 327, 221, 21771, 199, 21, 7906, 12, 21, 7119, 12, 21, 6708, 12, 7736, 17, 12, 21, 7507, 12, 21, 4288, 12, 21, 7214, 12, 21, 6889, 12, 7736, 22, 12, 21, 4195, 12, 21, 3933, 12, 21, 7263, 12, 21, 9056, 12, 21, 11780, 12, 2869, 708, 12, 21, 10456, 12,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
baylee-d/osf.io
api/nodes/urls.py
5
6124
from django.conf.urls import url from api.nodes import views app_name = 'osf' urlpatterns = [ # Examples: # url(r'^$', 'api.views.home', name='home'), # url(r'^blog/', include('blog.urls')), url(r'^$', views.NodeList.as_view(), name=views.NodeList.view_name), url(r'^(?P<node_id>\w+)/$', views.NodeDetail.as_view(), name=views.NodeDetail.view_name), url(r'^(?P<node_id>\w+)/addons/$', views.NodeAddonList.as_view(), name=views.NodeAddonList.view_name), url(r'^(?P<node_id>\w+)/addons/(?P<provider>\w+)/$', views.NodeAddonDetail.as_view(), name=views.NodeAddonDetail.view_name), url(r'^(?P<node_id>\w+)/addons/(?P<provider>\w+)/folders/$', views.NodeAddonFolderList.as_view(), name=views.NodeAddonFolderList.view_name), url(r'^(?P<node_id>\w+)/bibliographic_contributors/$', views.NodeBibliographicContributorsList.as_view(), name=views.NodeBibliographicContributorsList.view_name), url(r'^(?P<node_id>\w+)/children/$', views.NodeChildrenList.as_view(), name=views.NodeChildrenList.view_name), url(r'^(?P<node_id>\w+)/citation/$', views.NodeCitationDetail.as_view(), name=views.NodeCitationDetail.view_name), url(r'^(?P<node_id>\w+)/citation/(?P<style_id>[-\w]+)/$', views.NodeCitationStyleDetail.as_view(), name=views.NodeCitationStyleDetail.view_name), url(r'^(?P<node_id>\w+)/comments/$', views.NodeCommentsList.as_view(), name=views.NodeCommentsList.view_name), url(r'^(?P<node_id>\w+)/contributors_and_group_members/$', views.NodeContributorsAndGroupMembersList.as_view(), name=views.NodeContributorsAndGroupMembersList.view_name), url(r'^(?P<node_id>\w+)/implicit_contributors/$', views.NodeImplicitContributorsList.as_view(), name=views.NodeImplicitContributorsList.view_name), url(r'^(?P<node_id>\w+)/contributors/$', views.NodeContributorsList.as_view(), name=views.NodeContributorsList.view_name), url(r'^(?P<node_id>\w+)/contributors/(?P<user_id>\w+)/$', views.NodeContributorDetail.as_view(), name=views.NodeContributorDetail.view_name), url(r'^(?P<node_id>\w+)/draft_registrations/$', views.NodeDraftRegistrationsList.as_view(), name=views.NodeDraftRegistrationsList.view_name), url(r'^(?P<node_id>\w+)/draft_registrations/(?P<draft_id>\w+)/$', views.NodeDraftRegistrationDetail.as_view(), name=views.NodeDraftRegistrationDetail.view_name), url(r'^(?P<node_id>\w+)/files/$', views.NodeStorageProvidersList.as_view(), name=views.NodeStorageProvidersList.view_name), url(r'^(?P<node_id>\w+)/files/providers/(?P<provider>\w+)/?$', views.NodeStorageProviderDetail.as_view(), name=views.NodeStorageProviderDetail.view_name), url(r'^(?P<node_id>\w+)/files/(?P<provider>\w+)(?P<path>/(?:.*/)?)$', views.NodeFilesList.as_view(), name=views.NodeFilesList.view_name), url(r'^(?P<node_id>\w+)/files/(?P<provider>\w+)(?P<path>/.+[^/])$', views.NodeFileDetail.as_view(), name=views.NodeFileDetail.view_name), url(r'^(?P<node_id>\w+)/forks/$', views.NodeForksList.as_view(), name=views.NodeForksList.view_name), url(r'^(?P<node_id>\w+)/groups/$', views.NodeGroupsList.as_view(), name=views.NodeGroupsList.view_name), url(r'^(?P<node_id>\w+)/groups/(?P<group_id>\w+)/$', views.NodeGroupsDetail.as_view(), name=views.NodeGroupsDetail.view_name), url(r'^(?P<node_id>\w+)/identifiers/$', views.NodeIdentifierList.as_view(), name=views.NodeIdentifierList.view_name), url(r'^(?P<node_id>\w+)/institutions/$', views.NodeInstitutionsList.as_view(), name=views.NodeInstitutionsList.view_name), url(r'^(?P<node_id>\w+)/linked_nodes/$', views.LinkedNodesList.as_view(), name=views.LinkedNodesList.view_name), url(r'^(?P<node_id>\w+)/linked_registrations/$', views.NodeLinkedRegistrationsList.as_view(), name=views.NodeLinkedRegistrationsList.view_name), url(r'^(?P<node_id>\w+)/logs/$', views.NodeLogList.as_view(), name=views.NodeLogList.view_name), url(r'^(?P<node_id>\w+)/node_links/$', views.NodeLinksList.as_view(), name=views.NodeLinksList.view_name), url(r'^(?P<node_id>\w+)/node_links/(?P<node_link_id>\w+)/', views.NodeLinksDetail.as_view(), name=views.NodeLinksDetail.view_name), url(r'^(?P<node_id>\w+)/linked_by_nodes/$', views.NodeLinkedByNodesList.as_view(), name=views.NodeLinkedByNodesList.view_name), url(r'^(?P<node_id>\w+)/linked_by_registrations/$', views.NodeLinkedByRegistrationsList.as_view(), name=views.NodeLinkedByRegistrationsList.view_name), url(r'^(?P<node_id>\w+)/preprints/$', views.NodePreprintsList.as_view(), name=views.NodePreprintsList.view_name), url(r'^(?P<node_id>\w+)/registrations/$', views.NodeRegistrationsList.as_view(), name=views.NodeRegistrationsList.view_name), url(r'^(?P<node_id>\w+)/relationships/institutions/$', views.NodeInstitutionsRelationship.as_view(), name=views.NodeInstitutionsRelationship.view_name), url(r'^(?P<node_id>\w+)/relationships/linked_nodes/$', views.NodeLinkedNodesRelationship.as_view(), name=views.NodeLinkedNodesRelationship.view_name), url(r'^(?P<node_id>\w+)/relationships/linked_registrations/$', views.NodeLinkedRegistrationsRelationship.as_view(), name=views.NodeLinkedRegistrationsRelationship.view_name), url(r'^(?P<node_id>\w+)/relationships/subjects/$', views.NodeSubjectsRelationship.as_view(), name=views.NodeSubjectsRelationship.view_name), url(r'^(?P<node_id>\w+)/requests/$', views.NodeRequestListCreate.as_view(), name=views.NodeRequestListCreate.view_name), url(r'^(?P<node_id>\w+)/settings/$', views.NodeSettings.as_view(), name=views.NodeSettings.view_name), url(r'^(?P<node_id>\w+)/storage/$', views.NodeStorage.as_view(), name=views.NodeStorage.view_name), url(r'^(?P<node_id>\w+)/subjects/$', views.NodeSubjectsList.as_view(), name=views.NodeSubjectsList.view_name), url(r'^(?P<node_id>\w+)/view_only_links/$', views.NodeViewOnlyLinksList.as_view(), name=views.NodeViewOnlyLinksList.view_name), url(r'^(?P<node_id>\w+)/view_only_links/(?P<link_id>\w+)/$', views.NodeViewOnlyLinkDetail.as_view(), name=views.NodeViewOnlyLinkDetail.view_name), url(r'^(?P<node_id>\w+)/wikis/$', views.NodeWikiList.as_view(), name=views.NodeWikiList.view_name), ]
apache-2.0
[ 504, 1639, 14, 2190, 14, 3603, 492, 1166, 199, 199, 504, 2986, 14, 2415, 492, 6858, 199, 199, 571, 63, 354, 275, 283, 20923, 7, 199, 199, 20050, 275, 359, 272, 327, 6058, 26, 272, 327, 1166, 8, 82, 4289, 4268, 283, 1246, 14, 4196, 14, 4219, 297, 536, 534, 4219, 659, 272, 327, 1166, 8, 82, 4289, 11486, 3678, 2387, 360, 11486, 14, 3603, 3855, 272, 1166, 8, 82, 4289, 4268, 6858, 14, 29166, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 29166, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 4268, 6858, 14, 1716, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 10788, 10884, 6858, 14, 1716, 19654, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 19654, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 10788, 9448, 48, 28, 3780, 3072, 87, 18830, 4268, 6858, 14, 1716, 19654, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 19654, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 10788, 9448, 48, 28, 3780, 3072, 87, 18830, 15171, 10884, 6858, 14, 1716, 19654, 7850, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 19654, 7850, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 30892, 63, 21630, 10884, 6858, 14, 1716, 25217, 24623, 714, 1925, 6622, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 25217, 24623, 714, 1925, 6622, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 3223, 10884, 6858, 14, 1716, 7139, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 7139, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 6210, 10884, 6858, 14, 1716, 35, 5314, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 35, 5314, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 6210, 9448, 48, 28, 2487, 63, 344, 30, 1988, 60, 87, 24598, 4268, 6858, 14, 1716, 35, 5314, 6609, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 35, 5314, 6609, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 6223, 10884, 6858, 14, 1716, 18929, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 18929, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 21630, 63, 460, 63, 923, 63, 6334, 10884, 6858, 14, 1716, 714, 1925, 6622, 3325, 2448, 23056, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 714, 1925, 6622, 3325, 2448, 23056, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 11886, 63, 21630, 10884, 6858, 14, 1716, 8499, 3137, 714, 1925, 6622, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 8499, 3137, 714, 1925, 6622, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 21630, 10884, 6858, 14, 1716, 714, 1925, 6622, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 714, 1925, 6622, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 21630, 9448, 48, 28, 751, 63, 344, 3072, 87, 18830, 4268, 6858, 14, 1716, 714, 1925, 4139, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 714, 1925, 4139, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 7185, 63, 29440, 10884, 6858, 14, 1716, 18332, 2872, 631, 3801, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 18332, 2872, 631, 3801, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 7185, 63, 29440, 9448, 48, 28, 7185, 63, 344, 3072, 87, 18830, 4268, 6858, 14, 1716, 18332, 11757, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 18332, 11757, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 1725, 10884, 6858, 14, 1716, 6408, 6663, 83, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 6408, 6663, 83, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 1725, 15, 9710, 9448, 48, 28, 3780, 3072, 87, 18830, 31, 4268, 6858, 14, 1716, 6408, 6663, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 6408, 6663, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 1725, 9448, 48, 28, 3780, 3072, 87, 8771, 2229, 48, 28, 515, 12202, 5169, 2795, 15, 5547, 29150, 6858, 14, 1716, 5535, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 5535, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 1725, 9448, 48, 28, 3780, 3072, 87, 8771, 2229, 48, 28, 515, 12202, 6977, 4735, 15, 566, 4268, 6858, 14, 1716, 1173, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 1173, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 509, 6080, 10884, 6858, 14, 1716, 1858, 6080, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 1858, 6080, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 2634, 10884, 6858, 14, 1716, 10177, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 10177, 1296, 14, 1345, 63, 354, 395, 272 ]
[ 1639, 14, 2190, 14, 3603, 492, 1166, 199, 199, 504, 2986, 14, 2415, 492, 6858, 199, 199, 571, 63, 354, 275, 283, 20923, 7, 199, 199, 20050, 275, 359, 272, 327, 6058, 26, 272, 327, 1166, 8, 82, 4289, 4268, 283, 1246, 14, 4196, 14, 4219, 297, 536, 534, 4219, 659, 272, 327, 1166, 8, 82, 4289, 11486, 3678, 2387, 360, 11486, 14, 3603, 3855, 272, 1166, 8, 82, 4289, 4268, 6858, 14, 29166, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 29166, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 4268, 6858, 14, 1716, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 10788, 10884, 6858, 14, 1716, 19654, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 19654, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 10788, 9448, 48, 28, 3780, 3072, 87, 18830, 4268, 6858, 14, 1716, 19654, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 19654, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 10788, 9448, 48, 28, 3780, 3072, 87, 18830, 15171, 10884, 6858, 14, 1716, 19654, 7850, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 19654, 7850, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 30892, 63, 21630, 10884, 6858, 14, 1716, 25217, 24623, 714, 1925, 6622, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 25217, 24623, 714, 1925, 6622, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 3223, 10884, 6858, 14, 1716, 7139, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 7139, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 6210, 10884, 6858, 14, 1716, 35, 5314, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 35, 5314, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 6210, 9448, 48, 28, 2487, 63, 344, 30, 1988, 60, 87, 24598, 4268, 6858, 14, 1716, 35, 5314, 6609, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 35, 5314, 6609, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 6223, 10884, 6858, 14, 1716, 18929, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 18929, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 21630, 63, 460, 63, 923, 63, 6334, 10884, 6858, 14, 1716, 714, 1925, 6622, 3325, 2448, 23056, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 714, 1925, 6622, 3325, 2448, 23056, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 11886, 63, 21630, 10884, 6858, 14, 1716, 8499, 3137, 714, 1925, 6622, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 8499, 3137, 714, 1925, 6622, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 21630, 10884, 6858, 14, 1716, 714, 1925, 6622, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 714, 1925, 6622, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 21630, 9448, 48, 28, 751, 63, 344, 3072, 87, 18830, 4268, 6858, 14, 1716, 714, 1925, 4139, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 714, 1925, 4139, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 7185, 63, 29440, 10884, 6858, 14, 1716, 18332, 2872, 631, 3801, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 18332, 2872, 631, 3801, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 7185, 63, 29440, 9448, 48, 28, 7185, 63, 344, 3072, 87, 18830, 4268, 6858, 14, 1716, 18332, 11757, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 18332, 11757, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 1725, 10884, 6858, 14, 1716, 6408, 6663, 83, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 6408, 6663, 83, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 1725, 15, 9710, 9448, 48, 28, 3780, 3072, 87, 18830, 31, 4268, 6858, 14, 1716, 6408, 6663, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 6408, 6663, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 1725, 9448, 48, 28, 3780, 3072, 87, 8771, 2229, 48, 28, 515, 12202, 5169, 2795, 15, 5547, 29150, 6858, 14, 1716, 5535, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 5535, 1296, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 1725, 9448, 48, 28, 3780, 3072, 87, 8771, 2229, 48, 28, 515, 12202, 6977, 4735, 15, 566, 4268, 6858, 14, 1716, 1173, 8064, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 1173, 8064, 14, 1345, 63, 354, 395, 272, 1166, 8, 82, 24550, 48, 28, 932, 63, 344, 3072, 87, 18830, 509, 6080, 10884, 6858, 14, 1716, 1858, 6080, 1296, 14, 305, 63, 1345, 1062, 536, 29, 4196, 14, 1716, 1858, 6080, 1296, 14, 1345, 63, 354, 395, 272,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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 ]
dsolimando/Hot
hot-jython-modules/src/main/resources/email/test/test_email_renamed.py
134
118811
# Copyright (C) 2001-2007 Python Software Foundation # Contact: email-sig@python.org # email package unit tests import os import sys import time import base64 import difflib import unittest import warnings from cStringIO import StringIO import email from email.charset import Charset from email.header import Header, decode_header, make_header from email.parser import Parser, HeaderParser from email.generator import Generator, DecodedGenerator from email.message import Message from email.mime.application import MIMEApplication from email.mime.audio import MIMEAudio from email.mime.text import MIMEText from email.mime.image import MIMEImage from email.mime.base import MIMEBase from email.mime.message import MIMEMessage from email.mime.multipart import MIMEMultipart from email import utils from email import errors from email import encoders from email import iterators from email import base64mime from email import quoprimime from test.test_support import findfile, run_unittest from email.test import __file__ as landmark NL = '\n' EMPTYSTRING = '' SPACE = ' ' def openfile(filename, mode='r'): path = os.path.join(os.path.dirname(landmark), 'data', filename) return open(path, mode) # Base test class class TestEmailBase(unittest.TestCase): def ndiffAssertEqual(self, first, second): """Like failUnlessEqual except use ndiff for readable output.""" if first <> second: sfirst = str(first) ssecond = str(second) diff = difflib.ndiff(sfirst.splitlines(), ssecond.splitlines()) fp = StringIO() print >> fp, NL, NL.join(diff) raise self.failureException, fp.getvalue() def _msgobj(self, filename): fp = openfile(findfile(filename)) try: msg = email.message_from_file(fp) finally: fp.close() return msg # Test various aspects of the Message class's API class TestMessageAPI(TestEmailBase): def test_get_all(self): eq = self.assertEqual msg = self._msgobj('msg_20.txt') eq(msg.get_all('cc'), ['ccc@zzz.org', 'ddd@zzz.org', 'eee@zzz.org']) eq(msg.get_all('xx', 'n/a'), 'n/a') def test_getset_charset(self): eq = self.assertEqual msg = Message() eq(msg.get_charset(), None) charset = Charset('iso-8859-1') msg.set_charset(charset) eq(msg['mime-version'], '1.0') eq(msg.get_content_type(), 'text/plain') eq(msg['content-type'], 'text/plain; charset="iso-8859-1"') eq(msg.get_param('charset'), 'iso-8859-1') eq(msg['content-transfer-encoding'], 'quoted-printable') eq(msg.get_charset().input_charset, 'iso-8859-1') # Remove the charset msg.set_charset(None) eq(msg.get_charset(), None) eq(msg['content-type'], 'text/plain') # Try adding a charset when there's already MIME headers present msg = Message() msg['MIME-Version'] = '2.0' msg['Content-Type'] = 'text/x-weird' msg['Content-Transfer-Encoding'] = 'quinted-puntable' msg.set_charset(charset) eq(msg['mime-version'], '2.0') eq(msg['content-type'], 'text/x-weird; charset="iso-8859-1"') eq(msg['content-transfer-encoding'], 'quinted-puntable') def test_set_charset_from_string(self): eq = self.assertEqual msg = Message() msg.set_charset('us-ascii') eq(msg.get_charset().input_charset, 'us-ascii') eq(msg['content-type'], 'text/plain; charset="us-ascii"') def test_set_payload_with_charset(self): msg = Message() charset = Charset('iso-8859-1') msg.set_payload('This is a string payload', charset) self.assertEqual(msg.get_charset().input_charset, 'iso-8859-1') def test_get_charsets(self): eq = self.assertEqual msg = self._msgobj('msg_08.txt') charsets = msg.get_charsets() eq(charsets, [None, 'us-ascii', 'iso-8859-1', 'iso-8859-2', 'koi8-r']) msg = self._msgobj('msg_09.txt') charsets = msg.get_charsets('dingbat') eq(charsets, ['dingbat', 'us-ascii', 'iso-8859-1', 'dingbat', 'koi8-r']) msg = self._msgobj('msg_12.txt') charsets = msg.get_charsets() eq(charsets, [None, 'us-ascii', 'iso-8859-1', None, 'iso-8859-2', 'iso-8859-3', 'us-ascii', 'koi8-r']) def test_get_filename(self): eq = self.assertEqual msg = self._msgobj('msg_04.txt') filenames = [p.get_filename() for p in msg.get_payload()] eq(filenames, ['msg.txt', 'msg.txt']) msg = self._msgobj('msg_07.txt') subpart = msg.get_payload(1) eq(subpart.get_filename(), 'dingusfish.gif') def test_get_filename_with_name_parameter(self): eq = self.assertEqual msg = self._msgobj('msg_44.txt') filenames = [p.get_filename() for p in msg.get_payload()] eq(filenames, ['msg.txt', 'msg.txt']) def test_get_boundary(self): eq = self.assertEqual msg = self._msgobj('msg_07.txt') # No quotes! eq(msg.get_boundary(), 'BOUNDARY') def test_set_boundary(self): eq = self.assertEqual # This one has no existing boundary parameter, but the Content-Type: # header appears fifth. msg = self._msgobj('msg_01.txt') msg.set_boundary('BOUNDARY') header, value = msg.items()[4] eq(header.lower(), 'content-type') eq(value, 'text/plain; charset="us-ascii"; boundary="BOUNDARY"') # This one has a Content-Type: header, with a boundary, stuck in the # middle of its headers. Make sure the order is preserved; it should # be fifth. msg = self._msgobj('msg_04.txt') msg.set_boundary('BOUNDARY') header, value = msg.items()[4] eq(header.lower(), 'content-type') eq(value, 'multipart/mixed; boundary="BOUNDARY"') # And this one has no Content-Type: header at all. msg = self._msgobj('msg_03.txt') self.assertRaises(errors.HeaderParseError, msg.set_boundary, 'BOUNDARY') def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=True), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=True), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=True), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=True), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=True), 'This has no Content-Transfer-Encoding: header.\n') def test_get_decoded_uu_payload(self): eq = self.assertEqual msg = Message() msg.set_payload('begin 666 -\n+:&5L;&\\@=V]R;&0 \n \nend\n') for cte in ('x-uuencode', 'uuencode', 'uue', 'x-uue'): msg['content-transfer-encoding'] = cte eq(msg.get_payload(decode=True), 'hello world') # Now try some bogus data msg.set_payload('foo') eq(msg.get_payload(decode=True), 'foo') def test_decoded_generator(self): eq = self.assertEqual msg = self._msgobj('msg_07.txt') fp = openfile('msg_17.txt') try: text = fp.read() finally: fp.close() s = StringIO() g = DecodedGenerator(s) g.flatten(msg) eq(s.getvalue(), text) def test__contains__(self): msg = Message() msg['From'] = 'Me' msg['to'] = 'You' # Check for case insensitivity self.failUnless('from' in msg) self.failUnless('From' in msg) self.failUnless('FROM' in msg) self.failUnless('to' in msg) self.failUnless('To' in msg) self.failUnless('TO' in msg) def test_as_string(self): eq = self.assertEqual msg = self._msgobj('msg_01.txt') fp = openfile('msg_01.txt') try: text = fp.read() finally: fp.close() eq(text, msg.as_string()) fullrepr = str(msg) lines = fullrepr.split('\n') self.failUnless(lines[0].startswith('From ')) eq(text, NL.join(lines[1:])) def test_bad_param(self): msg = email.message_from_string("Content-Type: blarg; baz; boo\n") self.assertEqual(msg.get_param('baz'), '') def test_missing_filename(self): msg = email.message_from_string("From: foo\n") self.assertEqual(msg.get_filename(), None) def test_bogus_filename(self): msg = email.message_from_string( "Content-Disposition: blarg; filename\n") self.assertEqual(msg.get_filename(), '') def test_missing_boundary(self): msg = email.message_from_string("From: foo\n") self.assertEqual(msg.get_boundary(), None) def test_get_params(self): eq = self.assertEqual msg = email.message_from_string( 'X-Header: foo=one; bar=two; baz=three\n') eq(msg.get_params(header='x-header'), [('foo', 'one'), ('bar', 'two'), ('baz', 'three')]) msg = email.message_from_string( 'X-Header: foo; bar=one; baz=two\n') eq(msg.get_params(header='x-header'), [('foo', ''), ('bar', 'one'), ('baz', 'two')]) eq(msg.get_params(), None) msg = email.message_from_string( 'X-Header: foo; bar="one"; baz=two\n') eq(msg.get_params(header='x-header'), [('foo', ''), ('bar', 'one'), ('baz', 'two')]) def test_get_param_liberal(self): msg = Message() msg['Content-Type'] = 'Content-Type: Multipart/mixed; boundary = "CPIMSSMTPC06p5f3tG"' self.assertEqual(msg.get_param('boundary'), 'CPIMSSMTPC06p5f3tG') def test_get_param(self): eq = self.assertEqual msg = email.message_from_string( "X-Header: foo=one; bar=two; baz=three\n") eq(msg.get_param('bar', header='x-header'), 'two') eq(msg.get_param('quuz', header='x-header'), None) eq(msg.get_param('quuz'), None) msg = email.message_from_string( 'X-Header: foo; bar="one"; baz=two\n') eq(msg.get_param('foo', header='x-header'), '') eq(msg.get_param('bar', header='x-header'), 'one') eq(msg.get_param('baz', header='x-header'), 'two') # XXX: We are not RFC-2045 compliant! We cannot parse: # msg["Content-Type"] = 'text/plain; weird="hey; dolly? [you] @ <\\"home\\">?"' # msg.get_param("weird") # yet. def test_get_param_funky_continuation_lines(self): msg = self._msgobj('msg_22.txt') self.assertEqual(msg.get_payload(1).get_param('name'), 'wibble.JPG') def test_get_param_with_semis_in_quotes(self): msg = email.message_from_string( 'Content-Type: image/pjpeg; name="Jim&amp;&amp;Jill"\n') self.assertEqual(msg.get_param('name'), 'Jim&amp;&amp;Jill') self.assertEqual(msg.get_param('name', unquote=False), '"Jim&amp;&amp;Jill"') def test_has_key(self): msg = email.message_from_string('Header: exists') self.failUnless(msg.has_key('header')) self.failUnless(msg.has_key('Header')) self.failUnless(msg.has_key('HEADER')) self.failIf(msg.has_key('headeri')) def test_set_param(self): eq = self.assertEqual msg = Message() msg.set_param('charset', 'iso-2022-jp') eq(msg.get_param('charset'), 'iso-2022-jp') msg.set_param('importance', 'high value') eq(msg.get_param('importance'), 'high value') eq(msg.get_param('importance', unquote=False), '"high value"') eq(msg.get_params(), [('text/plain', ''), ('charset', 'iso-2022-jp'), ('importance', 'high value')]) eq(msg.get_params(unquote=False), [('text/plain', ''), ('charset', '"iso-2022-jp"'), ('importance', '"high value"')]) msg.set_param('charset', 'iso-9999-xx', header='X-Jimmy') eq(msg.get_param('charset', header='X-Jimmy'), 'iso-9999-xx') def test_del_param(self): eq = self.assertEqual msg = self._msgobj('msg_05.txt') eq(msg.get_params(), [('multipart/report', ''), ('report-type', 'delivery-status'), ('boundary', 'D1690A7AC1.996856090/mail.example.com')]) old_val = msg.get_param("report-type") msg.del_param("report-type") eq(msg.get_params(), [('multipart/report', ''), ('boundary', 'D1690A7AC1.996856090/mail.example.com')]) msg.set_param("report-type", old_val) eq(msg.get_params(), [('multipart/report', ''), ('boundary', 'D1690A7AC1.996856090/mail.example.com'), ('report-type', old_val)]) def test_del_param_on_other_header(self): msg = Message() msg.add_header('Content-Disposition', 'attachment', filename='bud.gif') msg.del_param('filename', 'content-disposition') self.assertEqual(msg['content-disposition'], 'attachment') def test_set_type(self): eq = self.assertEqual msg = Message() self.assertRaises(ValueError, msg.set_type, 'text') msg.set_type('text/plain') eq(msg['content-type'], 'text/plain') msg.set_param('charset', 'us-ascii') eq(msg['content-type'], 'text/plain; charset="us-ascii"') msg.set_type('text/html') eq(msg['content-type'], 'text/html; charset="us-ascii"') def test_set_type_on_other_header(self): msg = Message() msg['X-Content-Type'] = 'text/plain' msg.set_type('application/octet-stream', 'X-Content-Type') self.assertEqual(msg['x-content-type'], 'application/octet-stream') def test_get_content_type_missing(self): msg = Message() self.assertEqual(msg.get_content_type(), 'text/plain') def test_get_content_type_missing_with_default_type(self): msg = Message() msg.set_default_type('message/rfc822') self.assertEqual(msg.get_content_type(), 'message/rfc822') def test_get_content_type_from_message_implicit(self): msg = self._msgobj('msg_30.txt') self.assertEqual(msg.get_payload(0).get_content_type(), 'message/rfc822') def test_get_content_type_from_message_explicit(self): msg = self._msgobj('msg_28.txt') self.assertEqual(msg.get_payload(0).get_content_type(), 'message/rfc822') def test_get_content_type_from_message_text_plain_implicit(self): msg = self._msgobj('msg_03.txt') self.assertEqual(msg.get_content_type(), 'text/plain') def test_get_content_type_from_message_text_plain_explicit(self): msg = self._msgobj('msg_01.txt') self.assertEqual(msg.get_content_type(), 'text/plain') def test_get_content_maintype_missing(self): msg = Message() self.assertEqual(msg.get_content_maintype(), 'text') def test_get_content_maintype_missing_with_default_type(self): msg = Message() msg.set_default_type('message/rfc822') self.assertEqual(msg.get_content_maintype(), 'message') def test_get_content_maintype_from_message_implicit(self): msg = self._msgobj('msg_30.txt') self.assertEqual(msg.get_payload(0).get_content_maintype(), 'message') def test_get_content_maintype_from_message_explicit(self): msg = self._msgobj('msg_28.txt') self.assertEqual(msg.get_payload(0).get_content_maintype(), 'message') def test_get_content_maintype_from_message_text_plain_implicit(self): msg = self._msgobj('msg_03.txt') self.assertEqual(msg.get_content_maintype(), 'text') def test_get_content_maintype_from_message_text_plain_explicit(self): msg = self._msgobj('msg_01.txt') self.assertEqual(msg.get_content_maintype(), 'text') def test_get_content_subtype_missing(self): msg = Message() self.assertEqual(msg.get_content_subtype(), 'plain') def test_get_content_subtype_missing_with_default_type(self): msg = Message() msg.set_default_type('message/rfc822') self.assertEqual(msg.get_content_subtype(), 'rfc822') def test_get_content_subtype_from_message_implicit(self): msg = self._msgobj('msg_30.txt') self.assertEqual(msg.get_payload(0).get_content_subtype(), 'rfc822') def test_get_content_subtype_from_message_explicit(self): msg = self._msgobj('msg_28.txt') self.assertEqual(msg.get_payload(0).get_content_subtype(), 'rfc822') def test_get_content_subtype_from_message_text_plain_implicit(self): msg = self._msgobj('msg_03.txt') self.assertEqual(msg.get_content_subtype(), 'plain') def test_get_content_subtype_from_message_text_plain_explicit(self): msg = self._msgobj('msg_01.txt') self.assertEqual(msg.get_content_subtype(), 'plain') def test_get_content_maintype_error(self): msg = Message() msg['Content-Type'] = 'no-slash-in-this-string' self.assertEqual(msg.get_content_maintype(), 'text') def test_get_content_subtype_error(self): msg = Message() msg['Content-Type'] = 'no-slash-in-this-string' self.assertEqual(msg.get_content_subtype(), 'plain') def test_replace_header(self): eq = self.assertEqual msg = Message() msg.add_header('First', 'One') msg.add_header('Second', 'Two') msg.add_header('Third', 'Three') eq(msg.keys(), ['First', 'Second', 'Third']) eq(msg.values(), ['One', 'Two', 'Three']) msg.replace_header('Second', 'Twenty') eq(msg.keys(), ['First', 'Second', 'Third']) eq(msg.values(), ['One', 'Twenty', 'Three']) msg.add_header('First', 'Eleven') msg.replace_header('First', 'One Hundred') eq(msg.keys(), ['First', 'Second', 'Third', 'First']) eq(msg.values(), ['One Hundred', 'Twenty', 'Three', 'Eleven']) self.assertRaises(KeyError, msg.replace_header, 'Fourth', 'Missing') def test_broken_base64_payload(self): x = 'AwDp0P7//y6LwKEAcPa/6Q=9' msg = Message() msg['content-type'] = 'audio/x-midi' msg['content-transfer-encoding'] = 'base64' msg.set_payload(x) self.assertEqual(msg.get_payload(decode=True), x) # Test the email.encoders module class TestEncoders(unittest.TestCase): def test_encode_empty_payload(self): eq = self.assertEqual msg = Message() msg.set_charset('us-ascii') eq(msg['content-transfer-encoding'], '7bit') def test_default_cte(self): eq = self.assertEqual msg = MIMEText('hello world') eq(msg['content-transfer-encoding'], '7bit') def test_default_cte(self): eq = self.assertEqual # With no explicit _charset its us-ascii, and all are 7-bit msg = MIMEText('hello world') eq(msg['content-transfer-encoding'], '7bit') # Similar, but with 8-bit data msg = MIMEText('hello \xf8 world') eq(msg['content-transfer-encoding'], '8bit') # And now with a different charset msg = MIMEText('hello \xf8 world', _charset='iso-8859-1') eq(msg['content-transfer-encoding'], 'quoted-printable') # Test long header wrapping class TestLongHeaders(TestEmailBase): def test_split_long_continuation(self): eq = self.ndiffAssertEqual msg = email.message_from_string("""\ Subject: bug demonstration \t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 \tmore text test """) sfp = StringIO() g = Generator(sfp) g.flatten(msg) eq(sfp.getvalue(), """\ Subject: bug demonstration \t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 \tmore text test """) def test_another_long_almost_unsplittable_header(self): eq = self.ndiffAssertEqual hstr = """\ bug demonstration \t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 \tmore text""" h = Header(hstr, continuation_ws='\t') eq(h.encode(), """\ bug demonstration \t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 \tmore text""") h = Header(hstr) eq(h.encode(), """\ bug demonstration 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 more text""") def test_long_nonstring(self): eq = self.ndiffAssertEqual g = Charset("iso-8859-1") cz = Charset("iso-8859-2") utf8 = Charset("utf-8") g_head = "Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an s\xfcdl\xfcndischen Wandgem\xe4lden vorbei, gegen die rotierenden Klingen bef\xf6rdert. " cz_head = "Finan\xe8ni metropole se hroutily pod tlakem jejich d\xf9vtipu.. " utf8_head = u"\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u4e00\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.\u300d\u3068\u8a00\u3063\u3066\u3044\u307e\u3059\u3002".encode("utf-8") h = Header(g_head, g, header_name='Subject') h.append(cz_head, cz) h.append(utf8_head, utf8) msg = Message() msg['Subject'] = h sfp = StringIO() g = Generator(sfp) g.flatten(msg) eq(sfp.getvalue(), """\ Subject: =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerd?= =?iso-8859-1?q?erband_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndi?= =?iso-8859-1?q?schen_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Kling?= =?iso-8859-1?q?en_bef=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_met?= =?iso-8859-2?q?ropole_se_hroutily_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE?= =?utf-8?b?44G+44Gb44KT44CC5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB?= =?utf-8?b?44GC44Go44Gv44Gn44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CM?= =?utf-8?q?Wenn_ist_das_Nunstuck_git_und_Slotermeyer=3F_Ja!_Beiherhund_das?= =?utf-8?b?IE9kZXIgZGllIEZsaXBwZXJ3YWxkdCBnZXJzcHV0LuOAjeOBqOiogOOBow==?= =?utf-8?b?44Gm44GE44G+44GZ44CC?= """) eq(h.encode(), """\ =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerd?= =?iso-8859-1?q?erband_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndi?= =?iso-8859-1?q?schen_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Kling?= =?iso-8859-1?q?en_bef=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_met?= =?iso-8859-2?q?ropole_se_hroutily_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE?= =?utf-8?b?44G+44Gb44KT44CC5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB?= =?utf-8?b?44GC44Go44Gv44Gn44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CM?= =?utf-8?q?Wenn_ist_das_Nunstuck_git_und_Slotermeyer=3F_Ja!_Beiherhund_das?= =?utf-8?b?IE9kZXIgZGllIEZsaXBwZXJ3YWxkdCBnZXJzcHV0LuOAjeOBqOiogOOBow==?= =?utf-8?b?44Gm44GE44G+44GZ44CC?=""") def test_long_header_encode(self): eq = self.ndiffAssertEqual h = Header('wasnipoop; giraffes="very-long-necked-animals"; ' 'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"', header_name='X-Foobar-Spoink-Defrobnit') eq(h.encode(), '''\ wasnipoop; giraffes="very-long-necked-animals"; spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''') def test_long_header_encode_with_tab_continuation(self): eq = self.ndiffAssertEqual h = Header('wasnipoop; giraffes="very-long-necked-animals"; ' 'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"', header_name='X-Foobar-Spoink-Defrobnit', continuation_ws='\t') eq(h.encode(), '''\ wasnipoop; giraffes="very-long-necked-animals"; \tspooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''') def test_header_splitter(self): eq = self.ndiffAssertEqual msg = MIMEText('') # It'd be great if we could use add_header() here, but that doesn't # guarantee an order of the parameters. msg['X-Foobar-Spoink-Defrobnit'] = ( 'wasnipoop; giraffes="very-long-necked-animals"; ' 'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"') sfp = StringIO() g = Generator(sfp) g.flatten(msg) eq(sfp.getvalue(), '''\ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Foobar-Spoink-Defrobnit: wasnipoop; giraffes="very-long-necked-animals"; \tspooge="yummy"; hippos="gargantuan"; marshmallows="gooey" ''') def test_no_semis_header_splitter(self): eq = self.ndiffAssertEqual msg = Message() msg['From'] = 'test@dom.ain' msg['References'] = SPACE.join(['<%d@dom.ain>' % i for i in range(10)]) msg.set_payload('Test') sfp = StringIO() g = Generator(sfp) g.flatten(msg) eq(sfp.getvalue(), """\ From: test@dom.ain References: <0@dom.ain> <1@dom.ain> <2@dom.ain> <3@dom.ain> <4@dom.ain> \t<5@dom.ain> <6@dom.ain> <7@dom.ain> <8@dom.ain> <9@dom.ain> Test""") def test_no_split_long_header(self): eq = self.ndiffAssertEqual hstr = 'References: ' + 'x' * 80 h = Header(hstr, continuation_ws='\t') eq(h.encode(), """\ References: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx""") def test_splitting_multiple_long_lines(self): eq = self.ndiffAssertEqual hstr = """\ from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST) \tfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST) \tfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST) """ h = Header(hstr, continuation_ws='\t') eq(h.encode(), """\ from babylon.socal-raves.org (localhost [127.0.0.1]); \tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; \tfor <mailman-admin@babylon.socal-raves.org>; \tSat, 2 Feb 2002 17:00:06 -0800 (PST) \tfrom babylon.socal-raves.org (localhost [127.0.0.1]); \tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; \tfor <mailman-admin@babylon.socal-raves.org>; \tSat, 2 Feb 2002 17:00:06 -0800 (PST) \tfrom babylon.socal-raves.org (localhost [127.0.0.1]); \tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; \tfor <mailman-admin@babylon.socal-raves.org>; \tSat, 2 Feb 2002 17:00:06 -0800 (PST)""") def test_splitting_first_line_only_is_long(self): eq = self.ndiffAssertEqual hstr = """\ from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93] helo=cthulhu.gerg.ca) \tby kronos.mems-exchange.org with esmtp (Exim 4.05) \tid 17k4h5-00034i-00 \tfor test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400""" h = Header(hstr, maxlinelen=78, header_name='Received', continuation_ws='\t') eq(h.encode(), """\ from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93] \thelo=cthulhu.gerg.ca) \tby kronos.mems-exchange.org with esmtp (Exim 4.05) \tid 17k4h5-00034i-00 \tfor test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400""") def test_long_8bit_header(self): eq = self.ndiffAssertEqual msg = Message() h = Header('Britische Regierung gibt', 'iso-8859-1', header_name='Subject') h.append('gr\xfcnes Licht f\xfcr Offshore-Windkraftprojekte') msg['Subject'] = h eq(msg.as_string(), """\ Subject: =?iso-8859-1?q?Britische_Regierung_gibt?= =?iso-8859-1?q?gr=FCnes?= =?iso-8859-1?q?_Licht_f=FCr_Offshore-Windkraftprojekte?= """) def test_long_8bit_header_no_charset(self): eq = self.ndiffAssertEqual msg = Message() msg['Reply-To'] = 'Britische Regierung gibt gr\xfcnes Licht f\xfcr Offshore-Windkraftprojekte <a-very-long-address@example.com>' eq(msg.as_string(), """\ Reply-To: Britische Regierung gibt gr\xfcnes Licht f\xfcr Offshore-Windkraftprojekte <a-very-long-address@example.com> """) def test_long_to_header(self): eq = self.ndiffAssertEqual to = '"Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>,"Someone Test #B" <someone@umich.edu>, "Someone Test #C" <someone@eecs.umich.edu>, "Someone Test #D" <someone@eecs.umich.edu>' msg = Message() msg['To'] = to eq(msg.as_string(0), '''\ To: "Someone Test #A" <someone@eecs.umich.edu>, <someone@eecs.umich.edu>, \t"Someone Test #B" <someone@umich.edu>, \t"Someone Test #C" <someone@eecs.umich.edu>, \t"Someone Test #D" <someone@eecs.umich.edu> ''') def test_long_line_after_append(self): eq = self.ndiffAssertEqual s = 'This is an example of string which has almost the limit of header length.' h = Header(s) h.append('Add another line.') eq(h.encode(), """\ This is an example of string which has almost the limit of header length. Add another line.""") def test_shorter_line_with_append(self): eq = self.ndiffAssertEqual s = 'This is a shorter line.' h = Header(s) h.append('Add another sentence. (Surprise?)') eq(h.encode(), 'This is a shorter line. Add another sentence. (Surprise?)') def test_long_field_name(self): eq = self.ndiffAssertEqual fn = 'X-Very-Very-Very-Long-Header-Name' gs = "Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an s\xfcdl\xfcndischen Wandgem\xe4lden vorbei, gegen die rotierenden Klingen bef\xf6rdert. " h = Header(gs, 'iso-8859-1', header_name=fn) # BAW: this seems broken because the first line is too long eq(h.encode(), """\ =?iso-8859-1?q?Die_Mieter_treten_hier_?= =?iso-8859-1?q?ein_werden_mit_einem_Foerderband_komfortabel_den_Korridor_?= =?iso-8859-1?q?entlang=2C_an_s=FCdl=FCndischen_Wandgem=E4lden_vorbei=2C_g?= =?iso-8859-1?q?egen_die_rotierenden_Klingen_bef=F6rdert=2E_?=""") def test_long_received_header(self): h = 'from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP; Wed, 05 Mar 2003 18:10:18 -0700' msg = Message() msg['Received-1'] = Header(h, continuation_ws='\t') msg['Received-2'] = h self.assertEqual(msg.as_string(), """\ Received-1: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by \throthgar.la.mastaler.com (tmda-ofmipd) with ESMTP; \tWed, 05 Mar 2003 18:10:18 -0700 Received-2: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by \throthgar.la.mastaler.com (tmda-ofmipd) with ESMTP; \tWed, 05 Mar 2003 18:10:18 -0700 """) def test_string_headerinst_eq(self): h = '<15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David Bremner\'s message of "Thu, 6 Mar 2003 13:58:21 +0100")' msg = Message() msg['Received-1'] = Header(h, header_name='Received-1', continuation_ws='\t') msg['Received-2'] = h self.assertEqual(msg.as_string(), """\ Received-1: <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> \t(David Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100") Received-2: <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> \t(David Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100") """) def test_long_unbreakable_lines_with_continuation(self): eq = self.ndiffAssertEqual msg = Message() t = """\ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp""" msg['Face-1'] = t msg['Face-2'] = Header(t, header_name='Face-2') eq(msg.as_string(), """\ Face-1: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9 \tlocQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp Face-2: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp """) def test_another_long_multiline_header(self): eq = self.ndiffAssertEqual m = '''\ Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with Microsoft SMTPSVC(5.0.2195.4905); \tWed, 16 Oct 2002 07:41:11 -0700''' msg = email.message_from_string(m) eq(msg.as_string(), '''\ Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with \tMicrosoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700 ''') def test_long_lines_with_different_header(self): eq = self.ndiffAssertEqual h = """\ List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/spamassassin-talk>, <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>""" msg = Message() msg['List'] = h msg['List'] = Header(h, header_name='List') eq(msg.as_string(), """\ List: List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/spamassassin-talk>, \t<mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe> List: List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/spamassassin-talk>, <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe> """) # Test mangling of "From " lines in the body of a message class TestFromMangling(unittest.TestCase): def setUp(self): self.msg = Message() self.msg['From'] = 'aaa@bbb.org' self.msg.set_payload("""\ From the desk of A.A.A.: Blah blah blah """) def test_mangled_from(self): s = StringIO() g = Generator(s, mangle_from_=True) g.flatten(self.msg) self.assertEqual(s.getvalue(), """\ From: aaa@bbb.org >From the desk of A.A.A.: Blah blah blah """) def test_dont_mangle_from(self): s = StringIO() g = Generator(s, mangle_from_=False) g.flatten(self.msg) self.assertEqual(s.getvalue(), """\ From: aaa@bbb.org From the desk of A.A.A.: Blah blah blah """) # Test the basic MIMEAudio class class TestMIMEAudio(unittest.TestCase): def setUp(self): # Make sure we pick up the audiotest.au that lives in email/test/data. # In Python, there's an audiotest.au living in Lib/test but that isn't # included in some binary distros that don't include the test # package. The trailing empty string on the .join() is significant # since findfile() will do a dirname(). datadir = os.path.join(os.path.dirname(landmark), 'data', '') fp = open(findfile('audiotest.au', datadir), 'rb') try: self._audiodata = fp.read() finally: fp.close() self._au = MIMEAudio(self._audiodata) def test_guess_minor_type(self): self.assertEqual(self._au.get_content_type(), 'audio/basic') def test_encoding(self): payload = self._au.get_payload() self.assertEqual(base64.decodestring(payload), self._audiodata) def test_checkSetMinor(self): au = MIMEAudio(self._audiodata, 'fish') self.assertEqual(au.get_content_type(), 'audio/fish') def test_add_header(self): eq = self.assertEqual unless = self.failUnless self._au.add_header('Content-Disposition', 'attachment', filename='audiotest.au') eq(self._au['content-disposition'], 'attachment; filename="audiotest.au"') eq(self._au.get_params(header='content-disposition'), [('attachment', ''), ('filename', 'audiotest.au')]) eq(self._au.get_param('filename', header='content-disposition'), 'audiotest.au') missing = [] eq(self._au.get_param('attachment', header='content-disposition'), '') unless(self._au.get_param('foo', failobj=missing, header='content-disposition') is missing) # Try some missing stuff unless(self._au.get_param('foobar', missing) is missing) unless(self._au.get_param('attachment', missing, header='foobar') is missing) # Test the basic MIMEImage class class TestMIMEImage(unittest.TestCase): def setUp(self): fp = openfile('PyBanner048.gif') try: self._imgdata = fp.read() finally: fp.close() self._im = MIMEImage(self._imgdata) def test_guess_minor_type(self): self.assertEqual(self._im.get_content_type(), 'image/gif') def test_encoding(self): payload = self._im.get_payload() self.assertEqual(base64.decodestring(payload), self._imgdata) def test_checkSetMinor(self): im = MIMEImage(self._imgdata, 'fish') self.assertEqual(im.get_content_type(), 'image/fish') def test_add_header(self): eq = self.assertEqual unless = self.failUnless self._im.add_header('Content-Disposition', 'attachment', filename='dingusfish.gif') eq(self._im['content-disposition'], 'attachment; filename="dingusfish.gif"') eq(self._im.get_params(header='content-disposition'), [('attachment', ''), ('filename', 'dingusfish.gif')]) eq(self._im.get_param('filename', header='content-disposition'), 'dingusfish.gif') missing = [] eq(self._im.get_param('attachment', header='content-disposition'), '') unless(self._im.get_param('foo', failobj=missing, header='content-disposition') is missing) # Try some missing stuff unless(self._im.get_param('foobar', missing) is missing) unless(self._im.get_param('attachment', missing, header='foobar') is missing) # Test the basic MIMEApplication class class TestMIMEApplication(unittest.TestCase): def test_headers(self): eq = self.assertEqual msg = MIMEApplication('\xfa\xfb\xfc\xfd\xfe\xff') eq(msg.get_content_type(), 'application/octet-stream') eq(msg['content-transfer-encoding'], 'base64') def test_body(self): eq = self.assertEqual bytes = '\xfa\xfb\xfc\xfd\xfe\xff' msg = MIMEApplication(bytes) eq(msg.get_payload(), '+vv8/f7/') eq(msg.get_payload(decode=True), bytes) # Test the basic MIMEText class class TestMIMEText(unittest.TestCase): def setUp(self): self._msg = MIMEText('hello there') def test_types(self): eq = self.assertEqual unless = self.failUnless eq(self._msg.get_content_type(), 'text/plain') eq(self._msg.get_param('charset'), 'us-ascii') missing = [] unless(self._msg.get_param('foobar', missing) is missing) unless(self._msg.get_param('charset', missing, header='foobar') is missing) def test_payload(self): self.assertEqual(self._msg.get_payload(), 'hello there') self.failUnless(not self._msg.is_multipart()) def test_charset(self): eq = self.assertEqual msg = MIMEText('hello there', _charset='us-ascii') eq(msg.get_charset().input_charset, 'us-ascii') eq(msg['content-type'], 'text/plain; charset="us-ascii"') # Test complicated multipart/* messages class TestMultipart(TestEmailBase): def setUp(self): fp = openfile('PyBanner048.gif') try: data = fp.read() finally: fp.close() container = MIMEBase('multipart', 'mixed', boundary='BOUNDARY') image = MIMEImage(data, name='dingusfish.gif') image.add_header('content-disposition', 'attachment', filename='dingusfish.gif') intro = MIMEText('''\ Hi there, This is the dingus fish. ''') container.attach(intro) container.attach(image) container['From'] = 'Barry <barry@digicool.com>' container['To'] = 'Dingus Lovers <cravindogs@cravindogs.com>' container['Subject'] = 'Here is your dingus fish' now = 987809702.54848599 timetuple = time.localtime(now) if timetuple[-1] == 0: tzsecs = time.timezone else: tzsecs = time.altzone if tzsecs > 0: sign = '-' else: sign = '+' tzoffset = ' %s%04d' % (sign, tzsecs / 36) container['Date'] = time.strftime( '%a, %d %b %Y %H:%M:%S', time.localtime(now)) + tzoffset self._msg = container self._im = image self._txt = intro def test_hierarchy(self): # convenience eq = self.assertEqual unless = self.failUnless raises = self.assertRaises # tests m = self._msg unless(m.is_multipart()) eq(m.get_content_type(), 'multipart/mixed') eq(len(m.get_payload()), 2) raises(IndexError, m.get_payload, 2) m0 = m.get_payload(0) m1 = m.get_payload(1) unless(m0 is self._txt) unless(m1 is self._im) eq(m.get_payload(), [m0, m1]) unless(not m0.is_multipart()) unless(not m1.is_multipart()) def test_empty_multipart_idempotent(self): text = """\ Content-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY --BOUNDARY-- """ msg = Parser().parsestr(text) self.ndiffAssertEqual(text, msg.as_string()) def test_no_parts_in_a_multipart_with_none_epilogue(self): outer = MIMEBase('multipart', 'mixed') outer['Subject'] = 'A subject' outer['To'] = 'aperson@dom.ain' outer['From'] = 'bperson@dom.ain' outer.set_boundary('BOUNDARY') self.ndiffAssertEqual(outer.as_string(), '''\ Content-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY --BOUNDARY--''') def test_no_parts_in_a_multipart_with_empty_epilogue(self): outer = MIMEBase('multipart', 'mixed') outer['Subject'] = 'A subject' outer['To'] = 'aperson@dom.ain' outer['From'] = 'bperson@dom.ain' outer.preamble = '' outer.epilogue = '' outer.set_boundary('BOUNDARY') self.ndiffAssertEqual(outer.as_string(), '''\ Content-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY --BOUNDARY-- ''') def test_one_part_in_a_multipart(self): eq = self.ndiffAssertEqual outer = MIMEBase('multipart', 'mixed') outer['Subject'] = 'A subject' outer['To'] = 'aperson@dom.ain' outer['From'] = 'bperson@dom.ain' outer.set_boundary('BOUNDARY') msg = MIMEText('hello world') outer.attach(msg) eq(outer.as_string(), '''\ Content-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit hello world --BOUNDARY--''') def test_seq_parts_in_a_multipart_with_empty_preamble(self): eq = self.ndiffAssertEqual outer = MIMEBase('multipart', 'mixed') outer['Subject'] = 'A subject' outer['To'] = 'aperson@dom.ain' outer['From'] = 'bperson@dom.ain' outer.preamble = '' msg = MIMEText('hello world') outer.attach(msg) outer.set_boundary('BOUNDARY') eq(outer.as_string(), '''\ Content-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit hello world --BOUNDARY--''') def test_seq_parts_in_a_multipart_with_none_preamble(self): eq = self.ndiffAssertEqual outer = MIMEBase('multipart', 'mixed') outer['Subject'] = 'A subject' outer['To'] = 'aperson@dom.ain' outer['From'] = 'bperson@dom.ain' outer.preamble = None msg = MIMEText('hello world') outer.attach(msg) outer.set_boundary('BOUNDARY') eq(outer.as_string(), '''\ Content-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit hello world --BOUNDARY--''') def test_seq_parts_in_a_multipart_with_none_epilogue(self): eq = self.ndiffAssertEqual outer = MIMEBase('multipart', 'mixed') outer['Subject'] = 'A subject' outer['To'] = 'aperson@dom.ain' outer['From'] = 'bperson@dom.ain' outer.epilogue = None msg = MIMEText('hello world') outer.attach(msg) outer.set_boundary('BOUNDARY') eq(outer.as_string(), '''\ Content-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit hello world --BOUNDARY--''') def test_seq_parts_in_a_multipart_with_empty_epilogue(self): eq = self.ndiffAssertEqual outer = MIMEBase('multipart', 'mixed') outer['Subject'] = 'A subject' outer['To'] = 'aperson@dom.ain' outer['From'] = 'bperson@dom.ain' outer.epilogue = '' msg = MIMEText('hello world') outer.attach(msg) outer.set_boundary('BOUNDARY') eq(outer.as_string(), '''\ Content-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit hello world --BOUNDARY-- ''') def test_seq_parts_in_a_multipart_with_nl_epilogue(self): eq = self.ndiffAssertEqual outer = MIMEBase('multipart', 'mixed') outer['Subject'] = 'A subject' outer['To'] = 'aperson@dom.ain' outer['From'] = 'bperson@dom.ain' outer.epilogue = '\n' msg = MIMEText('hello world') outer.attach(msg) outer.set_boundary('BOUNDARY') eq(outer.as_string(), '''\ Content-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit hello world --BOUNDARY-- ''') def test_message_external_body(self): eq = self.assertEqual msg = self._msgobj('msg_36.txt') eq(len(msg.get_payload()), 2) msg1 = msg.get_payload(1) eq(msg1.get_content_type(), 'multipart/alternative') eq(len(msg1.get_payload()), 2) for subpart in msg1.get_payload(): eq(subpart.get_content_type(), 'message/external-body') eq(len(subpart.get_payload()), 1) subsubpart = subpart.get_payload(0) eq(subsubpart.get_content_type(), 'text/plain') def test_double_boundary(self): # msg_37.txt is a multipart that contains two dash-boundary's in a # row. Our interpretation of RFC 2046 calls for ignoring the second # and subsequent boundaries. msg = self._msgobj('msg_37.txt') self.assertEqual(len(msg.get_payload()), 3) def test_nested_inner_contains_outer_boundary(self): eq = self.ndiffAssertEqual # msg_38.txt has an inner part that contains outer boundaries. My # interpretation of RFC 2046 (based on sections 5.1 and 5.1.2) say # these are illegal and should be interpreted as unterminated inner # parts. msg = self._msgobj('msg_38.txt') sfp = StringIO() iterators._structure(msg, sfp) eq(sfp.getvalue(), """\ multipart/mixed multipart/mixed multipart/alternative text/plain text/plain text/plain text/plain """) def test_nested_with_same_boundary(self): eq = self.ndiffAssertEqual # msg 39.txt is similarly evil in that it's got inner parts that use # the same boundary as outer parts. Again, I believe the way this is # parsed is closest to the spirit of RFC 2046 msg = self._msgobj('msg_39.txt') sfp = StringIO() iterators._structure(msg, sfp) eq(sfp.getvalue(), """\ multipart/mixed multipart/mixed multipart/alternative application/octet-stream application/octet-stream text/plain """) def test_boundary_in_non_multipart(self): msg = self._msgobj('msg_40.txt') self.assertEqual(msg.as_string(), '''\ MIME-Version: 1.0 Content-Type: text/html; boundary="--961284236552522269" ----961284236552522269 Content-Type: text/html; Content-Transfer-Encoding: 7Bit <html></html> ----961284236552522269-- ''') def test_boundary_with_leading_space(self): eq = self.assertEqual msg = email.message_from_string('''\ MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=" XXXX" -- XXXX Content-Type: text/plain -- XXXX Content-Type: text/plain -- XXXX-- ''') self.failUnless(msg.is_multipart()) eq(msg.get_boundary(), ' XXXX') eq(len(msg.get_payload()), 2) def test_boundary_without_trailing_newline(self): m = Parser().parsestr("""\ Content-Type: multipart/mixed; boundary="===============0012394164==" MIME-Version: 1.0 --===============0012394164== Content-Type: image/file1.jpg MIME-Version: 1.0 Content-Transfer-Encoding: base64 YXNkZg== --===============0012394164==--""") self.assertEquals(m.get_payload(0).get_payload(), 'YXNkZg==') # Test some badly formatted messages class TestNonConformant(TestEmailBase): def test_parse_missing_minor_type(self): eq = self.assertEqual msg = self._msgobj('msg_14.txt') eq(msg.get_content_type(), 'text/plain') eq(msg.get_content_maintype(), 'text') eq(msg.get_content_subtype(), 'plain') def test_same_boundary_inner_outer(self): unless = self.failUnless msg = self._msgobj('msg_15.txt') # XXX We can probably eventually do better inner = msg.get_payload(0) unless(hasattr(inner, 'defects')) self.assertEqual(len(inner.defects), 1) unless(isinstance(inner.defects[0], errors.StartBoundaryNotFoundDefect)) def test_multipart_no_boundary(self): unless = self.failUnless msg = self._msgobj('msg_25.txt') unless(isinstance(msg.get_payload(), str)) self.assertEqual(len(msg.defects), 2) unless(isinstance(msg.defects[0], errors.NoBoundaryInMultipartDefect)) unless(isinstance(msg.defects[1], errors.MultipartInvariantViolationDefect)) def test_invalid_content_type(self): eq = self.assertEqual neq = self.ndiffAssertEqual msg = Message() # RFC 2045, $5.2 says invalid yields text/plain msg['Content-Type'] = 'text' eq(msg.get_content_maintype(), 'text') eq(msg.get_content_subtype(), 'plain') eq(msg.get_content_type(), 'text/plain') # Clear the old value and try something /really/ invalid del msg['content-type'] msg['Content-Type'] = 'foo' eq(msg.get_content_maintype(), 'text') eq(msg.get_content_subtype(), 'plain') eq(msg.get_content_type(), 'text/plain') # Still, make sure that the message is idempotently generated s = StringIO() g = Generator(s) g.flatten(msg) neq(s.getvalue(), 'Content-Type: foo\n\n') def test_no_start_boundary(self): eq = self.ndiffAssertEqual msg = self._msgobj('msg_31.txt') eq(msg.get_payload(), """\ --BOUNDARY Content-Type: text/plain message 1 --BOUNDARY Content-Type: text/plain message 2 --BOUNDARY-- """) def test_no_separating_blank_line(self): eq = self.ndiffAssertEqual msg = self._msgobj('msg_35.txt') eq(msg.as_string(), """\ From: aperson@dom.ain To: bperson@dom.ain Subject: here's something interesting counter to RFC 2822, there's no separating newline here """) def test_lying_multipart(self): unless = self.failUnless msg = self._msgobj('msg_41.txt') unless(hasattr(msg, 'defects')) self.assertEqual(len(msg.defects), 2) unless(isinstance(msg.defects[0], errors.NoBoundaryInMultipartDefect)) unless(isinstance(msg.defects[1], errors.MultipartInvariantViolationDefect)) def test_missing_start_boundary(self): outer = self._msgobj('msg_42.txt') # The message structure is: # # multipart/mixed # text/plain # message/rfc822 # multipart/mixed [*] # # [*] This message is missing its start boundary bad = outer.get_payload(1).get_payload(0) self.assertEqual(len(bad.defects), 1) self.failUnless(isinstance(bad.defects[0], errors.StartBoundaryNotFoundDefect)) def test_first_line_is_continuation_header(self): eq = self.assertEqual m = ' Line 1\nLine 2\nLine 3' msg = email.message_from_string(m) eq(msg.keys(), []) eq(msg.get_payload(), 'Line 2\nLine 3') eq(len(msg.defects), 1) self.failUnless(isinstance(msg.defects[0], errors.FirstHeaderLineIsContinuationDefect)) eq(msg.defects[0].line, ' Line 1\n') # Test RFC 2047 header encoding and decoding class TestRFC2047(unittest.TestCase): def test_rfc2047_multiline(self): eq = self.assertEqual s = """Re: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar =?mac-iceland?q?r=8Aksm=9Arg=8Cs?=""" dh = decode_header(s) eq(dh, [ ('Re:', None), ('r\x8aksm\x9arg\x8cs', 'mac-iceland'), ('baz foo bar', None), ('r\x8aksm\x9arg\x8cs', 'mac-iceland')]) eq(str(make_header(dh)), """Re: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar =?mac-iceland?q?r=8Aksm=9Arg=8Cs?=""") def test_whitespace_eater_unicode(self): eq = self.assertEqual s = '=?ISO-8859-1?Q?Andr=E9?= Pirard <pirard@dom.ain>' dh = decode_header(s) eq(dh, [('Andr\xe9', 'iso-8859-1'), ('Pirard <pirard@dom.ain>', None)]) hu = unicode(make_header(dh)).encode('latin-1') eq(hu, 'Andr\xe9 Pirard <pirard@dom.ain>') def test_whitespace_eater_unicode_2(self): eq = self.assertEqual s = 'The =?iso-8859-1?b?cXVpY2sgYnJvd24gZm94?= jumped over the =?iso-8859-1?b?bGF6eSBkb2c=?=' dh = decode_header(s) eq(dh, [('The', None), ('quick brown fox', 'iso-8859-1'), ('jumped over the', None), ('lazy dog', 'iso-8859-1')]) hu = make_header(dh).__unicode__() eq(hu, u'The quick brown fox jumped over the lazy dog') def test_rfc2047_missing_whitespace(self): s = 'Sm=?ISO-8859-1?B?9g==?=rg=?ISO-8859-1?B?5Q==?=sbord' dh = decode_header(s) self.assertEqual(dh, [(s, None)]) def test_rfc2047_with_whitespace(self): s = 'Sm =?ISO-8859-1?B?9g==?= rg =?ISO-8859-1?B?5Q==?= sbord' dh = decode_header(s) self.assertEqual(dh, [('Sm', None), ('\xf6', 'iso-8859-1'), ('rg', None), ('\xe5', 'iso-8859-1'), ('sbord', None)]) # Test the MIMEMessage class class TestMIMEMessage(TestEmailBase): def setUp(self): fp = openfile('msg_11.txt') try: self._text = fp.read() finally: fp.close() def test_type_error(self): self.assertRaises(TypeError, MIMEMessage, 'a plain string') def test_valid_argument(self): eq = self.assertEqual unless = self.failUnless subject = 'A sub-message' m = Message() m['Subject'] = subject r = MIMEMessage(m) eq(r.get_content_type(), 'message/rfc822') payload = r.get_payload() unless(isinstance(payload, list)) eq(len(payload), 1) subpart = payload[0] unless(subpart is m) eq(subpart['subject'], subject) def test_bad_multipart(self): eq = self.assertEqual msg1 = Message() msg1['Subject'] = 'subpart 1' msg2 = Message() msg2['Subject'] = 'subpart 2' r = MIMEMessage(msg1) self.assertRaises(errors.MultipartConversionError, r.attach, msg2) def test_generate(self): # First craft the message to be encapsulated m = Message() m['Subject'] = 'An enclosed message' m.set_payload('Here is the body of the message.\n') r = MIMEMessage(m) r['Subject'] = 'The enclosing message' s = StringIO() g = Generator(s) g.flatten(r) self.assertEqual(s.getvalue(), """\ Content-Type: message/rfc822 MIME-Version: 1.0 Subject: The enclosing message Subject: An enclosed message Here is the body of the message. """) def test_parse_message_rfc822(self): eq = self.assertEqual unless = self.failUnless msg = self._msgobj('msg_11.txt') eq(msg.get_content_type(), 'message/rfc822') payload = msg.get_payload() unless(isinstance(payload, list)) eq(len(payload), 1) submsg = payload[0] self.failUnless(isinstance(submsg, Message)) eq(submsg['subject'], 'An enclosed message') eq(submsg.get_payload(), 'Here is the body of the message.\n') def test_dsn(self): eq = self.assertEqual unless = self.failUnless # msg 16 is a Delivery Status Notification, see RFC 1894 msg = self._msgobj('msg_16.txt') eq(msg.get_content_type(), 'multipart/report') unless(msg.is_multipart()) eq(len(msg.get_payload()), 3) # Subpart 1 is a text/plain, human readable section subpart = msg.get_payload(0) eq(subpart.get_content_type(), 'text/plain') eq(subpart.get_payload(), """\ This report relates to a message you sent with the following header fields: Message-id: <002001c144a6$8752e060$56104586@oxy.edu> Date: Sun, 23 Sep 2001 20:10:55 -0700 From: "Ian T. Henry" <henryi@oxy.edu> To: SoCal Raves <scr@socal-raves.org> Subject: [scr] yeah for Ians!! Your message cannot be delivered to the following recipients: Recipient address: jangel1@cougar.noc.ucla.edu Reason: recipient reached disk quota """) # Subpart 2 contains the machine parsable DSN information. It # consists of two blocks of headers, represented by two nested Message # objects. subpart = msg.get_payload(1) eq(subpart.get_content_type(), 'message/delivery-status') eq(len(subpart.get_payload()), 2) # message/delivery-status should treat each block as a bunch of # headers, i.e. a bunch of Message objects. dsn1 = subpart.get_payload(0) unless(isinstance(dsn1, Message)) eq(dsn1['original-envelope-id'], '0GK500B4HD0888@cougar.noc.ucla.edu') eq(dsn1.get_param('dns', header='reporting-mta'), '') # Try a missing one <wink> eq(dsn1.get_param('nsd', header='reporting-mta'), None) dsn2 = subpart.get_payload(1) unless(isinstance(dsn2, Message)) eq(dsn2['action'], 'failed') eq(dsn2.get_params(header='original-recipient'), [('rfc822', ''), ('jangel1@cougar.noc.ucla.edu', '')]) eq(dsn2.get_param('rfc822', header='final-recipient'), '') # Subpart 3 is the original message subpart = msg.get_payload(2) eq(subpart.get_content_type(), 'message/rfc822') payload = subpart.get_payload() unless(isinstance(payload, list)) eq(len(payload), 1) subsubpart = payload[0] unless(isinstance(subsubpart, Message)) eq(subsubpart.get_content_type(), 'text/plain') eq(subsubpart['message-id'], '<002001c144a6$8752e060$56104586@oxy.edu>') def test_epilogue(self): eq = self.ndiffAssertEqual fp = openfile('msg_21.txt') try: text = fp.read() finally: fp.close() msg = Message() msg['From'] = 'aperson@dom.ain' msg['To'] = 'bperson@dom.ain' msg['Subject'] = 'Test' msg.preamble = 'MIME message' msg.epilogue = 'End of MIME message\n' msg1 = MIMEText('One') msg2 = MIMEText('Two') msg.add_header('Content-Type', 'multipart/mixed', boundary='BOUNDARY') msg.attach(msg1) msg.attach(msg2) sfp = StringIO() g = Generator(sfp) g.flatten(msg) eq(sfp.getvalue(), text) def test_no_nl_preamble(self): eq = self.ndiffAssertEqual msg = Message() msg['From'] = 'aperson@dom.ain' msg['To'] = 'bperson@dom.ain' msg['Subject'] = 'Test' msg.preamble = 'MIME message' msg.epilogue = '' msg1 = MIMEText('One') msg2 = MIMEText('Two') msg.add_header('Content-Type', 'multipart/mixed', boundary='BOUNDARY') msg.attach(msg1) msg.attach(msg2) eq(msg.as_string(), """\ From: aperson@dom.ain To: bperson@dom.ain Subject: Test Content-Type: multipart/mixed; boundary="BOUNDARY" MIME message --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit One --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Two --BOUNDARY-- """) def test_default_type(self): eq = self.assertEqual fp = openfile('msg_30.txt') try: msg = email.message_from_file(fp) finally: fp.close() container1 = msg.get_payload(0) eq(container1.get_default_type(), 'message/rfc822') eq(container1.get_content_type(), 'message/rfc822') container2 = msg.get_payload(1) eq(container2.get_default_type(), 'message/rfc822') eq(container2.get_content_type(), 'message/rfc822') container1a = container1.get_payload(0) eq(container1a.get_default_type(), 'text/plain') eq(container1a.get_content_type(), 'text/plain') container2a = container2.get_payload(0) eq(container2a.get_default_type(), 'text/plain') eq(container2a.get_content_type(), 'text/plain') def test_default_type_with_explicit_container_type(self): eq = self.assertEqual fp = openfile('msg_28.txt') try: msg = email.message_from_file(fp) finally: fp.close() container1 = msg.get_payload(0) eq(container1.get_default_type(), 'message/rfc822') eq(container1.get_content_type(), 'message/rfc822') container2 = msg.get_payload(1) eq(container2.get_default_type(), 'message/rfc822') eq(container2.get_content_type(), 'message/rfc822') container1a = container1.get_payload(0) eq(container1a.get_default_type(), 'text/plain') eq(container1a.get_content_type(), 'text/plain') container2a = container2.get_payload(0) eq(container2a.get_default_type(), 'text/plain') eq(container2a.get_content_type(), 'text/plain') def test_default_type_non_parsed(self): eq = self.assertEqual neq = self.ndiffAssertEqual # Set up container container = MIMEMultipart('digest', 'BOUNDARY') container.epilogue = '' # Set up subparts subpart1a = MIMEText('message 1\n') subpart2a = MIMEText('message 2\n') subpart1 = MIMEMessage(subpart1a) subpart2 = MIMEMessage(subpart2a) container.attach(subpart1) container.attach(subpart2) eq(subpart1.get_content_type(), 'message/rfc822') eq(subpart1.get_default_type(), 'message/rfc822') eq(subpart2.get_content_type(), 'message/rfc822') eq(subpart2.get_default_type(), 'message/rfc822') neq(container.as_string(0), '''\ Content-Type: multipart/digest; boundary="BOUNDARY" MIME-Version: 1.0 --BOUNDARY Content-Type: message/rfc822 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit message 1 --BOUNDARY Content-Type: message/rfc822 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit message 2 --BOUNDARY-- ''') del subpart1['content-type'] del subpart1['mime-version'] del subpart2['content-type'] del subpart2['mime-version'] eq(subpart1.get_content_type(), 'message/rfc822') eq(subpart1.get_default_type(), 'message/rfc822') eq(subpart2.get_content_type(), 'message/rfc822') eq(subpart2.get_default_type(), 'message/rfc822') neq(container.as_string(0), '''\ Content-Type: multipart/digest; boundary="BOUNDARY" MIME-Version: 1.0 --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit message 1 --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit message 2 --BOUNDARY-- ''') def test_mime_attachments_in_constructor(self): eq = self.assertEqual text1 = MIMEText('') text2 = MIMEText('') msg = MIMEMultipart(_subparts=(text1, text2)) eq(len(msg.get_payload()), 2) eq(msg.get_payload(0), text1) eq(msg.get_payload(1), text2) # A general test of parser->model->generator idempotency. IOW, read a message # in, parse it into a message object tree, then without touching the tree, # regenerate the plain text. The original text and the transformed text # should be identical. Note: that we ignore the Unix-From since that may # contain a changed date. class TestIdempotent(TestEmailBase): def _msgobj(self, filename): fp = openfile(filename) try: data = fp.read() finally: fp.close() msg = email.message_from_string(data) return msg, data def _idempotent(self, msg, text): eq = self.ndiffAssertEqual s = StringIO() g = Generator(s, maxheaderlen=0) g.flatten(msg) eq(text, s.getvalue()) def test_parse_text_message(self): eq = self.assertEquals msg, text = self._msgobj('msg_01.txt') eq(msg.get_content_type(), 'text/plain') eq(msg.get_content_maintype(), 'text') eq(msg.get_content_subtype(), 'plain') eq(msg.get_params()[1], ('charset', 'us-ascii')) eq(msg.get_param('charset'), 'us-ascii') eq(msg.preamble, None) eq(msg.epilogue, None) self._idempotent(msg, text) def test_parse_untyped_message(self): eq = self.assertEquals msg, text = self._msgobj('msg_03.txt') eq(msg.get_content_type(), 'text/plain') eq(msg.get_params(), None) eq(msg.get_param('charset'), None) self._idempotent(msg, text) def test_simple_multipart(self): msg, text = self._msgobj('msg_04.txt') self._idempotent(msg, text) def test_MIME_digest(self): msg, text = self._msgobj('msg_02.txt') self._idempotent(msg, text) def test_long_header(self): msg, text = self._msgobj('msg_27.txt') self._idempotent(msg, text) def test_MIME_digest_with_part_headers(self): msg, text = self._msgobj('msg_28.txt') self._idempotent(msg, text) def test_mixed_with_image(self): msg, text = self._msgobj('msg_06.txt') self._idempotent(msg, text) def test_multipart_report(self): msg, text = self._msgobj('msg_05.txt') self._idempotent(msg, text) def test_dsn(self): msg, text = self._msgobj('msg_16.txt') self._idempotent(msg, text) def test_preamble_epilogue(self): msg, text = self._msgobj('msg_21.txt') self._idempotent(msg, text) def test_multipart_one_part(self): msg, text = self._msgobj('msg_23.txt') self._idempotent(msg, text) def test_multipart_no_parts(self): msg, text = self._msgobj('msg_24.txt') self._idempotent(msg, text) def test_no_start_boundary(self): msg, text = self._msgobj('msg_31.txt') self._idempotent(msg, text) def test_rfc2231_charset(self): msg, text = self._msgobj('msg_32.txt') self._idempotent(msg, text) def test_more_rfc2231_parameters(self): msg, text = self._msgobj('msg_33.txt') self._idempotent(msg, text) def test_text_plain_in_a_multipart_digest(self): msg, text = self._msgobj('msg_34.txt') self._idempotent(msg, text) def test_nested_multipart_mixeds(self): msg, text = self._msgobj('msg_12a.txt') self._idempotent(msg, text) def test_message_external_body_idempotent(self): msg, text = self._msgobj('msg_36.txt') self._idempotent(msg, text) def test_content_type(self): eq = self.assertEquals unless = self.failUnless # Get a message object and reset the seek pointer for other tests msg, text = self._msgobj('msg_05.txt') eq(msg.get_content_type(), 'multipart/report') # Test the Content-Type: parameters params = {} for pk, pv in msg.get_params(): params[pk] = pv eq(params['report-type'], 'delivery-status') eq(params['boundary'], 'D1690A7AC1.996856090/mail.example.com') eq(msg.preamble, 'This is a MIME-encapsulated message.\n') eq(msg.epilogue, '\n') eq(len(msg.get_payload()), 3) # Make sure the subparts are what we expect msg1 = msg.get_payload(0) eq(msg1.get_content_type(), 'text/plain') eq(msg1.get_payload(), 'Yadda yadda yadda\n') msg2 = msg.get_payload(1) eq(msg2.get_content_type(), 'text/plain') eq(msg2.get_payload(), 'Yadda yadda yadda\n') msg3 = msg.get_payload(2) eq(msg3.get_content_type(), 'message/rfc822') self.failUnless(isinstance(msg3, Message)) payload = msg3.get_payload() unless(isinstance(payload, list)) eq(len(payload), 1) msg4 = payload[0] unless(isinstance(msg4, Message)) eq(msg4.get_payload(), 'Yadda yadda yadda\n') def test_parser(self): eq = self.assertEquals unless = self.failUnless msg, text = self._msgobj('msg_06.txt') # Check some of the outer headers eq(msg.get_content_type(), 'message/rfc822') # Make sure the payload is a list of exactly one sub-Message, and that # that submessage has a type of text/plain payload = msg.get_payload() unless(isinstance(payload, list)) eq(len(payload), 1) msg1 = payload[0] self.failUnless(isinstance(msg1, Message)) eq(msg1.get_content_type(), 'text/plain') self.failUnless(isinstance(msg1.get_payload(), str)) eq(msg1.get_payload(), '\n') # Test various other bits of the package's functionality class TestMiscellaneous(TestEmailBase): def test_message_from_string(self): fp = openfile('msg_01.txt') try: text = fp.read() finally: fp.close() msg = email.message_from_string(text) s = StringIO() # Don't wrap/continue long headers since we're trying to test # idempotency. g = Generator(s, maxheaderlen=0) g.flatten(msg) self.assertEqual(text, s.getvalue()) def test_message_from_file(self): fp = openfile('msg_01.txt') try: text = fp.read() fp.seek(0) msg = email.message_from_file(fp) s = StringIO() # Don't wrap/continue long headers since we're trying to test # idempotency. g = Generator(s, maxheaderlen=0) g.flatten(msg) self.assertEqual(text, s.getvalue()) finally: fp.close() def test_message_from_string_with_class(self): unless = self.failUnless fp = openfile('msg_01.txt') try: text = fp.read() finally: fp.close() # Create a subclass class MyMessage(Message): pass msg = email.message_from_string(text, MyMessage) unless(isinstance(msg, MyMessage)) # Try something more complicated fp = openfile('msg_02.txt') try: text = fp.read() finally: fp.close() msg = email.message_from_string(text, MyMessage) for subpart in msg.walk(): unless(isinstance(subpart, MyMessage)) def test_message_from_file_with_class(self): unless = self.failUnless # Create a subclass class MyMessage(Message): pass fp = openfile('msg_01.txt') try: msg = email.message_from_file(fp, MyMessage) finally: fp.close() unless(isinstance(msg, MyMessage)) # Try something more complicated fp = openfile('msg_02.txt') try: msg = email.message_from_file(fp, MyMessage) finally: fp.close() for subpart in msg.walk(): unless(isinstance(subpart, MyMessage)) def test__all__(self): module = __import__('email') # Can't use sorted() here due to Python 2.3 compatibility all = module.__all__[:] all.sort() self.assertEqual(all, [ # Old names 'Charset', 'Encoders', 'Errors', 'Generator', 'Header', 'Iterators', 'MIMEAudio', 'MIMEBase', 'MIMEImage', 'MIMEMessage', 'MIMEMultipart', 'MIMENonMultipart', 'MIMEText', 'Message', 'Parser', 'Utils', 'base64MIME', # new names 'base64mime', 'charset', 'encoders', 'errors', 'generator', 'header', 'iterators', 'message', 'message_from_file', 'message_from_string', 'mime', 'parser', 'quopriMIME', 'quoprimime', 'utils', ]) def test_formatdate(self): now = time.time() self.assertEqual(utils.parsedate(utils.formatdate(now))[:6], time.gmtime(now)[:6]) def test_formatdate_localtime(self): now = time.time() self.assertEqual( utils.parsedate(utils.formatdate(now, localtime=True))[:6], time.localtime(now)[:6]) def test_formatdate_usegmt(self): now = time.time() self.assertEqual( utils.formatdate(now, localtime=False), time.strftime('%a, %d %b %Y %H:%M:%S -0000', time.gmtime(now))) self.assertEqual( utils.formatdate(now, localtime=False, usegmt=True), time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime(now))) def test_parsedate_none(self): self.assertEqual(utils.parsedate(''), None) def test_parsedate_compact(self): # The FWS after the comma is optional self.assertEqual(utils.parsedate('Wed,3 Apr 2002 14:58:26 +0800'), utils.parsedate('Wed, 3 Apr 2002 14:58:26 +0800')) def test_parsedate_no_dayofweek(self): eq = self.assertEqual eq(utils.parsedate_tz('25 Feb 2003 13:47:26 -0800'), (2003, 2, 25, 13, 47, 26, 0, 1, -1, -28800)) def test_parsedate_compact_no_dayofweek(self): eq = self.assertEqual eq(utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'), (2003, 2, 5, 13, 47, 26, 0, 1, -1, -28800)) def test_parsedate_acceptable_to_time_functions(self): eq = self.assertEqual timetup = utils.parsedate('5 Feb 2003 13:47:26 -0800') t = int(time.mktime(timetup)) eq(time.localtime(t)[:6], timetup[:6]) eq(int(time.strftime('%Y', timetup)), 2003) timetup = utils.parsedate_tz('5 Feb 2003 13:47:26 -0800') t = int(time.mktime(timetup[:9])) eq(time.localtime(t)[:6], timetup[:6]) eq(int(time.strftime('%Y', timetup[:9])), 2003) def test_parseaddr_empty(self): self.assertEqual(utils.parseaddr('<>'), ('', '')) self.assertEqual(utils.formataddr(utils.parseaddr('<>')), '') def test_noquote_dump(self): self.assertEqual( utils.formataddr(('A Silly Person', 'person@dom.ain')), 'A Silly Person <person@dom.ain>') def test_escape_dump(self): self.assertEqual( utils.formataddr(('A (Very) Silly Person', 'person@dom.ain')), r'"A \(Very\) Silly Person" <person@dom.ain>') a = r'A \(Special\) Person' b = 'person@dom.ain' self.assertEqual(utils.parseaddr(utils.formataddr((a, b))), (a, b)) def test_escape_backslashes(self): self.assertEqual( utils.formataddr(('Arthur \Backslash\ Foobar', 'person@dom.ain')), r'"Arthur \\Backslash\\ Foobar" <person@dom.ain>') a = r'Arthur \Backslash\ Foobar' b = 'person@dom.ain' self.assertEqual(utils.parseaddr(utils.formataddr((a, b))), (a, b)) def test_name_with_dot(self): x = 'John X. Doe <jxd@example.com>' y = '"John X. Doe" <jxd@example.com>' a, b = ('John X. Doe', 'jxd@example.com') self.assertEqual(utils.parseaddr(x), (a, b)) self.assertEqual(utils.parseaddr(y), (a, b)) # formataddr() quotes the name if there's a dot in it self.assertEqual(utils.formataddr((a, b)), y) def test_multiline_from_comment(self): x = """\ Foo \tBar <foo@example.com>""" self.assertEqual(utils.parseaddr(x), ('Foo Bar', 'foo@example.com')) def test_quote_dump(self): self.assertEqual( utils.formataddr(('A Silly; Person', 'person@dom.ain')), r'"A Silly; Person" <person@dom.ain>') def test_fix_eols(self): eq = self.assertEqual eq(utils.fix_eols('hello'), 'hello') eq(utils.fix_eols('hello\n'), 'hello\r\n') eq(utils.fix_eols('hello\r'), 'hello\r\n') eq(utils.fix_eols('hello\r\n'), 'hello\r\n') eq(utils.fix_eols('hello\n\r'), 'hello\r\n\r\n') def test_charset_richcomparisons(self): eq = self.assertEqual ne = self.failIfEqual cset1 = Charset() cset2 = Charset() eq(cset1, 'us-ascii') eq(cset1, 'US-ASCII') eq(cset1, 'Us-AsCiI') eq('us-ascii', cset1) eq('US-ASCII', cset1) eq('Us-AsCiI', cset1) ne(cset1, 'usascii') ne(cset1, 'USASCII') ne(cset1, 'UsAsCiI') ne('usascii', cset1) ne('USASCII', cset1) ne('UsAsCiI', cset1) eq(cset1, cset2) eq(cset2, cset1) def test_getaddresses(self): eq = self.assertEqual eq(utils.getaddresses(['aperson@dom.ain (Al Person)', 'Bud Person <bperson@dom.ain>']), [('Al Person', 'aperson@dom.ain'), ('Bud Person', 'bperson@dom.ain')]) def test_getaddresses_nasty(self): eq = self.assertEqual eq(utils.getaddresses(['foo: ;']), [('', '')]) eq(utils.getaddresses( ['[]*-- =~$']), [('', ''), ('', ''), ('', '*--')]) eq(utils.getaddresses( ['foo: ;', '"Jason R. Mastaler" <jason@dom.ain>']), [('', ''), ('Jason R. Mastaler', 'jason@dom.ain')]) def test_getaddresses_embedded_comment(self): """Test proper handling of a nested comment""" eq = self.assertEqual addrs = utils.getaddresses(['User ((nested comment)) <foo@bar.com>']) eq(addrs[0][1], 'foo@bar.com') def test_utils_quote_unquote(self): eq = self.assertEqual msg = Message() msg.add_header('content-disposition', 'attachment', filename='foo\\wacky"name') eq(msg.get_filename(), 'foo\\wacky"name') def test_get_body_encoding_with_bogus_charset(self): charset = Charset('not a charset') self.assertEqual(charset.get_body_encoding(), 'base64') def test_get_body_encoding_with_uppercase_charset(self): eq = self.assertEqual msg = Message() msg['Content-Type'] = 'text/plain; charset=UTF-8' eq(msg['content-type'], 'text/plain; charset=UTF-8') charsets = msg.get_charsets() eq(len(charsets), 1) eq(charsets[0], 'utf-8') charset = Charset(charsets[0]) eq(charset.get_body_encoding(), 'base64') msg.set_payload('hello world', charset=charset) eq(msg.get_payload(), 'aGVsbG8gd29ybGQ=\n') eq(msg.get_payload(decode=True), 'hello world') eq(msg['content-transfer-encoding'], 'base64') # Try another one msg = Message() msg['Content-Type'] = 'text/plain; charset="US-ASCII"' charsets = msg.get_charsets() eq(len(charsets), 1) eq(charsets[0], 'us-ascii') charset = Charset(charsets[0]) eq(charset.get_body_encoding(), encoders.encode_7or8bit) msg.set_payload('hello world', charset=charset) eq(msg.get_payload(), 'hello world') eq(msg['content-transfer-encoding'], '7bit') def test_charsets_case_insensitive(self): lc = Charset('us-ascii') uc = Charset('US-ASCII') self.assertEqual(lc.get_body_encoding(), uc.get_body_encoding()) def test_partial_falls_inside_message_delivery_status(self): eq = self.ndiffAssertEqual # The Parser interface provides chunks of data to FeedParser in 8192 # byte gulps. SF bug #1076485 found one of those chunks inside # message/delivery-status header block, which triggered an # unreadline() of NeedMoreData. msg = self._msgobj('msg_43.txt') sfp = StringIO() iterators._structure(msg, sfp) eq(sfp.getvalue(), """\ multipart/report text/plain message/delivery-status text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/rfc822-headers """) # Test the iterator/generators class TestIterators(TestEmailBase): def test_body_line_iterator(self): eq = self.assertEqual neq = self.ndiffAssertEqual # First a simple non-multipart message msg = self._msgobj('msg_01.txt') it = iterators.body_line_iterator(msg) lines = list(it) eq(len(lines), 6) neq(EMPTYSTRING.join(lines), msg.get_payload()) # Now a more complicated multipart msg = self._msgobj('msg_02.txt') it = iterators.body_line_iterator(msg) lines = list(it) eq(len(lines), 43) fp = openfile('msg_19.txt') try: neq(EMPTYSTRING.join(lines), fp.read()) finally: fp.close() def test_typed_subpart_iterator(self): eq = self.assertEqual msg = self._msgobj('msg_04.txt') it = iterators.typed_subpart_iterator(msg, 'text') lines = [] subparts = 0 for subpart in it: subparts += 1 lines.append(subpart.get_payload()) eq(subparts, 2) eq(EMPTYSTRING.join(lines), """\ a simple kind of mirror to reflect upon our own a simple kind of mirror to reflect upon our own """) def test_typed_subpart_iterator_default_type(self): eq = self.assertEqual msg = self._msgobj('msg_03.txt') it = iterators.typed_subpart_iterator(msg, 'text', 'plain') lines = [] subparts = 0 for subpart in it: subparts += 1 lines.append(subpart.get_payload()) eq(subparts, 1) eq(EMPTYSTRING.join(lines), """\ Hi, Do you like this message? -Me """) class TestParsers(TestEmailBase): def test_header_parser(self): eq = self.assertEqual # Parse only the headers of a complex multipart MIME document fp = openfile('msg_02.txt') try: msg = HeaderParser().parse(fp) finally: fp.close() eq(msg['from'], 'ppp-request@zzz.org') eq(msg['to'], 'ppp@zzz.org') eq(msg.get_content_type(), 'multipart/mixed') self.failIf(msg.is_multipart()) self.failUnless(isinstance(msg.get_payload(), str)) def test_whitespace_continuation(self): eq = self.assertEqual # This message contains a line after the Subject: header that has only # whitespace, but it is not empty! msg = email.message_from_string("""\ From: aperson@dom.ain To: bperson@dom.ain Subject: the next line has a space on it \x20 Date: Mon, 8 Apr 2002 15:09:19 -0400 Message-ID: spam Here's the message body """) eq(msg['subject'], 'the next line has a space on it\n ') eq(msg['message-id'], 'spam') eq(msg.get_payload(), "Here's the message body\n") def test_whitespace_continuation_last_header(self): eq = self.assertEqual # Like the previous test, but the subject line is the last # header. msg = email.message_from_string("""\ From: aperson@dom.ain To: bperson@dom.ain Date: Mon, 8 Apr 2002 15:09:19 -0400 Message-ID: spam Subject: the next line has a space on it \x20 Here's the message body """) eq(msg['subject'], 'the next line has a space on it\n ') eq(msg['message-id'], 'spam') eq(msg.get_payload(), "Here's the message body\n") def test_crlf_separation(self): eq = self.assertEqual fp = openfile('msg_26.txt', mode='rb') try: msg = Parser().parse(fp) finally: fp.close() eq(len(msg.get_payload()), 2) part1 = msg.get_payload(0) eq(part1.get_content_type(), 'text/plain') eq(part1.get_payload(), 'Simple email with attachment.\r\n\r\n') part2 = msg.get_payload(1) eq(part2.get_content_type(), 'application/riscos') def test_multipart_digest_with_extra_mime_headers(self): eq = self.assertEqual neq = self.ndiffAssertEqual fp = openfile('msg_28.txt') try: msg = email.message_from_file(fp) finally: fp.close() # Structure is: # multipart/digest # message/rfc822 # text/plain # message/rfc822 # text/plain eq(msg.is_multipart(), 1) eq(len(msg.get_payload()), 2) part1 = msg.get_payload(0) eq(part1.get_content_type(), 'message/rfc822') eq(part1.is_multipart(), 1) eq(len(part1.get_payload()), 1) part1a = part1.get_payload(0) eq(part1a.is_multipart(), 0) eq(part1a.get_content_type(), 'text/plain') neq(part1a.get_payload(), 'message 1\n') # next message/rfc822 part2 = msg.get_payload(1) eq(part2.get_content_type(), 'message/rfc822') eq(part2.is_multipart(), 1) eq(len(part2.get_payload()), 1) part2a = part2.get_payload(0) eq(part2a.is_multipart(), 0) eq(part2a.get_content_type(), 'text/plain') neq(part2a.get_payload(), 'message 2\n') def test_three_lines(self): # A bug report by Andrew McNamara lines = ['From: Andrew Person <aperson@dom.ain', 'Subject: Test', 'Date: Tue, 20 Aug 2002 16:43:45 +1000'] msg = email.message_from_string(NL.join(lines)) self.assertEqual(msg['date'], 'Tue, 20 Aug 2002 16:43:45 +1000') def test_strip_line_feed_and_carriage_return_in_headers(self): eq = self.assertEqual # For [ 1002475 ] email message parser doesn't handle \r\n correctly value1 = 'text' value2 = 'more text' m = 'Header: %s\r\nNext-Header: %s\r\n\r\nBody\r\n\r\n' % ( value1, value2) msg = email.message_from_string(m) eq(msg.get('Header'), value1) eq(msg.get('Next-Header'), value2) def test_rfc2822_header_syntax(self): eq = self.assertEqual m = '>From: foo\nFrom: bar\n!"#QUX;~: zoo\n\nbody' msg = email.message_from_string(m) eq(len(msg.keys()), 3) keys = msg.keys() keys.sort() eq(keys, ['!"#QUX;~', '>From', 'From']) eq(msg.get_payload(), 'body') def test_rfc2822_space_not_allowed_in_header(self): eq = self.assertEqual m = '>From foo@example.com 11:25:53\nFrom: bar\n!"#QUX;~: zoo\n\nbody' msg = email.message_from_string(m) eq(len(msg.keys()), 0) def test_rfc2822_one_character_header(self): eq = self.assertEqual m = 'A: first header\nB: second header\nCC: third header\n\nbody' msg = email.message_from_string(m) headers = msg.keys() headers.sort() eq(headers, ['A', 'B', 'CC']) eq(msg.get_payload(), 'body') class TestBase64(unittest.TestCase): def test_len(self): eq = self.assertEqual eq(base64mime.base64_len('hello'), len(base64mime.encode('hello', eol=''))) for size in range(15): if size == 0 : bsize = 0 elif size <= 3 : bsize = 4 elif size <= 6 : bsize = 8 elif size <= 9 : bsize = 12 elif size <= 12: bsize = 16 else : bsize = 20 eq(base64mime.base64_len('x'*size), bsize) def test_decode(self): eq = self.assertEqual eq(base64mime.decode(''), '') eq(base64mime.decode('aGVsbG8='), 'hello') eq(base64mime.decode('aGVsbG8=', 'X'), 'hello') eq(base64mime.decode('aGVsbG8NCndvcmxk\n', 'X'), 'helloXworld') def test_encode(self): eq = self.assertEqual eq(base64mime.encode(''), '') eq(base64mime.encode('hello'), 'aGVsbG8=\n') # Test the binary flag eq(base64mime.encode('hello\n'), 'aGVsbG8K\n') eq(base64mime.encode('hello\n', 0), 'aGVsbG8NCg==\n') # Test the maxlinelen arg eq(base64mime.encode('xxxx ' * 20, maxlinelen=40), """\ eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg eHh4eCB4eHh4IA== """) # Test the eol argument eq(base64mime.encode('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\ eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r eHh4eCB4eHh4IA==\r """) def test_header_encode(self): eq = self.assertEqual he = base64mime.header_encode eq(he('hello'), '=?iso-8859-1?b?aGVsbG8=?=') eq(he('hello\nworld'), '=?iso-8859-1?b?aGVsbG8NCndvcmxk?=') # Test the charset option eq(he('hello', charset='iso-8859-2'), '=?iso-8859-2?b?aGVsbG8=?=') # Test the keep_eols flag eq(he('hello\nworld', keep_eols=True), '=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=') # Test the maxlinelen argument eq(he('xxxx ' * 20, maxlinelen=40), """\ =?iso-8859-1?b?eHh4eCB4eHh4IHh4eHggeHg=?= =?iso-8859-1?b?eHggeHh4eCB4eHh4IHh4eHg=?= =?iso-8859-1?b?IHh4eHggeHh4eCB4eHh4IHg=?= =?iso-8859-1?b?eHh4IHh4eHggeHh4eCB4eHg=?= =?iso-8859-1?b?eCB4eHh4IHh4eHggeHh4eCA=?= =?iso-8859-1?b?eHh4eCB4eHh4IHh4eHgg?=""") # Test the eol argument eq(he('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\ =?iso-8859-1?b?eHh4eCB4eHh4IHh4eHggeHg=?=\r =?iso-8859-1?b?eHggeHh4eCB4eHh4IHh4eHg=?=\r =?iso-8859-1?b?IHh4eHggeHh4eCB4eHh4IHg=?=\r =?iso-8859-1?b?eHh4IHh4eHggeHh4eCB4eHg=?=\r =?iso-8859-1?b?eCB4eHh4IHh4eHggeHh4eCA=?=\r =?iso-8859-1?b?eHh4eCB4eHh4IHh4eHgg?=""") class TestQuopri(unittest.TestCase): def setUp(self): self.hlit = [chr(x) for x in range(ord('a'), ord('z')+1)] + \ [chr(x) for x in range(ord('A'), ord('Z')+1)] + \ [chr(x) for x in range(ord('0'), ord('9')+1)] + \ ['!', '*', '+', '-', '/', ' '] self.hnon = [chr(x) for x in range(256) if chr(x) not in self.hlit] assert len(self.hlit) + len(self.hnon) == 256 self.blit = [chr(x) for x in range(ord(' '), ord('~')+1)] + ['\t'] self.blit.remove('=') self.bnon = [chr(x) for x in range(256) if chr(x) not in self.blit] assert len(self.blit) + len(self.bnon) == 256 def test_header_quopri_check(self): for c in self.hlit: self.failIf(quoprimime.header_quopri_check(c)) for c in self.hnon: self.failUnless(quoprimime.header_quopri_check(c)) def test_body_quopri_check(self): for c in self.blit: self.failIf(quoprimime.body_quopri_check(c)) for c in self.bnon: self.failUnless(quoprimime.body_quopri_check(c)) def test_header_quopri_len(self): eq = self.assertEqual hql = quoprimime.header_quopri_len enc = quoprimime.header_encode for s in ('hello', 'h@e@l@l@o@'): # Empty charset and no line-endings. 7 == RFC chrome eq(hql(s), len(enc(s, charset='', eol=''))-7) for c in self.hlit: eq(hql(c), 1) for c in self.hnon: eq(hql(c), 3) def test_body_quopri_len(self): eq = self.assertEqual bql = quoprimime.body_quopri_len for c in self.blit: eq(bql(c), 1) for c in self.bnon: eq(bql(c), 3) def test_quote_unquote_idempotent(self): for x in range(256): c = chr(x) self.assertEqual(quoprimime.unquote(quoprimime.quote(c)), c) def test_header_encode(self): eq = self.assertEqual he = quoprimime.header_encode eq(he('hello'), '=?iso-8859-1?q?hello?=') eq(he('hello\nworld'), '=?iso-8859-1?q?hello=0D=0Aworld?=') # Test the charset option eq(he('hello', charset='iso-8859-2'), '=?iso-8859-2?q?hello?=') # Test the keep_eols flag eq(he('hello\nworld', keep_eols=True), '=?iso-8859-1?q?hello=0Aworld?=') # Test a non-ASCII character eq(he('hello\xc7there'), '=?iso-8859-1?q?hello=C7there?=') # Test the maxlinelen argument eq(he('xxxx ' * 20, maxlinelen=40), """\ =?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xx?= =?iso-8859-1?q?xx_xxxx_xxxx_xxxx_xxxx?= =?iso-8859-1?q?_xxxx_xxxx_xxxx_xxxx_x?= =?iso-8859-1?q?xxx_xxxx_xxxx_xxxx_xxx?= =?iso-8859-1?q?x_xxxx_xxxx_?=""") # Test the eol argument eq(he('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\ =?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xx?=\r =?iso-8859-1?q?xx_xxxx_xxxx_xxxx_xxxx?=\r =?iso-8859-1?q?_xxxx_xxxx_xxxx_xxxx_x?=\r =?iso-8859-1?q?xxx_xxxx_xxxx_xxxx_xxx?=\r =?iso-8859-1?q?x_xxxx_xxxx_?=""") def test_decode(self): eq = self.assertEqual eq(quoprimime.decode(''), '') eq(quoprimime.decode('hello'), 'hello') eq(quoprimime.decode('hello', 'X'), 'hello') eq(quoprimime.decode('hello\nworld', 'X'), 'helloXworld') def test_encode(self): eq = self.assertEqual eq(quoprimime.encode(''), '') eq(quoprimime.encode('hello'), 'hello') # Test the binary flag eq(quoprimime.encode('hello\r\nworld'), 'hello\nworld') eq(quoprimime.encode('hello\r\nworld', 0), 'hello\nworld') # Test the maxlinelen arg eq(quoprimime.encode('xxxx ' * 20, maxlinelen=40), """\ xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx= xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx= x xxxx xxxx xxxx xxxx=20""") # Test the eol argument eq(quoprimime.encode('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\ xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=\r xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=\r x xxxx xxxx xxxx xxxx=20""") eq(quoprimime.encode("""\ one line two line"""), """\ one line two line""") # Test the Charset class class TestCharset(unittest.TestCase): def tearDown(self): from email import charset as CharsetModule try: del CharsetModule.CHARSETS['fake'] except KeyError: pass def test_idempotent(self): eq = self.assertEqual # Make sure us-ascii = no Unicode conversion c = Charset('us-ascii') s = 'Hello World!' sp = c.to_splittable(s) eq(s, c.from_splittable(sp)) # test 8-bit idempotency with us-ascii s = '\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa' sp = c.to_splittable(s) eq(s, c.from_splittable(sp)) def test_body_encode(self): eq = self.assertEqual # Try a charset with QP body encoding c = Charset('iso-8859-1') eq('hello w=F6rld', c.body_encode('hello w\xf6rld')) # Try a charset with Base64 body encoding c = Charset('utf-8') eq('aGVsbG8gd29ybGQ=\n', c.body_encode('hello world')) # Try a charset with None body encoding c = Charset('us-ascii') eq('hello world', c.body_encode('hello world')) # Try the convert argument, where input codec <> output codec c = Charset('euc-jp') # With apologies to Tokio Kikuchi ;) try: eq('\x1b$B5FCO;~IW\x1b(B', c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7')) eq('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', False)) except LookupError: # We probably don't have the Japanese codecs installed pass # Testing SF bug #625509, which we have to fake, since there are no # built-in encodings where the header encoding is QP but the body # encoding is not. from email import charset as CharsetModule CharsetModule.add_charset('fake', CharsetModule.QP, None) c = Charset('fake') eq('hello w\xf6rld', c.body_encode('hello w\xf6rld')) def test_unicode_charset_name(self): charset = Charset(u'us-ascii') self.assertEqual(str(charset), 'us-ascii') self.assertRaises(errors.CharsetError, Charset, 'asc\xffii') # Test multilingual MIME headers. class TestHeader(TestEmailBase): def test_simple(self): eq = self.ndiffAssertEqual h = Header('Hello World!') eq(h.encode(), 'Hello World!') h.append(' Goodbye World!') eq(h.encode(), 'Hello World! Goodbye World!') def test_simple_surprise(self): eq = self.ndiffAssertEqual h = Header('Hello World!') eq(h.encode(), 'Hello World!') h.append('Goodbye World!') eq(h.encode(), 'Hello World! Goodbye World!') def test_header_needs_no_decoding(self): h = 'no decoding needed' self.assertEqual(decode_header(h), [(h, None)]) def test_long(self): h = Header("I am the very model of a modern Major-General; I've information vegetable, animal, and mineral; I know the kings of England, and I quote the fights historical from Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical; I understand equations, both the simple and quadratical; about binomial theorem I'm teeming with a lot o' news, with many cheerful facts about the square of the hypotenuse.", maxlinelen=76) for l in h.encode(splitchars=' ').split('\n '): self.failUnless(len(l) <= 76) def test_multilingual(self): eq = self.ndiffAssertEqual g = Charset("iso-8859-1") cz = Charset("iso-8859-2") utf8 = Charset("utf-8") g_head = "Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an s\xfcdl\xfcndischen Wandgem\xe4lden vorbei, gegen die rotierenden Klingen bef\xf6rdert. " cz_head = "Finan\xe8ni metropole se hroutily pod tlakem jejich d\xf9vtipu.. " utf8_head = u"\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u4e00\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.\u300d\u3068\u8a00\u3063\u3066\u3044\u307e\u3059\u3002".encode("utf-8") h = Header(g_head, g) h.append(cz_head, cz) h.append(utf8_head, utf8) enc = h.encode() eq(enc, """\ =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderband_ko?= =?iso-8859-1?q?mfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen_Wan?= =?iso-8859-1?q?dgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef=F6?= =?iso-8859-1?q?rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hroutily?= =?iso-8859-2?q?_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K6?= =?utf-8?b?44Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb44KT44CC?= =?utf-8?b?5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go44Gv44Gn?= =?utf-8?b?44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGFz?= =?utf-8?q?_Nunstuck_git_und_Slotermeyer=3F_Ja!_Beiherhund_das_Oder_die_Fl?= =?utf-8?b?aXBwZXJ3YWxkdCBnZXJzcHV0LuOAjeOBqOiogOOBo+OBpuOBhOOBvuOBmQ==?= =?utf-8?b?44CC?=""") eq(decode_header(enc), [(g_head, "iso-8859-1"), (cz_head, "iso-8859-2"), (utf8_head, "utf-8")]) ustr = unicode(h) eq(ustr.encode('utf-8'), 'Die Mieter treten hier ein werden mit einem Foerderband ' 'komfortabel den Korridor entlang, an s\xc3\xbcdl\xc3\xbcndischen ' 'Wandgem\xc3\xa4lden vorbei, gegen die rotierenden Klingen ' 'bef\xc3\xb6rdert. Finan\xc4\x8dni metropole se hroutily pod ' 'tlakem jejich d\xc5\xafvtipu.. \xe6\xad\xa3\xe7\xa2\xba\xe3\x81' '\xab\xe8\xa8\x80\xe3\x81\x86\xe3\x81\xa8\xe7\xbf\xbb\xe8\xa8\xb3' '\xe3\x81\xaf\xe3\x81\x95\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x84\xe3' '\x81\xbe\xe3\x81\x9b\xe3\x82\x93\xe3\x80\x82\xe4\xb8\x80\xe9\x83' '\xa8\xe3\x81\xaf\xe3\x83\x89\xe3\x82\xa4\xe3\x83\x84\xe8\xaa\x9e' '\xe3\x81\xa7\xe3\x81\x99\xe3\x81\x8c\xe3\x80\x81\xe3\x81\x82\xe3' '\x81\xa8\xe3\x81\xaf\xe3\x81\xa7\xe3\x81\x9f\xe3\x82\x89\xe3\x82' '\x81\xe3\x81\xa7\xe3\x81\x99\xe3\x80\x82\xe5\xae\x9f\xe9\x9a\x9b' '\xe3\x81\xab\xe3\x81\xaf\xe3\x80\x8cWenn ist das Nunstuck git ' 'und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt ' 'gersput.\xe3\x80\x8d\xe3\x81\xa8\xe8\xa8\x80\xe3\x81\xa3\xe3\x81' '\xa6\xe3\x81\x84\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82') # Test make_header() newh = make_header(decode_header(enc)) eq(newh, enc) def test_header_ctor_default_args(self): eq = self.ndiffAssertEqual h = Header() eq(h, '') h.append('foo', Charset('iso-8859-1')) eq(h, '=?iso-8859-1?q?foo?=') def test_explicit_maxlinelen(self): eq = self.ndiffAssertEqual hstr = 'A very long line that must get split to something other than at the 76th character boundary to test the non-default behavior' h = Header(hstr) eq(h.encode(), '''\ A very long line that must get split to something other than at the 76th character boundary to test the non-default behavior''') h = Header(hstr, header_name='Subject') eq(h.encode(), '''\ A very long line that must get split to something other than at the 76th character boundary to test the non-default behavior''') h = Header(hstr, maxlinelen=1024, header_name='Subject') eq(h.encode(), hstr) def test_us_ascii_header(self): eq = self.assertEqual s = 'hello' x = decode_header(s) eq(x, [('hello', None)]) h = make_header(x) eq(s, h.encode()) def test_string_charset(self): eq = self.assertEqual h = Header() h.append('hello', 'iso-8859-1') eq(h, '=?iso-8859-1?q?hello?=') ## def test_unicode_error(self): ## raises = self.assertRaises ## raises(UnicodeError, Header, u'[P\xf6stal]', 'us-ascii') ## raises(UnicodeError, Header, '[P\xf6stal]', 'us-ascii') ## h = Header() ## raises(UnicodeError, h.append, u'[P\xf6stal]', 'us-ascii') ## raises(UnicodeError, h.append, '[P\xf6stal]', 'us-ascii') ## raises(UnicodeError, Header, u'\u83ca\u5730\u6642\u592b', 'iso-8859-1') def test_utf8_shortest(self): eq = self.assertEqual h = Header(u'p\xf6stal', 'utf-8') eq(h.encode(), '=?utf-8?q?p=C3=B6stal?=') h = Header(u'\u83ca\u5730\u6642\u592b', 'utf-8') eq(h.encode(), '=?utf-8?b?6I+K5Zyw5pmC5aSr?=') def test_bad_8bit_header(self): raises = self.assertRaises eq = self.assertEqual x = 'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big' raises(UnicodeError, Header, x) h = Header() raises(UnicodeError, h.append, x) eq(str(Header(x, errors='replace')), x) h.append(x, errors='replace') eq(str(h), x) def test_encoded_adjacent_nonencoded(self): eq = self.assertEqual h = Header() h.append('hello', 'iso-8859-1') h.append('world') s = h.encode() eq(s, '=?iso-8859-1?q?hello?= world') h = make_header(decode_header(s)) eq(h.encode(), s) def test_whitespace_eater(self): eq = self.assertEqual s = 'Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztk=?= =?koi8-r?q?=CA?= zz.' parts = decode_header(s) eq(parts, [('Subject:', None), ('\xf0\xd2\xcf\xd7\xc5\xd2\xcb\xc1 \xce\xc1 \xc6\xc9\xce\xc1\xcc\xd8\xce\xd9\xca', 'koi8-r'), ('zz.', None)]) hdr = make_header(parts) eq(hdr.encode(), 'Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztnK?= zz.') def test_broken_base64_header(self): raises = self.assertRaises s = 'Subject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3IQ?=' raises(errors.HeaderParseError, decode_header, s) # Test RFC 2231 header parameters (en/de)coding class TestRFC2231(TestEmailBase): def test_get_param(self): eq = self.assertEqual msg = self._msgobj('msg_29.txt') eq(msg.get_param('title'), ('us-ascii', 'en', 'This is even more ***fun*** isn\'t it!')) eq(msg.get_param('title', unquote=False), ('us-ascii', 'en', '"This is even more ***fun*** isn\'t it!"')) def test_set_param(self): eq = self.assertEqual msg = Message() msg.set_param('title', 'This is even more ***fun*** isn\'t it!', charset='us-ascii') eq(msg.get_param('title'), ('us-ascii', '', 'This is even more ***fun*** isn\'t it!')) msg.set_param('title', 'This is even more ***fun*** isn\'t it!', charset='us-ascii', language='en') eq(msg.get_param('title'), ('us-ascii', 'en', 'This is even more ***fun*** isn\'t it!')) msg = self._msgobj('msg_01.txt') msg.set_param('title', 'This is even more ***fun*** isn\'t it!', charset='us-ascii', language='en') eq(msg.as_string(), """\ Return-Path: <bbb@zzz.org> Delivered-To: bbb@zzz.org Received: by mail.zzz.org (Postfix, from userid 889) \tid 27CEAD38CC; Fri, 4 May 2001 14:05:44 -0400 (EDT) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: <15090.61304.110929.45684@aaa.zzz.org> From: bbb@ddd.com (John X. Doe) To: bbb@zzz.org Subject: This is a test message Date: Fri, 4 May 2001 14:05:44 -0400 Content-Type: text/plain; charset=us-ascii; \ttitle*="us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21" Hi, Do you like this message? -Me """) def test_del_param(self): eq = self.ndiffAssertEqual msg = self._msgobj('msg_01.txt') msg.set_param('foo', 'bar', charset='us-ascii', language='en') msg.set_param('title', 'This is even more ***fun*** isn\'t it!', charset='us-ascii', language='en') msg.del_param('foo', header='Content-Type') eq(msg.as_string(), """\ Return-Path: <bbb@zzz.org> Delivered-To: bbb@zzz.org Received: by mail.zzz.org (Postfix, from userid 889) \tid 27CEAD38CC; Fri, 4 May 2001 14:05:44 -0400 (EDT) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: <15090.61304.110929.45684@aaa.zzz.org> From: bbb@ddd.com (John X. Doe) To: bbb@zzz.org Subject: This is a test message Date: Fri, 4 May 2001 14:05:44 -0400 Content-Type: text/plain; charset="us-ascii"; \ttitle*="us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21" Hi, Do you like this message? -Me """) def test_rfc2231_get_content_charset(self): eq = self.assertEqual msg = self._msgobj('msg_32.txt') eq(msg.get_content_charset(), 'us-ascii') def test_rfc2231_no_language_or_charset(self): m = '''\ Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm" Content-Type: text/html; NAME*0=file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEM; NAME*1=P_nsmail.htm ''' msg = email.message_from_string(m) param = msg.get_param('NAME') self.failIf(isinstance(param, tuple)) self.assertEqual( param, 'file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm') def test_rfc2231_no_language_or_charset_in_filename(self): m = '''\ Content-Disposition: inline; \tfilename*0*="''This%20is%20even%20more%20"; \tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20"; \tfilename*2="is it not.pdf" ''' msg = email.message_from_string(m) self.assertEqual(msg.get_filename(), 'This is even more ***fun*** is it not.pdf') def test_rfc2231_no_language_or_charset_in_filename_encoded(self): m = '''\ Content-Disposition: inline; \tfilename*0*="''This%20is%20even%20more%20"; \tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20"; \tfilename*2="is it not.pdf" ''' msg = email.message_from_string(m) self.assertEqual(msg.get_filename(), 'This is even more ***fun*** is it not.pdf') def test_rfc2231_partly_encoded(self): m = '''\ Content-Disposition: inline; \tfilename*0="''This%20is%20even%20more%20"; \tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20"; \tfilename*2="is it not.pdf" ''' msg = email.message_from_string(m) self.assertEqual( msg.get_filename(), 'This%20is%20even%20more%20***fun*** is it not.pdf') def test_rfc2231_partly_nonencoded(self): m = '''\ Content-Disposition: inline; \tfilename*0="This%20is%20even%20more%20"; \tfilename*1="%2A%2A%2Afun%2A%2A%2A%20"; \tfilename*2="is it not.pdf" ''' msg = email.message_from_string(m) self.assertEqual( msg.get_filename(), 'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20is it not.pdf') def test_rfc2231_no_language_or_charset_in_boundary(self): m = '''\ Content-Type: multipart/alternative; \tboundary*0*="''This%20is%20even%20more%20"; \tboundary*1*="%2A%2A%2Afun%2A%2A%2A%20"; \tboundary*2="is it not.pdf" ''' msg = email.message_from_string(m) self.assertEqual(msg.get_boundary(), 'This is even more ***fun*** is it not.pdf') def test_rfc2231_no_language_or_charset_in_charset(self): # This is a nonsensical charset value, but tests the code anyway m = '''\ Content-Type: text/plain; \tcharset*0*="This%20is%20even%20more%20"; \tcharset*1*="%2A%2A%2Afun%2A%2A%2A%20"; \tcharset*2="is it not.pdf" ''' msg = email.message_from_string(m) self.assertEqual(msg.get_content_charset(), 'this is even more ***fun*** is it not.pdf') def test_rfc2231_bad_encoding_in_filename(self): m = '''\ Content-Disposition: inline; \tfilename*0*="bogus'xx'This%20is%20even%20more%20"; \tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20"; \tfilename*2="is it not.pdf" ''' msg = email.message_from_string(m) self.assertEqual(msg.get_filename(), 'This is even more ***fun*** is it not.pdf') def test_rfc2231_bad_encoding_in_charset(self): m = """\ Content-Type: text/plain; charset*=bogus''utf-8%E2%80%9D """ msg = email.message_from_string(m) # This should return None because non-ascii characters in the charset # are not allowed. self.assertEqual(msg.get_content_charset(), None) def test_rfc2231_bad_character_in_charset(self): m = """\ Content-Type: text/plain; charset*=ascii''utf-8%E2%80%9D """ msg = email.message_from_string(m) # This should return None because non-ascii characters in the charset # are not allowed. self.assertEqual(msg.get_content_charset(), None) def test_rfc2231_bad_character_in_filename(self): m = '''\ Content-Disposition: inline; \tfilename*0*="ascii'xx'This%20is%20even%20more%20"; \tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20"; \tfilename*2*="is it not.pdf%E2" ''' msg = email.message_from_string(m) self.assertEqual(msg.get_filename(), u'This is even more ***fun*** is it not.pdf\ufffd') def test_rfc2231_unknown_encoding(self): m = """\ Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename*=X-UNKNOWN''myfile.txt """ msg = email.message_from_string(m) self.assertEqual(msg.get_filename(), 'myfile.txt') def test_rfc2231_single_tick_in_filename_extended(self): eq = self.assertEqual m = """\ Content-Type: application/x-foo; \tname*0*=\"Frank's\"; name*1*=\" Document\" """ msg = email.message_from_string(m) charset, language, s = msg.get_param('name') eq(charset, None) eq(language, None) eq(s, "Frank's Document") def test_rfc2231_single_tick_in_filename(self): m = """\ Content-Type: application/x-foo; name*0=\"Frank's\"; name*1=\" Document\" """ msg = email.message_from_string(m) param = msg.get_param('name') self.failIf(isinstance(param, tuple)) self.assertEqual(param, "Frank's Document") def test_rfc2231_tick_attack_extended(self): eq = self.assertEqual m = """\ Content-Type: application/x-foo; \tname*0*=\"us-ascii'en-us'Frank's\"; name*1*=\" Document\" """ msg = email.message_from_string(m) charset, language, s = msg.get_param('name') eq(charset, 'us-ascii') eq(language, 'en-us') eq(s, "Frank's Document") def test_rfc2231_tick_attack(self): m = """\ Content-Type: application/x-foo; \tname*0=\"us-ascii'en-us'Frank's\"; name*1=\" Document\" """ msg = email.message_from_string(m) param = msg.get_param('name') self.failIf(isinstance(param, tuple)) self.assertEqual(param, "us-ascii'en-us'Frank's Document") def test_rfc2231_no_extended_values(self): eq = self.assertEqual m = """\ Content-Type: application/x-foo; name=\"Frank's Document\" """ msg = email.message_from_string(m) eq(msg.get_param('name'), "Frank's Document") def test_rfc2231_encoded_then_unencoded_segments(self): eq = self.assertEqual m = """\ Content-Type: application/x-foo; \tname*0*=\"us-ascii'en-us'My\"; \tname*1=\" Document\"; \tname*2*=\" For You\" """ msg = email.message_from_string(m) charset, language, s = msg.get_param('name') eq(charset, 'us-ascii') eq(language, 'en-us') eq(s, 'My Document For You') def test_rfc2231_unencoded_then_encoded_segments(self): eq = self.assertEqual m = """\ Content-Type: application/x-foo; \tname*0=\"us-ascii'en-us'My\"; \tname*1*=\" Document\"; \tname*2*=\" For You\" """ msg = email.message_from_string(m) charset, language, s = msg.get_param('name') eq(charset, 'us-ascii') eq(language, 'en-us') eq(s, 'My Document For You') def _testclasses(): mod = sys.modules[__name__] return [getattr(mod, name) for name in dir(mod) if name.startswith('Test')] def suite(): suite = unittest.TestSuite() for testclass in _testclasses(): suite.addTest(unittest.makeSuite(testclass)) return suite def test_main(): for testclass in _testclasses(): run_unittest(testclass) if __name__ == '__main__': unittest.main(defaultTest='suite')
gpl-3.0
[ 3, 1898, 334, 35, 9, 12521, 13, 9488, 2018, 2290, 2752, 199, 3, 18684, 26, 3031, 13, 4093, 32, 1548, 14, 1308, 199, 3, 3031, 2559, 4137, 2295, 199, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 646, 1300, 772, 199, 646, 27070, 199, 646, 2882, 199, 646, 3598, 199, 504, 15073, 492, 5228, 199, 199, 646, 3031, 199, 199, 504, 3031, 14, 6043, 492, 29392, 199, 504, 3031, 14, 1291, 492, 10240, 12, 4849, 63, 1291, 12, 1852, 63, 1291, 199, 504, 3031, 14, 2087, 492, 10191, 12, 10240, 2842, 199, 504, 3031, 14, 4679, 492, 15042, 12, 1487, 15282, 7599, 199, 504, 3031, 14, 1188, 492, 6430, 199, 504, 3031, 14, 7626, 14, 3578, 492, 14735, 5039, 199, 504, 3031, 14, 7626, 14, 8130, 492, 14735, 15484, 199, 504, 3031, 14, 7626, 14, 505, 492, 603, 26567, 199, 504, 3031, 14, 7626, 14, 1569, 492, 14735, 3491, 199, 504, 3031, 14, 7626, 14, 1095, 492, 14735, 1563, 199, 504, 3031, 14, 7626, 14, 1188, 492, 14735, 2209, 199, 504, 3031, 14, 7626, 14, 10123, 492, 603, 30596, 1141, 2064, 199, 504, 3031, 492, 3778, 199, 504, 3031, 492, 2552, 199, 504, 3031, 492, 10295, 83, 199, 504, 3031, 492, 28241, 199, 504, 3031, 492, 1300, 772, 7626, 199, 504, 3031, 492, 2173, 21993, 7626, 199, 199, 504, 511, 14, 396, 63, 4058, 492, 2342, 493, 12, 1255, 63, 2796, 199, 504, 3031, 14, 396, 492, 636, 493, 363, 465, 20078, 1657, 421, 199, 14176, 275, 1557, 78, 7, 199, 13993, 5353, 275, 2125, 199, 11658, 275, 283, 283, 4388, 201, 199, 318, 1551, 493, 8, 1501, 12, 818, 534, 82, 735, 272, 931, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 9688, 1657, 395, 283, 576, 297, 1788, 9, 272, 372, 1551, 8, 515, 12, 818, 9, 4388, 201, 199, 3, 3523, 511, 1021, 199, 533, 1379, 7035, 1563, 8, 2796, 14, 1746, 304, 272, 347, 302, 3028, 28560, 8, 277, 12, 1642, 12, 3499, 304, 267, 408, 12545, 2449, 5524, 591, 871, 675, 302, 3028, 367, 12701, 1072, 1041, 267, 340, 1642, 20941, 3499, 26, 288, 308, 2246, 275, 620, 8, 2246, 9, 288, 308, 4375, 275, 620, 8, 4375, 9, 288, 3915, 275, 27070, 14, 28632, 8, 83, 2246, 14, 7644, 1062, 308, 4375, 14, 7644, 1012, 288, 4090, 275, 5228, 342, 288, 870, 4331, 4090, 12, 24719, 12, 24719, 14, 904, 8, 3028, 9, 288, 746, 291, 14, 15935, 12, 4090, 14, 7150, 342, 339, 347, 485, 28048, 8, 277, 12, 1788, 304, 267, 4090, 275, 1551, 493, 8, 1623, 493, 8, 1501, 430, 267, 862, 26, 288, 1499, 275, 3031, 14, 1188, 63, 504, 63, 493, 8, 3997, 9, 267, 3753, 26, 288, 4090, 14, 1600, 342, 267, 372, 1499, 4388, 201, 199, 3, 1379, 7750, 17435, 83, 402, 314, 6430, 1021, 1159, 3261, 199, 533, 1379, 2209, 3735, 8, 774, 7035, 1563, 304, 272, 347, 511, 63, 362, 63, 452, 8, 277, 304, 267, 3850, 275, 291, 14, 629, 267, 1499, 275, 291, 423, 28048, 360, 1328, 63, 1165, 14, 2424, 358, 267, 3850, 8, 1328, 14, 362, 63, 452, 360, 2055, 659, 788, 19504, 32, 29414, 14, 1308, 297, 283, 15389, 32, 29414, 14, 1308, 297, 283, 18777, 32, 29414, 14, 1308, 1105, 267, 3850, 8, 1328, 14, 362, 63, 452, 360, 2154, 297, 283, 78, 15, 65, 659, 283, 78, 15, 65, 358, 339, 347, 511, 63, 362, 409, 63, 6043, 8, 277, 304, 267, 3850, 275, 291, 14, 629, 267, 1499, 275, 6430, 342, 267, 3850, 8, 1328, 14, 362, 63, 6043, 1062, 488, 9, 267, 5960, 275, 29392, 360, 4595, 13, 4830, 13, 17, 358, 267, 1499, 14, 409, 63, 6043, 8, 6043, 9, 267, 3850, 8, 1328, 459, 7626, 13, 1023, 995, 283, 17, 14, 16, 358, 267, 3850, 8, 1328, 14, 362, 63, 1317, 63, 466, 1062, 283, 505, 15, 6104, 358, 267, 3850, 8, 1328, 459, 1317, 13, 466, 995, 283, 505, 15, 6104, 27, 5960, 628, 4595, 13, 4830, 13, 17, 9008, 267, 3850, 8, 1328, 14, 362, 63, 635, 360, 6043, 659, 283, 4595, 13, 4830, 13, 17, 358, 267, 3850, 8, 1328, 459, 1317, 13, 9609, 13, 2991, 995, 283, 9888, 13, 20557, 358, 267, 3850, 8, 1328, 14, 362, 63, 6043, 1252, 1210, 63, 6043, 12, 283, 4595, 13, 4830, 13, 17, 358, 267, 327, 5852, 314, 5960, 267, 1499, 14, 409, 63, 6043, 8, 403, 9, 267, 3850, 8, 1328, 14, 362, 63, 6043, 1062, 488, 9, 267, 3850, 8, 1328, 459, 1317, 13, 466, 995, 283, 505, 15, 6104, 358, 267, 327, 7649, 7791, 282, 5960, 1380, 2337, 1159, 2575, 14735, 2323, 3451, 267, 1499, 275, 6430, 342, 267, 1499, 459, 17057, 13, 3353, 418, 275, 283, 18, 14, 16, 7, 267, 1499, 459, 2714, 13, 804, 418, 275, 283, 505, 15, 88, 13, 1129, 5428, 7, 267, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 392, 9082, 13, 80, 638, 461, 7, 267, 1499, 14, 409, 63, 6043, 8, 6043, 9, 267, 3850, 8, 1328, 459, 7626, 13, 1023, 995, 283, 18, 14, 16, 358, 267, 3850, 8, 1328, 459, 1317, 13, 466, 995, 283, 505, 15, 88, 13, 1129, 5428, 27, 5960, 628, 4595, 13, 4830, 13, 17, 9008, 267, 3850, 8, 1328, 459, 1317, 13, 9609, 13, 2991, 995, 283, 392, 9082, 13, 80, 638, 461, 358, 339, 347, 511, 63, 409, 63, 6043, 63, 504, 63, 875, 8, 277, 304, 267, 3850, 275, 291, 14, 629, 267, 1499, 275, 6430, 342, 267, 1499, 14, 409, 63, 6043, 360, 527, 13, 4371, 358, 267, 3850, 8, 1328, 14, 362, 63, 6043, 1252, 1210, 63, 6043, 12, 283, 527, 13, 4371, 358, 267, 3850, 8, 1328, 459, 1317, 13, 466, 995, 283, 505, 15, 6104, 27, 5960, 628, 527, 13, 4371, 9008, 339, 347, 511, 63, 409, 63, 4749, 63, 1045, 63, 6043, 8, 277, 304, 267, 1499, 275, 6430, 342, 267, 5960, 275, 29392, 360, 4595, 13, 4830, 13, 17, 358, 267, 1499, 14, 409, 63, 4749, 360, 2765, 365, 282, 1059, 4886, 297, 5960, 9, 267, 291, 14, 629, 8, 1328 ]
[ 1898, 334, 35, 9, 12521, 13, 9488, 2018, 2290, 2752, 199, 3, 18684, 26, 3031, 13, 4093, 32, 1548, 14, 1308, 199, 3, 3031, 2559, 4137, 2295, 199, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 646, 1300, 772, 199, 646, 27070, 199, 646, 2882, 199, 646, 3598, 199, 504, 15073, 492, 5228, 199, 199, 646, 3031, 199, 199, 504, 3031, 14, 6043, 492, 29392, 199, 504, 3031, 14, 1291, 492, 10240, 12, 4849, 63, 1291, 12, 1852, 63, 1291, 199, 504, 3031, 14, 2087, 492, 10191, 12, 10240, 2842, 199, 504, 3031, 14, 4679, 492, 15042, 12, 1487, 15282, 7599, 199, 504, 3031, 14, 1188, 492, 6430, 199, 504, 3031, 14, 7626, 14, 3578, 492, 14735, 5039, 199, 504, 3031, 14, 7626, 14, 8130, 492, 14735, 15484, 199, 504, 3031, 14, 7626, 14, 505, 492, 603, 26567, 199, 504, 3031, 14, 7626, 14, 1569, 492, 14735, 3491, 199, 504, 3031, 14, 7626, 14, 1095, 492, 14735, 1563, 199, 504, 3031, 14, 7626, 14, 1188, 492, 14735, 2209, 199, 504, 3031, 14, 7626, 14, 10123, 492, 603, 30596, 1141, 2064, 199, 504, 3031, 492, 3778, 199, 504, 3031, 492, 2552, 199, 504, 3031, 492, 10295, 83, 199, 504, 3031, 492, 28241, 199, 504, 3031, 492, 1300, 772, 7626, 199, 504, 3031, 492, 2173, 21993, 7626, 199, 199, 504, 511, 14, 396, 63, 4058, 492, 2342, 493, 12, 1255, 63, 2796, 199, 504, 3031, 14, 396, 492, 636, 493, 363, 465, 20078, 1657, 421, 199, 14176, 275, 1557, 78, 7, 199, 13993, 5353, 275, 2125, 199, 11658, 275, 283, 283, 4388, 201, 199, 318, 1551, 493, 8, 1501, 12, 818, 534, 82, 735, 272, 931, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 9688, 1657, 395, 283, 576, 297, 1788, 9, 272, 372, 1551, 8, 515, 12, 818, 9, 4388, 201, 199, 3, 3523, 511, 1021, 199, 533, 1379, 7035, 1563, 8, 2796, 14, 1746, 304, 272, 347, 302, 3028, 28560, 8, 277, 12, 1642, 12, 3499, 304, 267, 408, 12545, 2449, 5524, 591, 871, 675, 302, 3028, 367, 12701, 1072, 1041, 267, 340, 1642, 20941, 3499, 26, 288, 308, 2246, 275, 620, 8, 2246, 9, 288, 308, 4375, 275, 620, 8, 4375, 9, 288, 3915, 275, 27070, 14, 28632, 8, 83, 2246, 14, 7644, 1062, 308, 4375, 14, 7644, 1012, 288, 4090, 275, 5228, 342, 288, 870, 4331, 4090, 12, 24719, 12, 24719, 14, 904, 8, 3028, 9, 288, 746, 291, 14, 15935, 12, 4090, 14, 7150, 342, 339, 347, 485, 28048, 8, 277, 12, 1788, 304, 267, 4090, 275, 1551, 493, 8, 1623, 493, 8, 1501, 430, 267, 862, 26, 288, 1499, 275, 3031, 14, 1188, 63, 504, 63, 493, 8, 3997, 9, 267, 3753, 26, 288, 4090, 14, 1600, 342, 267, 372, 1499, 4388, 201, 199, 3, 1379, 7750, 17435, 83, 402, 314, 6430, 1021, 1159, 3261, 199, 533, 1379, 2209, 3735, 8, 774, 7035, 1563, 304, 272, 347, 511, 63, 362, 63, 452, 8, 277, 304, 267, 3850, 275, 291, 14, 629, 267, 1499, 275, 291, 423, 28048, 360, 1328, 63, 1165, 14, 2424, 358, 267, 3850, 8, 1328, 14, 362, 63, 452, 360, 2055, 659, 788, 19504, 32, 29414, 14, 1308, 297, 283, 15389, 32, 29414, 14, 1308, 297, 283, 18777, 32, 29414, 14, 1308, 1105, 267, 3850, 8, 1328, 14, 362, 63, 452, 360, 2154, 297, 283, 78, 15, 65, 659, 283, 78, 15, 65, 358, 339, 347, 511, 63, 362, 409, 63, 6043, 8, 277, 304, 267, 3850, 275, 291, 14, 629, 267, 1499, 275, 6430, 342, 267, 3850, 8, 1328, 14, 362, 63, 6043, 1062, 488, 9, 267, 5960, 275, 29392, 360, 4595, 13, 4830, 13, 17, 358, 267, 1499, 14, 409, 63, 6043, 8, 6043, 9, 267, 3850, 8, 1328, 459, 7626, 13, 1023, 995, 283, 17, 14, 16, 358, 267, 3850, 8, 1328, 14, 362, 63, 1317, 63, 466, 1062, 283, 505, 15, 6104, 358, 267, 3850, 8, 1328, 459, 1317, 13, 466, 995, 283, 505, 15, 6104, 27, 5960, 628, 4595, 13, 4830, 13, 17, 9008, 267, 3850, 8, 1328, 14, 362, 63, 635, 360, 6043, 659, 283, 4595, 13, 4830, 13, 17, 358, 267, 3850, 8, 1328, 459, 1317, 13, 9609, 13, 2991, 995, 283, 9888, 13, 20557, 358, 267, 3850, 8, 1328, 14, 362, 63, 6043, 1252, 1210, 63, 6043, 12, 283, 4595, 13, 4830, 13, 17, 358, 267, 327, 5852, 314, 5960, 267, 1499, 14, 409, 63, 6043, 8, 403, 9, 267, 3850, 8, 1328, 14, 362, 63, 6043, 1062, 488, 9, 267, 3850, 8, 1328, 459, 1317, 13, 466, 995, 283, 505, 15, 6104, 358, 267, 327, 7649, 7791, 282, 5960, 1380, 2337, 1159, 2575, 14735, 2323, 3451, 267, 1499, 275, 6430, 342, 267, 1499, 459, 17057, 13, 3353, 418, 275, 283, 18, 14, 16, 7, 267, 1499, 459, 2714, 13, 804, 418, 275, 283, 505, 15, 88, 13, 1129, 5428, 7, 267, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 392, 9082, 13, 80, 638, 461, 7, 267, 1499, 14, 409, 63, 6043, 8, 6043, 9, 267, 3850, 8, 1328, 459, 7626, 13, 1023, 995, 283, 18, 14, 16, 358, 267, 3850, 8, 1328, 459, 1317, 13, 466, 995, 283, 505, 15, 88, 13, 1129, 5428, 27, 5960, 628, 4595, 13, 4830, 13, 17, 9008, 267, 3850, 8, 1328, 459, 1317, 13, 9609, 13, 2991, 995, 283, 392, 9082, 13, 80, 638, 461, 358, 339, 347, 511, 63, 409, 63, 6043, 63, 504, 63, 875, 8, 277, 304, 267, 3850, 275, 291, 14, 629, 267, 1499, 275, 6430, 342, 267, 1499, 14, 409, 63, 6043, 360, 527, 13, 4371, 358, 267, 3850, 8, 1328, 14, 362, 63, 6043, 1252, 1210, 63, 6043, 12, 283, 527, 13, 4371, 358, 267, 3850, 8, 1328, 459, 1317, 13, 466, 995, 283, 505, 15, 6104, 27, 5960, 628, 527, 13, 4371, 9008, 339, 347, 511, 63, 409, 63, 4749, 63, 1045, 63, 6043, 8, 277, 304, 267, 1499, 275, 6430, 342, 267, 5960, 275, 29392, 360, 4595, 13, 4830, 13, 17, 358, 267, 1499, 14, 409, 63, 4749, 360, 2765, 365, 282, 1059, 4886, 297, 5960, 9, 267, 291, 14, 629, 8, 1328, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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