diff --git a/.gitattributes b/.gitattributes index a6344aac8c09253b3b630fb776ae94478aa0275b..6b1209addbbbd630bf4affb636ba52ffd70e3a17 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,35 +1,4 @@ -*.7z filter=lfs diff=lfs merge=lfs -text -*.arrow filter=lfs diff=lfs merge=lfs -text -*.bin filter=lfs diff=lfs merge=lfs -text -*.bz2 filter=lfs diff=lfs merge=lfs -text -*.ckpt filter=lfs diff=lfs merge=lfs -text -*.ftz filter=lfs diff=lfs merge=lfs -text -*.gz filter=lfs diff=lfs merge=lfs -text -*.h5 filter=lfs diff=lfs merge=lfs -text -*.joblib filter=lfs diff=lfs merge=lfs -text -*.lfs.* filter=lfs diff=lfs merge=lfs -text -*.mlmodel filter=lfs diff=lfs merge=lfs -text -*.model filter=lfs diff=lfs merge=lfs -text -*.msgpack filter=lfs diff=lfs merge=lfs -text -*.npy filter=lfs diff=lfs merge=lfs -text -*.npz filter=lfs diff=lfs merge=lfs -text -*.onnx filter=lfs diff=lfs merge=lfs -text -*.ot filter=lfs diff=lfs merge=lfs -text -*.parquet filter=lfs diff=lfs merge=lfs -text -*.pb filter=lfs diff=lfs merge=lfs -text -*.pickle filter=lfs diff=lfs merge=lfs -text -*.pkl filter=lfs diff=lfs merge=lfs -text -*.pt filter=lfs diff=lfs merge=lfs -text -*.pth filter=lfs diff=lfs merge=lfs -text -*.rar filter=lfs diff=lfs merge=lfs -text *.safetensors filter=lfs diff=lfs merge=lfs -text -saved_model/**/* filter=lfs diff=lfs merge=lfs -text -*.tar.* filter=lfs diff=lfs merge=lfs -text -*.tar filter=lfs diff=lfs merge=lfs -text -*.tflite filter=lfs diff=lfs merge=lfs -text -*.tgz filter=lfs diff=lfs merge=lfs -text -*.wasm filter=lfs diff=lfs merge=lfs -text -*.xz filter=lfs diff=lfs merge=lfs -text -*.zip filter=lfs diff=lfs merge=lfs -text -*.zst filter=lfs diff=lfs merge=lfs -text -*tfevents* filter=lfs diff=lfs merge=lfs -text +*.gguf filter=lfs diff=lfs merge=lfs -text +*.jsonl filter=lfs diff=lfs merge=lfs -text +*.pyc filter=lfs diff=lfs merge=lfs -text diff --git a/DATA-CARD-training-corpus.md b/DATA-CARD-training-corpus.md new file mode 100644 index 0000000000000000000000000000000000000000..935dae7de9841a052343a909d6606a6f74095af0 --- /dev/null +++ b/DATA-CARD-training-corpus.md @@ -0,0 +1,141 @@ +# Data card — PyBytecode v2 / v3 training corpus + +The corpus behind `pybytecode-v2-1.5b` and `pybytecode-v3-1.5b`. Written 2026-08-04; no data card +existed before. + +**This corpus is not distributed.** Section 5 states why, as a property of the artifact rather +than an apology. The model weights are unaffected — see `WEIGHTS-LICENSE-PROPOSAL.md`. + +--- + +## 1. What it is + +| | | +|---|---| +| Task | Python 3.12 bytecode disassembly → original source | +| Rows | **48,196** (identical row set in v2 and v3) | +| Row shape | `{"input": , "output": }` | +| Source dataset | `codeparrot/github-code-clean` (the dataset itself is Apache-2.0) | +| Shards used for training | 0–5 | +| Unit | one top-level function plus its transitive helpers and imports | +| Python | 3.12, `optimize=0` | +| Files | `data/foundry/pybytecode-v2_train.jsonl`, `-v3_train.jsonl`, `-v3-sft_train.jsonl` | + +v3 differs from v2 in the **input representation only**. v2's `rep.py` omitted the exception +table's `end`, so a bare `try:` body and a `try/else:` body that compile to the same instruction +stream were byte-identical in the model's input. v3 emits `EXC try=Ls..Le -> ...` and the end +label joins the label set, making the two distinguishable. 14,122 of 48,196 inputs changed; +no row was added, removed or relabelled (`data/foundry/pybytecode-artifacts/v3_build_report.json`). +Any v2→v3 delta is therefore attributable to the representation fix alone. + +## 2. Licence filtering — what was dropped, and why + +`scripts/pybytecode/extract_v2.py` filters **per row** on `github-code-clean`'s `license` column +and keeps seven permissive values: + +``` +mit apache-2.0 bsd-2-clause bsd-3-clause isc unlicense cc0-1.0 +``` + +Every GPL, LGPL, AGPL, MPL and EPL row is dropped before extraction, along with everything the +column does not positively identify. The intent was to avoid training on reciprocally-licensed +source; the filter is a hard gate, not a preference. + +Rows are then dropped by a chain of quality gates, each counted rather than silently applied: +unparseable; not stable under `ast.unparse` round-trip (`canonicalise(canon) != canon`); does not +compile; disassembly or source over the size ceiling; duplicate of an already-kept unit +(SHA-1 of the canonical source). + +## 3. Decontamination against the test sets + +Three layers, because one is never enough (`scripts/pybytecode/build_final.py`): + +1. **Shard-disjoint** — training from shards 0–5, held-out pool from shards 8–9. The held-out + pool was never read during training extraction. +2. **Repo-disjoint** — any repo appearing in training is removed from the held-out pool outright. + A repo can span shards, so layer 1 does not imply this. +3. **Fingerprint-disjoint** — an identifier-blind structural fingerprint (every `Name`/`arg`/ + attribute → placeholder, every literal → its type name). This catches the same algorithm under + renamed variables, which exact match misses. It caught 15 items exact match missed. + +The CSN benchmarks apply the same identifier-blind fingerprint against this corpus. On the +600-row licensed rebuild it removed 3 rows. + +## 4. Labelling + +Labels are the canonical source itself, so the supervision is exact by construction. The grading +tier attached to each unit was assigned **by running an oracle**, not by inspection: + +- **tier A / behavioural** — differential execution. Kills 100% of injected semantic bugs; the + gold tier. +- **tier B / stub** — stubbed execution. Kills 78.9%, so scores on it are an **upper bound**. +- **tier C / AST-exact** — undercounts by roughly 2.4×, so scores on it are a **lower bound**. + +Only 5.43% of all real top-level Python functions survive to be behaviourally adjudicable. That +ceiling is why the byte-identical recompile oracle exists: it needs no runnable environment and +so has 100% coverage. + +## 5. The corpus cannot be redistributed + +**Per-row attribution was not retained.** `extract_v2.py` carried `repo` and `license` on every +row through extraction, and `build_final.py:118` writes only `{"input", "expected"}` when it +emits the final splits. The intermediate pool that still held the metadata was written to `/tmp` +and no longer exists. + +The consequence is specific: the corpus is 48,196 excerpts of MIT-, BSD-, Apache-, ISC- and +public-domain-licensed source, and every one of those licences except the two public-domain +dedications requires the copyright notice to be reproduced with the copy. We cannot produce those +notices, because we no longer know which row came from which repository. Redistributing the file +would strip required notices from tens of thousands of copyright holders. + +This is a limitation of the artifact, not of the licences: nothing about the corpus is unlicensed +or reciprocally licensed. It is not fixable by adding a licence file, and it is not repaired by +listing the source dataset — attribution under these licences is per-work, not per-collection. + +**It is fixable by rebuilding.** Extraction is deterministic and the source dataset is public. +Carrying `repo`, `license` and file path through `build_final.py`'s writer — one line — produces +an equivalent corpus that *is* redistributable with a `NOTICES` file. That is the recommended +fix for a v4 and it does not require retraining anything to be useful. + +## 6. Held-out evaluation sets built from the same corpus + +`data/foundry/pybytecode-v3-ood-{behavioural,stub,ast,doc}_test.jsonl` are drawn from the +held-out shards of this same corpus and **inherit section 5 exactly** — they carry no attribution +and cannot be redistributed either. + +They are named `-ood-` but they are **not out-of-distribution**: they are the same source and the +same distribution as training, held out three ways. Matching all 974 canonicalised +`google-research-datasets/mbpp` rows against them yields **0 matches** in all four files, while +the v1-era `pybytecode-ood_test.jsonl` matches at **400/400**. Only that v1-era file is MBPP. +Full evidence in `LICENSING-DETERMINATION.md` §4. + +They remain sound *generalisation* tests, and the numbers measured on them stand. Only the label +is wrong, and it should be corrected wherever it appears. + +**On the tier-A set specifically (n=279, the set behind the 91.04% and 97.49% figures):** it is +the complete behaviourally-adjudicable population of the held-out pool — the 400-row cap did not +truncate it, whereas the stub and ast tiers both hit that cap. The pool was therefore larger than +400 units, but its exact size is **not recoverable**: `build_final.py` printed its census to +stdout and no run log was kept. The framing "279 of 400 = 70% of the set" does not describe these +files (the four tiers are largely disjoint populations — the 279 behavioural rows share 9 function +names with the 400 stub rows and 8 with the 400 ast rows) and should not be used. Report the +denominator as 279 with the sentence above, or rebuild the pool to recover the true rate. + +## 7. Known confound, stated rather than engineered away + +`extract_v2.py` carries `from __future__ import annotations`, and its `compile()` call inherits +the flag, so the training bytecode has PEP-563 stringised annotations. **Real `.pyc` files are not +compiled that way.** The benchmarks deliberately compile with `dont_inherit=True`, giving the +model an input distribution it was not trained on for annotated functions. Any resulting handicap +is a real property of the model and is counted against it. + +## 8. Provenance summary + +| Field | Value | +|---|---| +| Base model | `Qwen/Qwen2.5-Coder-1.5B-Instruct` (Apache-2.0) | +| Rows | 48,196 | +| Method | LoRA r=16, α=32, all attention + MLP projections, 1 epoch, lr 2e-4 | +| Build scripts | `scripts/pybytecode/{extract_v2,build_final,build_v3,rep,gen,verify}.py` | +| Grader hashes | all six match `grader.sha256` in `data/models/models.jsonl` | +| Redistributable | **No** — §5 | diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..d645695673349e3947e8e5ae42332d0ac3164cd7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000000000000000000000000000000000000..ff24aaff75d71df4b705418b2f6a23c8058eec20 --- /dev/null +++ b/NOTICE @@ -0,0 +1,24 @@ +PyBytecode +Copyright 2026 Blazing Customs + +This product includes software developed from Qwen2.5-Coder-1.5B-Instruct +(https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct), Copyright Alibaba Cloud, +licensed under the Apache License, Version 2.0. + +The upstream repository ships a LICENSE file and no NOTICE file (checked 2026-08-04 against +the Hugging Face API), so there is no upstream NOTICE text to append here. + +CHANGES MADE TO THE LICENSED WORK, as required by Apache-2.0 section 4(b): + + The base model was fine-tuned with LoRA (rank 16, alpha 32, applied to q_proj, k_proj, + v_proj, o_proj, gate_proj, up_proj and down_proj; 1 epoch; learning rate 2e-4) on 48,196 + pairs of Python 3.12 bytecode disassembly and the source that produced it. The resulting + adapter was merged into the base weights. No architecture, vocabulary or tokenizer change + was made. + +The training corpus is not distributed. Its per-row attribution was not retained, so it cannot +be redistributed without stripping required notices from its upstream authors. See +DATA-CARD-training-corpus.md. This constrains the corpus only; it does not encumber these +weights, which are trained parameters rather than a copy of any source text, and which were +derived from a corpus pre-filtered to seven permissive licences with all GPL, LGPL, AGPL, MPL +and EPL rows dropped before extraction. diff --git a/ORACLE-LIMITS.md b/ORACLE-LIMITS.md new file mode 100644 index 0000000000000000000000000000000000000000..a7597ec34879678f601af5adada9016b1ad21ef8 --- /dev/null +++ b/ORACLE-LIMITS.md @@ -0,0 +1,133 @@ +# The oracle's real limits + +The verifier is the reason to use PyBytecode at all, so its limits belong in front of a user, not +in an appendix. Everything here is measured; sources are named per section. + +--- + +## 1. The pre-flight 100% proves almost nothing. Read this before quoting it. + +Every grading command prints `PRE-FLIGHT 600/600 = 100%` before it scores. **That number is +trivial by construction and is not evidence of soundness.** + +Pre-flight grades each reference label against itself. The oracle asks whether +`compile(prediction)` and `compile(reference)` produce the same code object — so at pre-flight it +is comparing `compile(x)` with `compile(x)`. It would return 100% for *any* deterministic +function of the source, including a stub that hashes the input string and ignores the bytecode +entirely. + +What pre-flight actually detects is a **broken harness**: a benchmark whose `.pyc` files do not +match their sources, a Python version mismatch (3.11 or 3.13 against a 3.12 benchmark), a corrupt +row. Those are real failure modes and worth catching, which is why it runs. But a passing +pre-flight says the instrument is plugged in, not that it measures anything. + +**Soundness evidence comes from the mutation test and the blind-spot probes, not from +pre-flight**: corrupt a label and require the oracle to reject it. Measured +(`evidence/ORACLE-MUTATION.md`): **0 true survivors in 1,239 mutants**, and +**18/18 targeted blind-spot probes** behave as required — including the historical failure where +a `try:` body and a `try/else:` body were indistinguishable, docstring changes, docstring +removal, float-vs-int, bool-vs-int and `-0.0` vs `0.0`. + +Even the mutation kill rate is weak evidence on its own: for a byte-identical oracle a kill is +close to tautological, since a mutant survives only if it compiles to a structurally identical +code object. The probes are the load-bearing test, because they ask the question that actually bit +us once — *is a behaviourally load-bearing field missing from the fingerprint?* + +**Caveat on mutation supply, stated rather than hidden:** 188 of 600 wild rows (31%) produced no +effective mutant within 30 tries, and 323 void attempts were discarded. The wild kill rate is +measured on the 412 rows that did produce one. + +## 2. The 0.33% wild false-reject floor + +Against `.pyc` files built by someone else, the oracle refuses a small fraction of correct +answers. Measured on 600 wild install-time `.pyc` from installed site-packages +(`evidence/GATE-RESULT.md`): + +| | certified | false reject | false accepts | +|---|---|---|---| +| L0 (old constant encoding) | 585/600 = 97.5% | 15 = 2.5% | 0 / 1,274 | +| **L1 (shipping)** | **598/600 = 99.67%** | **2 = 0.33%** | 0 / 1,274 | + +13 of the 15 L0 failures were our own defect — `repr()` of a `set`/`frozenset`/`dict` follows the +compiling process's hash seed, which also made the L0 verdict **non-deterministic** (585 / 592 / +584 / 585 / 589 under `PYTHONHASHSEED` 0–4). L1 fixes it and returns 598 under all five seeds. + +The remaining **0.33% is a real floor and is not fixable.** One distinct module +(`pandas/_testing/__init__.py`) compiles differently under CPython 3.12.3 than under 3.12.13 — +`co_code` 2,692 vs 2,696 bytes, and a differing `co_exceptiontable`. The source is correct; the +*compiler patch release* differs. No normalisation removes this without abandoning the +byte-identical guarantee. + +**It degrades to a false REJECT, never a false accept.** You are told "unknown" about a correct +answer; you are never told "verified" about a wrong one. That is the safe direction, and it is the +direction the design chose deliberately. + +## 3. Optimization level must match the producer's, or verification collapses + +A `.pyc` built with `-O` or `-OO` is a different code object. Measured on 679 sources compiled by +a foreign interpreter at each level and graded at each level: + +| producer ↓ / grader → | 0 | 1 | 2 | +|---|---|---|---| +| **0** | **100.0%** | 95.43% | 23.86% | +| **1** | 95.43% | **100.0%** | 24.15% | +| **2** | 23.86% | 24.15% | **100.0%** | + +The diagonal is 679/679 at every level. Guessing wrong is **not** a graceful degradation — it +collapses to ~24%. There are only three levels and trying all three costs three compiles, so this +is *"needs normalisation to survive"*, not *"breaks"*. **The harness does not currently search the +three levels automatically; a user verifying a foreign `.pyc` must do it.** + +**What trying all three costs you, and it is not nothing.** The certificate changes meaning from +*"byte-identical to the code object the original source compiles to"* to *"byte-identical to the +code object that was actually shipped"*. At `optimize>=1` docstrings are **absent from the `.pyc`**, +and at `>=2` asserts are gone too. So against an `-O` artifact, **docstring recovery cannot be +certified at all** — the information is not in the file. That bears directly on our headline +differentiator: 115 of 679 benchmark rows carry a real docstring, and none of that could be proven +against an `-O` `.pyc`. It is a limit of the artifact, not unsoundness in the oracle. + +## 4. What the oracle deliberately ignores + +Excluded from the fingerprint, with how often each would have caused a false reject on the 600 +wild rows had it been included: + +| Field | In fingerprint? | Rows differing / 600 | +|---|---|---| +| `co_filename` | excluded | **600 (100%)** — every wild `.pyc` carries its builder's absolute path | +| `co_linetable` | excluded | **122 (20.3%)** — varies across builds with no semantic content | +| `co_firstlineno` | excluded | 0 | + +Docstrings, `co_consts`, `co_names` and `co_exceptiontable` are **included** — the first because +docstring fidelity is a claim we make, the last because omitting it once produced a false proof. + +## 5. Unverified means unknown, not wrong + +The oracle is **sound but incomplete**: + +``` +verified = PROVABLY correct. Identical code object => identical behaviour. No false positives. +unverified = UNKNOWN. A correct decompilation that compiles differently — a `while` where the + original had a `for`, a differently-ordered but equivalent boolean — does not verify. +``` + +Reported accuracy is therefore a **lower bound on correctness**, not an estimate of it. Treating +the unverified remainder as errors understates the model; treating it as correct is unsafe. + +## 6. Not tested — unknown, not claimed + +- **Cross-minor (3.13).** No 3.13 interpreter on the measurement box; nothing was downloaded. + The benchmark and the model are 3.12 only. +- **PyInstaller / Nuitka containers.** `import PyInstaller` → `ModuleNotFoundError`. Not measured. +- **`.pyc` from non-CPython or patched builds.** Not measured. Given that a *patch release* + already produces the 0.33% floor, a patched build is a live risk, not a theoretical one. +- **Obfuscated or deliberately adversarial bytecode.** Not measured. No malware was fetched. + +## 7. Where these limits are stated to users + +| Limit | Stated in | +|---|---| +| Pre-flight is trivial | this file; `harness/README.md`; both benchmark data cards | +| 0.33% wild false-reject floor | this file; `weights/MODEL-CARD.md` | +| `-O` mismatch collapse, docstrings unprovable | this file; `weights/MODEL-CARD.md` | +| unverified ≠ wrong | this file; `weights/MODEL-CARD.md`; `harness/README.md` | +| 3.13 / PyInstaller untested | this file; `weights/MODEL-CARD.md` | diff --git a/benchmarks/csn-3.12-licensed/pyc/00008.pyc b/benchmarks/csn-3.12-licensed/pyc/00008.pyc new file mode 100644 index 0000000000000000000000000000000000000000..01158328939eda41d85e9fc0a71ae12c4e92d147 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00008.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00024.pyc b/benchmarks/csn-3.12-licensed/pyc/00024.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7b8bddd01ec5a52f6c6c0fb303684208a7d28084 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00024.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00026.pyc b/benchmarks/csn-3.12-licensed/pyc/00026.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6d7d7161c32d96e14d70c73c19c6a85a23201b97 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00026.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00033.pyc b/benchmarks/csn-3.12-licensed/pyc/00033.pyc new file mode 100644 index 0000000000000000000000000000000000000000..95baf8ee2c4575a2b77285643f143519a8f08afb Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00033.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00044.pyc b/benchmarks/csn-3.12-licensed/pyc/00044.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e42b76cc19366fd77e23c9873438a8278968025a Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00044.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00047.pyc b/benchmarks/csn-3.12-licensed/pyc/00047.pyc new file mode 100644 index 0000000000000000000000000000000000000000..97c47096a70ad1f8aad488dd53415fa47f7a3a31 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00047.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00054.pyc b/benchmarks/csn-3.12-licensed/pyc/00054.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ae1eedf38f6aba47dc502370d8057a734d7fc690 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00054.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00093.pyc b/benchmarks/csn-3.12-licensed/pyc/00093.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6b38335adda1b421cdf326a7b2c292f5bf2a8d32 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00093.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00105.pyc b/benchmarks/csn-3.12-licensed/pyc/00105.pyc new file mode 100644 index 0000000000000000000000000000000000000000..69f3d87d8dd7adf93b03dc6cebf428e65dc9b8f5 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00105.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00114.pyc b/benchmarks/csn-3.12-licensed/pyc/00114.pyc new file mode 100644 index 0000000000000000000000000000000000000000..78c8efff2c1d8fa1d5cb170ca7aa41674e7fc35d Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00114.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00119.pyc b/benchmarks/csn-3.12-licensed/pyc/00119.pyc new file mode 100644 index 0000000000000000000000000000000000000000..423f5789d2f885e5a3aed0afa11a39d811eb50dd Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00119.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00131.pyc b/benchmarks/csn-3.12-licensed/pyc/00131.pyc new file mode 100644 index 0000000000000000000000000000000000000000..407bdcc2cf044749a88ac71c8aedbde02b7a039a Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00131.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00133.pyc b/benchmarks/csn-3.12-licensed/pyc/00133.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7ec4399f6b7e15d16899856f4306f92ebbb98890 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00133.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00143.pyc b/benchmarks/csn-3.12-licensed/pyc/00143.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8b886b0c15b8265865821c9e82a7e2e27ff5e212 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00143.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00148.pyc b/benchmarks/csn-3.12-licensed/pyc/00148.pyc new file mode 100644 index 0000000000000000000000000000000000000000..051056ec81e9be42944198c967d3d166256a96b3 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00148.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00176.pyc b/benchmarks/csn-3.12-licensed/pyc/00176.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7fea632bf6e57d54ae8eec980e6e573f7e8eb409 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00176.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00238.pyc b/benchmarks/csn-3.12-licensed/pyc/00238.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0d03e94acda8bf74fadefe98eec8664d0c3983f7 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00238.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00239.pyc b/benchmarks/csn-3.12-licensed/pyc/00239.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3fd7c2305bb18a41f2b1b717faf65939d60f87dc Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00239.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00265.pyc b/benchmarks/csn-3.12-licensed/pyc/00265.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c79fb5fdd6c623abc1543223366ed3950924cab1 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00265.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00268.pyc b/benchmarks/csn-3.12-licensed/pyc/00268.pyc new file mode 100644 index 0000000000000000000000000000000000000000..194b2876efcd7ed751fff9107d00d26346c3cf90 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00268.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00278.pyc b/benchmarks/csn-3.12-licensed/pyc/00278.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d4a28f71b42d82fc10844504a78b66a5f1eb34c5 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00278.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00286.pyc b/benchmarks/csn-3.12-licensed/pyc/00286.pyc new file mode 100644 index 0000000000000000000000000000000000000000..359abbb0dc33d7156f1c39ca6a30b2366a40085c Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00286.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00303.pyc b/benchmarks/csn-3.12-licensed/pyc/00303.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b09af5a016abe1ef4d971ba70f06ec026774726b Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00303.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00304.pyc b/benchmarks/csn-3.12-licensed/pyc/00304.pyc new file mode 100644 index 0000000000000000000000000000000000000000..744ddbe1f9372469dab7015b948c235f4f88015f Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00304.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00317.pyc b/benchmarks/csn-3.12-licensed/pyc/00317.pyc new file mode 100644 index 0000000000000000000000000000000000000000..63dc7ecd65e23cc140d80ac8e99bd7be2b869453 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00317.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00320.pyc b/benchmarks/csn-3.12-licensed/pyc/00320.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9cdfdd1b7ac6425ec308cadab23765a0619fa54c Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00320.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00329.pyc b/benchmarks/csn-3.12-licensed/pyc/00329.pyc new file mode 100644 index 0000000000000000000000000000000000000000..71f56b25dc23bb2324f9c370384e1f762c8c6b4f Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00329.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00332.pyc b/benchmarks/csn-3.12-licensed/pyc/00332.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ef500b8e9d11dc34c4b8b279094139c35c0ddfa6 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00332.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00344.pyc b/benchmarks/csn-3.12-licensed/pyc/00344.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9329f6cfd3b80f341e7147be169e86ed504f5608 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00344.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00361.pyc b/benchmarks/csn-3.12-licensed/pyc/00361.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d8cceaeec9b9afee0bdb37cdf8f78d3d1220b50b Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00361.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00369.pyc b/benchmarks/csn-3.12-licensed/pyc/00369.pyc new file mode 100644 index 0000000000000000000000000000000000000000..87842a0a9b625ea4653e5add815b9802671c18b9 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00369.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00381.pyc b/benchmarks/csn-3.12-licensed/pyc/00381.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3fc3f304dff5a74b660a565f5541244903d0f81d Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00381.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00392.pyc b/benchmarks/csn-3.12-licensed/pyc/00392.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cda79499efad9a2b87db5ee5ea378980ac4d40ab Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00392.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00397.pyc b/benchmarks/csn-3.12-licensed/pyc/00397.pyc new file mode 100644 index 0000000000000000000000000000000000000000..98b2b3536dd0638b1c256c0e652ab8c9ab6c625a Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00397.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00402.pyc b/benchmarks/csn-3.12-licensed/pyc/00402.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3ff8518b13a3324fd1a9756ae2676b3151ebded8 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00402.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00413.pyc b/benchmarks/csn-3.12-licensed/pyc/00413.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2ce5973b462d011576c08aa818b4c90b5865c24e Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00413.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00421.pyc b/benchmarks/csn-3.12-licensed/pyc/00421.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d564d9694833d78d6acafa9f9aa90c5d05a03d4d Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00421.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00428.pyc b/benchmarks/csn-3.12-licensed/pyc/00428.pyc new file mode 100644 index 0000000000000000000000000000000000000000..79d92898ae688c6a1085cdaf1d9bd2271f223306 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00428.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00442.pyc b/benchmarks/csn-3.12-licensed/pyc/00442.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5fac25828be0c365ea8d77fd36f80ace3e987fd8 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00442.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00463.pyc b/benchmarks/csn-3.12-licensed/pyc/00463.pyc new file mode 100644 index 0000000000000000000000000000000000000000..082f186ae044f9120ef31dbe17a46e9cee984891 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00463.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00465.pyc b/benchmarks/csn-3.12-licensed/pyc/00465.pyc new file mode 100644 index 0000000000000000000000000000000000000000..60b957179bea85913e1761523c2ab2dd770c5637 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00465.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00471.pyc b/benchmarks/csn-3.12-licensed/pyc/00471.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e7107665d841be4f506a919c5e42799104c01c1b Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00471.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00488.pyc b/benchmarks/csn-3.12-licensed/pyc/00488.pyc new file mode 100644 index 0000000000000000000000000000000000000000..96994bcce74300716e45def1524831f0df03e3d5 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00488.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00498.pyc b/benchmarks/csn-3.12-licensed/pyc/00498.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8afee8c6c0678022cee6fee4382d63f2ea56b1a8 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00498.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00511.pyc b/benchmarks/csn-3.12-licensed/pyc/00511.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e75099d0f21a84576fc5b474f64b8766da735cac Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00511.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00528.pyc b/benchmarks/csn-3.12-licensed/pyc/00528.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e638362fc04aea443b597716a50b32bed4e16993 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00528.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00544.pyc b/benchmarks/csn-3.12-licensed/pyc/00544.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d4ed7e464bb870b47385c4dafc66c88a1743c8ac Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00544.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00554.pyc b/benchmarks/csn-3.12-licensed/pyc/00554.pyc new file mode 100644 index 0000000000000000000000000000000000000000..19deb34c6236451ebe02a402e0f95ac276b1c74f Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00554.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00562.pyc b/benchmarks/csn-3.12-licensed/pyc/00562.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cd4d608bd6d78e442144b2b5a1acf69834e2ec04 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00562.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00565.pyc b/benchmarks/csn-3.12-licensed/pyc/00565.pyc new file mode 100644 index 0000000000000000000000000000000000000000..95dc347315eb511427194f8f22f3949ecb8f68b9 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00565.pyc differ diff --git a/benchmarks/csn-3.12-licensed/pyc/00595.pyc b/benchmarks/csn-3.12-licensed/pyc/00595.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a0382de0aea6f08065b296c18449d90cc0d81d48 Binary files /dev/null and b/benchmarks/csn-3.12-licensed/pyc/00595.pyc differ diff --git a/chat_template.jinja b/chat_template.jinja new file mode 100644 index 0000000000000000000000000000000000000000..bdf7919a96cfe43d50914a007b9c0877bd0ec27e --- /dev/null +++ b/chat_template.jinja @@ -0,0 +1,54 @@ +{%- if tools %} + {{- '<|im_start|>system\n' }} + {%- if messages[0]['role'] == 'system' %} + {{- messages[0]['content'] }} + {%- else %} + {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }} + {%- endif %} + {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within XML tags:\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n\n\nFor each function call, return a json object with function name and arguments within XML tags:\n\n{\"name\": , \"arguments\": }\n<|im_end|>\n" }} +{%- else %} + {%- if messages[0]['role'] == 'system' %} + {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }} + {%- else %} + {{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- for message in messages %} + {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %} + {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {{- '<|im_start|>' + message.role }} + {%- if message.content %} + {{- '\n' + message.content }} + {%- endif %} + {%- for tool_call in message.tool_calls %} + {%- if tool_call.function is defined %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '\n\n{"name": "' }} + {{- tool_call.name }} + {{- '", "arguments": ' }} + {{- tool_call.arguments | tojson }} + {{- '}\n' }} + {%- endfor %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "tool" %} + {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {{- message.content }} + {{- '\n' }} + {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} +{%- endif %} diff --git a/config.json b/config.json new file mode 100644 index 0000000000000000000000000000000000000000..2e8bb79fbef49431e8da2c3afa3213d077f57fdd --- /dev/null +++ b/config.json @@ -0,0 +1,62 @@ +{ + "architectures": [ + "Qwen2ForCausalLM" + ], + "attention_dropout": 0.0, + "bos_token_id": 151643, + "dtype": "bfloat16", + "eos_token_id": 151645, + "hidden_act": "silu", + "hidden_size": 1536, + "initializer_range": 0.02, + "intermediate_size": 8960, + "layer_types": [ + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention" + ], + "max_position_embeddings": 32768, + "max_window_layers": 28, + "model_type": "qwen2", + "num_attention_heads": 12, + "num_hidden_layers": 28, + "num_key_value_heads": 2, + "pad_token_id": null, + "rms_norm_eps": 1e-06, + "rope_parameters": { + "rope_theta": 1000000.0, + "rope_type": "default" + }, + "sliding_window": null, + "tie_word_embeddings": true, + "transformers_version": "5.13.0", + "use_cache": true, + "use_sliding_window": false, + "vocab_size": 151936, + "torch_dtype": "bfloat16" +} diff --git a/generation_config.json b/generation_config.json new file mode 100644 index 0000000000000000000000000000000000000000..86c2d14c47073cc37a8d5f4485b06bc2b9803438 --- /dev/null +++ b/generation_config.json @@ -0,0 +1,14 @@ +{ + "bos_token_id": 151643, + "do_sample": true, + "eos_token_id": [ + 151645, + 151643 + ], + "pad_token_id": 151643, + "repetition_penalty": 1.1, + "temperature": 0.7, + "top_k": 20, + "top_p": 0.8, + "transformers_version": "5.13.0" +} diff --git a/generations/boN_v3_csn600.jsonl b/generations/boN_v3_csn600.jsonl new file mode 100644 index 0000000000000000000000000000000000000000..bd8ea2597deab44df2693e6eed6e07dcbb71f73d --- /dev/null +++ b/generations/boN_v3_csn600.jsonl @@ -0,0 +1,1425 @@ +{"i": 4, "s": 0, "got": "def __hi2lo_multiscale_indexes(self, mask, orig_shape):\n \"\"\"pass\"\"\"\n mask_orig = zoom_to_shape(mask, orig_shape, dtype=np.int8)\n inds_small = np.arange(mask.size).reshape(mask.shape)\n inds_small_in_orig = zoom_to_shape(inds_small, orig_shape, dtype=np.int8)\n inds_orig = np.arange(np.prod(orig_shape)).reshape(orig_shape)\n inds_orig += np.max(inds_small_in_orig) + 1\n inds_small_in_orig[mask_orig == True] = inds_orig[mask_orig == True]\n inds = inds_small_in_orig\n inds = relabel_squeeze(inds)\n logger.debug('Index after relabeling: %s', scipy.stats.describe(inds, axis=None))\n return (inds, mask_orig)"} +{"i": 5, "s": 0, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from .seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 1, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from ..seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 2, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 3, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 4, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from .seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 5, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 6, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from ..seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 7, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.interactivity_loop, voxelSize=self.voxelsize, seeds=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 8, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 9, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 10, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 11, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 12, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 13, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from .seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 14, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from .seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 15, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from .seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 16, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 17, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 18, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 19, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 20, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from .seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 21, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from .seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 22, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from .seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 23, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from .seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 24, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 25, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from .seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 26, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from .seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 27, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 28, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 29, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from .seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.interactivity_loop, voxelSize=self.voxelsize, seeds=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 5, "s": 30, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from .seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 15, "s": 0, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 1, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 2, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 3, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 4, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 5, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 6, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 7, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 8, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 9, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 10, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 11, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 12, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 13, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 14, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 15, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 16, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 17, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 18, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 19, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 20, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 21, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 22, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 23, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 24, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 25, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 26, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 27, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 28, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 29, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 15, "s": 30, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 25, "s": 0, "got": "def execute(self, payload, *args, flavour: ModuleType=None, **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n return self._meta_runner.run_payload(payload, flavour=flavour)"} +{"i": 25, "s": 1, "got": "def execute(self, payload, *args, flavour='flavour', **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n return self._meta_runner.run_payload(payload, flavour=flavour)"} +{"i": 25, "s": 2, "got": "def execute(self, payload: ModuleType, *args, flavour='flavour', **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n return self._meta_runner.run_payload(payload, flavour=flavour)"} +{"i": 25, "s": 3, "got": "def execute(self, payload: ModuleType, *args, flavour=None, **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n return self._meta_runner.run_payload(payload, flavour=flavour)"} +{"i": 25, "s": 4, "got": "def execute(self, payload, *args, flavour: ModuleType=None, **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n return self._meta_runner.run_payload(payload, flavour=flavour)"} +{"i": 25, "s": 5, "got": "def execute(self, payload: ModuleType, *args, flavour=None, **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n return self._meta_runner.run_payload(payload, flavour=flavour)"} +{"i": 25, "s": 6, "got": "def execute(self, payload, *args, flavour: ModuleType, **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n return self._meta_runner.run_payload(payload, flavour=flavour)"} +{"i": 26, "s": 0, "got": "def adopt(self, payload: ModuleType, *args, flavour='flavour', **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n self._meta_runner.register_payload(payload, flavour=flavour)"} +{"i": 26, "s": 1, "got": "def adopt(self, payload, *args, flavour='flavour', **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n self._meta_runner.register_payload(payload, flavour=flavour)"} +{"i": 26, "s": 2, "got": "def adopt(self, payload: ModuleType, *args, flavour=None, **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n self._meta_runner.register_payload(payload, flavour=flavour)"} +{"i": 26, "s": 3, "got": "def adopt(self, payload: ModuleType, *args, flavour='flavour', **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n self._meta_runner.register_payload(payload, flavour=flavour)"} +{"i": 26, "s": 4, "got": "def adopt(self, payload, *args, flavour: ModuleType=None, **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n self._meta_runner.register_payload(payload, flavour=flavour)"} +{"i": 26, "s": 5, "got": "def adopt(self, payload: ModuleType, *args, flavour='flavour', **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n self._meta_runner.register_payload(payload, flavour=flavour)"} +{"i": 26, "s": 6, "got": "def adopt(self, payload, *args, flavour: ModuleType, **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n self._meta_runner.register_payload(payload, flavour=flavour)"} +{"i": 35, "s": 0, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = (71.6 * zval / 10 ** 12 * cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1)) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0'])\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel"} +{"i": 35, "s": 1, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = (10 ** np.arange(1, 15, 0.2))\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'c'\n zarray = (10 ** np.arange(6, 14, 2))\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'zf'\n zarray = (10 ** np.arange(6, 14, 2))\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'dMdt'\n zarray = (10 ** np.arange(10, 14, 0.5))\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = (71.6 * zval / 10 ** 9) * cosmo['h'] / 0.7 * (-0.24 + 0.75 * (xarray + 1)) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0'])\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(10, 14, 0.5))\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'Mz'\n zarray = (10 ** np.arange(10, 14, 0.5))\n xtitle = 'Redshift'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_{0}$(M$_"} +{"i": 35, "s": 2, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(xarray / yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5) - 1\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, mah=True, com=False)\n yarray = output[yval].flatten()\n ax.plot(xarray / yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_specificMAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_specificMAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'Mz'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Redshift'\n ytitle = 'M(z) (M$_{sol}$)'\n linelabel = 'log$_{10}$ M$_{0}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=0, Mi=zval, z=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n ax.set_yscale('log')\n leg = ax.legend"} +{"i": 35, "s": 3, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9.0) * (cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0']))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n"} +{"i": 35, "s": 4, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9) * cosmo['h'] / 0.7 * (-0.24 + 0.75 * (xarray + 1))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'mMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax"} +{"i": 35, "s": 5, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(10, 14, 0.5)) - 1\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = (71.6 * zval / 1e9 * cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1)) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0'])\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(10, 14, 0.5)) - 1\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0"} +{"i": 35, "s": 6, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = (10 ** np.arange(1, 15, 0.2))\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = (71.6 * zval / 10 ** 9) * cosmo['h'] / 0.7 * (-0.24 + 0.75 * (xarray + 1) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0']))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(10, 14, 0.5)) - 1\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'm'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linel"} +{"i": 35, "s": 7, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9.0) * cosmo['h'] / 0.7 * (-0.24 + 0.75 * (xarray + 1))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'Mz'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Redshift'\n ytitle = 'M(z) (M$_{sol}$)'\n linelabel = 'log$_{10}$ M$_{0}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(11"} +{"i": 35, "s": 8, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(xarray / yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_specificMAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_specificMAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'Mz'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Redshift'\n ytitle = 'M(z) (M$_{sol}$)'\n linelabel = 'log$_{10}$ M$_{0}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n ax.set_yscale('log')\n leg = ax.legend(loc"} +{"i": 35, "s": 9, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = (71.6 * zval / 10 ** 10) * (cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0']))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Redshift'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n "} +{"i": 35, "s": 10, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), colors[zind])\n semianalytic_approx = 71.6 * zval / 10 ** 9 * (cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1)) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0'])\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'Mz'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Redshift'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'log$_{10}$ M"} +{"i": 35, "s": 11, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, mah=True, com=False)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray / xarray, label=linelabel + str(zval), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_specificMAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_specificMAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.02) - 1\n yval = 'Mz'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Redshift'\n ytitle = 'log$_{10}$ M(z)/M$_{0}$'\n linelabel = 'log$_{10}$ M$_{0}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, z=zval)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=3)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n"} +{"i": 35, "s": 12, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** (10 + 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * (zval / 1e9) * cosmo['h'] / 0.7 * (-0.24 + 0.75 * (xarray + 1)) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0'])\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** (10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig"} +{"i": 35, "s": 13, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9.0) * (cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1)) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0'])\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n"} +{"i": 35, "s": 14, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 10.5) * (cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0']))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n "} +{"i": 35, "s": 15, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(xarray / yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=True, mah=False)\n yarray = output[yval].flatten()\n ax.plot(xarray / yarray, xarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_specificMAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_specificMAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'Mz'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Redshift'\n ytitle = 'M(z) (M$_{sol}$)'\n linelabel = 'log$_{10}$ M$_{0}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=0, Mi=zval, z=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n ax.set_yscale('log')\n leg = ax.legend(loc"} +{"i": 35, "s": 16, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9) * (cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0']))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig"} +{"i": 35, "s": 17, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9) * (cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0']))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n lin"} +{"i": 35, "s": 18, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.02) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Redshift'\n ytitle = 'log$_{10}$ (1+z)'\n linelabel = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9) * (cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1) * (np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0'])))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.02) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.02) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n "} +{"i": 35, "s": 19, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, mah=True, com=False)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray / xarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_specificMAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_specificMAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'Mz'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Redshift'\n ytitle = 'M(z) (M$_{sol}$)'\n linelabel = 'log$_{10}$ M$_{0}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[z"} +{"i": 35, "s": 20, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Redshift'\n ytitle = 'Halo Mass M$_{sol}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = (71.6 * zval / 10 ** 9.0 * cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Redshift'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah"} +{"i": 35, "s": 21, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05) - 1)\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05) - 1)\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05) - 1)\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * (zval / 1e9) * cosmo['h'] / 0.7 * (-0.24 + 0.75 * (xarray + 1)) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0'])\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(10, 14, 0.5))\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05) - 1)\n yval = 'Mz'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Redshift'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'log$_{10}$ M"} +{"i": 35, "s": 22, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9.5) * cosmo['h'] / 0.7 * (-0.24 + 0.75 * (xarray + 1) + np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0']))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'mz'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n"} +{"i": 35, "s": 23, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** (10 + 4)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9.0) * (cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'mM'\n zarray = 10 ** (10 + 4)\n xtitle = 'Redshift'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1"} +{"i": 35, "s": 24, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'c'\n zarray = (10 ** np.arange(6, 14, 2))\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'zf'\n zarray = (10 ** np.arange(6, 14, 2))\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'dMdt'\n zarray = (10 ** np.arange(10, 14, 0.5))\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * zval / (10 ** 9) * cosmo['h'] / 0.7 * (-0.24 + 0.75 * (xarray + 1)) * np.sqrt(cosmo['omega_M_0'] * ((xarray + 1) ** 3) + cosmo['omega_lambda_0'])\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(10, 14, 0.5))\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = (10 ** np.arange(0, 1, 0.05)) - 1\n yval = 'dMdt'\n zarray = (10 ** np.arange(10, 14, 0.5))\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel"} +{"i": 35, "s": 25, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=True, mah=False)\n yarray = output[yval].flatten()\n ax.plot(xarray / yarray, xarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_specificMAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_specificMAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'Mz'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Redshift'\n ytitle = 'M(z) (M$_{sol}$)'\n linelabel = 'log$_{10}$ M$_{0}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, linelabel + '{0:.1f}'.format(np.log10(zval)), label=colors[zind])\n ax.set_yscale('log')\n leg = ax.legend(loc="} +{"i": 35, "s": 26, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9) * (cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0']))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig"} +{"i": 35, "s": 27, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9.0) * cosmo['h'] / 0.7 * (-0.24 + 0.75 * (xarray + 1) * 3 / (cosmo['omega_M_0'] * (xarray + 1) + cosmo['omega_lambda_0']))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot("} +{"i": 35, "s": 28, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9) * cosmo['h'] / 0.7 * (-0.24 + 0.75 * (xarray + 1)) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0'])\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n"} +{"i": 35, "s": 29, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9.0) * (cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1)) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0'])\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n"} +{"i": 35, "s": 30, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = (71.6 * zval / 10 ** 9.0 * (cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1) * cosmo[{'omega_M_0': xarray + 1} + {'omega_lambda_0': cosmo['omega_lambda_0']})) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0']))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'Mz'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Redshift'\n "} +{"i": 54, "s": 0, "got": "def _checkinput(zi, Mi, z, verbose=False):\n \"\"\"pass\"\"\"\n zi = np.array(zi, ndmin=1, dtype=float)\n Mi = np.array(Mi, ndmin=1, dtype=float)\n if zi.size > 1 and Mi.size > 1:\n if zi.size != Mi.size:\n print('Error ambiguous request')\n print('Need individual redshifts for all haloes provided ')\n print('Or have all haloes at same redshift ')\n return -1\n elif zi.size == 1 and Mi.size > 1:\n if verbose:\n print('Assume zi is the same for all Mi halo masses provided')\n zi = np.ones_like(Mi) * zi[0]\n elif Mi.size == 1 and zi.size > 1:\n if verbose:\n print('Assume Mi halo masses are the same for all zi provided')\n Mi = np.ones_like(zi) * Mi[0]\n elif verbose:\n print('A single Mi and zi provided')\n if z is False:\n lenzout = 1\n else:\n z = np.array(z, ndmin=1, dtype=float)\n lenzout = z.size\n return (zi, Mi, z, zi.size, Mi.size, lenzout)"} +{"i": 54, "s": 1, "got": "def _checkinput(zi, Mi, z=None, verbose=False):\n \"\"\"pass\"\"\"\n zi = np.array(zi, ndmin=1, dtype=float)\n Mi = np.array(Mi, ndmin=1, dtype=float)\n if zi.size > 1 and Mi.size > 1 and (zi.size != Mi.size):\n print('Error ambiguous request')\n print('Need individual redshifts for all haloes provided ')\n print('Or have all haloes at same redshift ')\n return -1\n elif zi.size == 1 and Mi.size > 1:\n if verbose:\n print('Assume zi is the same for all Mi halo masses provided')\n zi = np.ones_like(Mi) * zi[0]\n elif Mi.size == 1 and zi.size > 1:\n if verbose:\n print('Assume Mi halo masses are the same for all zi provided')\n Mi = np.ones_like(zi) * Mi[0]\n else:\n if verbose:\n print('A single Mi and zi provided')\n if z is False:\n lenzout = 1\n else:\n z = np.array(z, ndmin=1, dtype=float)\n lenzout = z.size\n return (zi, Mi, z, zi.size, Mi.size, lenzout)"} +{"i": 54, "s": 2, "got": "def _checkinput(zi, Mi, z, verbose=False):\n \"\"\"pass\"\"\"\n zi = np.array(zi, ndmin=1, dtype=float)\n Mi = np.array(Mi, ndmin=1, dtype=float)\n if zi.size > 1 and Mi.size > 1 and (zi.size != Mi.size):\n print('Error ambiguous request')\n print('Need individual redshifts for all haloes provided ')\n print('Or have all haloes at same redshift ')\n return -1\n elif zi.size == 1 and Mi.size > 1:\n if verbose:\n print('Assume zi is the same for all Mi halo masses provided')\n zi = np.ones_like(Mi) * zi[0]\n elif Mi.size == 1 and zi.size > 1:\n if verbose:\n print('Assume Mi halo masses are the same for all zi provided')\n Mi = np.ones_like(zi) * Mi[0]\n elif verbose:\n print('A single Mi and zi provided')\n if z is False:\n lenzout = 1\n else:\n z = np.array(z, ndmin=1, dtype=float)\n lenzout = z.size\n return (zi, Mi, z, zi.size, Mi.size, lenzout)"} +{"i": 54, "s": 3, "got": "def _checkinput(zi, Mi, z, verbose=False):\n \"\"\"pass\"\"\"\n zi = np.array(zi, ndmin=1, dtype=float)\n Mi = np.array(Mi, ndmin=1, dtype=float)\n if zi.size > 1 and Mi.size > 1:\n if zi.size != Mi.size:\n print('Error ambiguous request')\n print('Need individual redshifts for all haloes provided ')\n print('Or have all haloes at same redshift ')\n return -1\n elif zi.size == 1 and Mi.size > 1:\n if verbose:\n print('Assume zi is the same for all Mi halo masses provided')\n zi = np.ones_like(Mi) * zi[0]\n elif Mi.size == 1 and zi.size > 1:\n if verbose:\n print('Assume Mi halo masses are the same for all zi provided')\n Mi = np.ones_like(zi) * Mi[0]\n else:\n if verbose:\n print('A single Mi and zi provided')\n if z is False:\n lenzout = 1\n else:\n z = np.array(z, ndmin=1, dtype=float)\n lenzout = z.size\n return (zi, Mi, z, zi.size, Mi.size, lenzout)"} +{"i": 54, "s": 4, "got": "def _checkinput(zi, Mi, z=False, verbose=None):\n \"\"\"pass\"\"\"\n zi = np.array(zi, ndmin=1, dtype=float)\n Mi = np.array(Mi, ndmin=1, dtype=float)\n if zi.size > 1 and Mi.size > 1:\n if zi.size != Mi.size:\n print('Error ambiguous request')\n print('Need individual redshifts for all haloes provided ')\n print('Or have all haloes at same redshift ')\n return -1\n elif zi.size == 1 and Mi.size > 1:\n if verbose:\n print('Assume zi is the same for all Mi halo masses provided')\n zi = np.ones_like(Mi) * zi[0]\n elif Mi.size == 1 and zi.size > 1:\n if verbose:\n print('Assume Mi halo masses are the same for all zi provided')\n Mi = np.ones_like(zi) * Mi[0]\n elif verbose:\n print('A single Mi and zi provided')\n if z is False:\n lenzout = 1\n else:\n z = np.array(z, ndmin=1, dtype=float)\n lenzout = z.size\n return (zi, Mi, z, zi.size, Mi.size, lenzout)"} +{"i": 62, "s": 0, "got": "def get_related_targetApplication(vR, app_id, app_ver):\n \"\"\"pass\"\"\"\n targetApplication = vR.get('targetApplication')\n if not targetApplication:\n return None\n for tA in targetApplication:\n guid = tA.get('guid')\n if not guid or guid == app_id:\n continue\n if not app_ver:\n return tA\n if between(version_int(app_ver), '0', tA.get('maxVersion', '*')):\n return tA"} +{"i": 62, "s": 1, "got": "def get_related_targetApplication(vR, app_id, app_ver):\n \"\"\"pass\"\"\"\n targetApplication = vR.get('targetApplication')\n if not targetApplication:\n return\n for tA in targetApplication:\n guid = tA.get('guid')\n if guid and (not guid == app_id):\n continue\n if not app_ver:\n return tA\n else:\n if between(version_int(app_ver), '0', tA.get('maxVersion', '*')):\n return tA"} +{"i": 70, "s": 0, "got": "def _collect_classes(self, package_paths: Sequence[str], recurse_subpackages=True) -> Sequence[type]:\n \"\"\"pass\"\"\"\n import uqbar.apis\n classes = []\n initial_source_paths = set()\n for path in package_paths:\n try:\n module = importlib.import_module(path)\n if hasattr(module, '__path__'):\n initial_source_paths.update(getattr(module, '__path__'))\n else:\n initial_source_paths.add(module.__file__)\n except ModuleNotFoundError:\n path, _, class_name = path.rpartition('.')\n module = importlib.import_module(path)\n classes.append(getattr(module, class_name))\n for source_path in uqbar.apis.collect_source_paths(initial_source_paths, recurse_subpackages=recurse_subpackages):\n package_path = uqbar.apis.source_path_to_package_path(source_path)\n module = importlib.import_module(package_path)\n for name in dir(module):\n if not name.startswith('_') and isinstance(object_ := getattr(module, name), type) and (object_.__module__ == module.__name__):\n classes.append(object_)\n return sorted(classes, key=lambda x: (x.__module__, x.__name__))"} +{"i": 70, "s": 1, "got": "def _collect_classes(self, package_paths: Sequence[str], recurse_subpackages: bool=True):\n \"\"\"pass\"\"\"\n import uqbar.apis\n classes = []\n initial_source_paths = set()\n for path in package_paths:\n try:\n module = importlib.import_module(path)\n if hasattr(module, '__path__'):\n initial_source_paths.update(getattr(module, '__path__'))\n else:\n initial_source_paths.add(module.__file__)\n except ModuleNotFoundError:\n path, _, class_name = path.rpartition('.')\n module = importlib.import_module(path)\n classes.append(getattr(module, class_name))\n for source_path in uqbar.apis.collect_source_paths(initial_source_paths, recurse_subpackages=recurse_subpackages):\n package_path = uqbar.apis.source_path_to_package_path(source_path)\n module = importlib.import_module(package_path)\n for name in dir(module):\n if not name.startswith('_') and isinstance(getattr(module, name), type) and (object_.__module__ == module.__name__):\n classes.append(object_)\n return sorted(classes, key=lambda x: (x.__module__, x.__name__))"} +{"i": 70, "s": 2, "got": "def _collect_classes(self, package_paths: Sequence[str], recurse_subpackages=True) -> Sequence[type]:\n \"\"\"pass\"\"\"\n import uqbar.apis\n classes = []\n initial_source_paths = set()\n for path in package_paths:\n try:\n module = importlib.import_module(path)\n if hasattr(module, '__path__'):\n initial_source_paths.update(getattr(module, '__path__'))\n else:\n initial_source_paths.add(module.__file__)\n except ModuleNotFoundError:\n path, _, class_name = path.rpartition('.')\n module = importlib.import_module(path)\n classes.append(getattr(module, class_name))\n for source_path in uqbar.apis.collect_source_paths(initial_source_paths, recurse_subpackages=recurse_subpackages):\n package_path = uqbar.apis.source_path_to_package_path(source_path)\n module = importlib.import_module(package_path)\n for name in dir(module):\n if not name.startswith('_') and isinstance(getattr(module, name), type) and (object_.__module__ == module.__name__):\n classes.append(object_)\n return sorted(classes, key=lambda x: (x.__module__, x.__name__))"} +{"i": 70, "s": 3, "got": "def _collect_classes(self, package_paths: Sequence[str], recurse_subpackages=True) -> Sequence[type]:\n \"\"\"pass\"\"\"\n import uqbar.apis\n classes = []\n initial_source_paths = set()\n for path in package_paths:\n try:\n module = importlib.import_module(path)\n if hasattr(module, '__path__'):\n initial_source_paths.update(getattr(module, '__path__'))\n else:\n initial_source_paths.add(module.__file__)\n except ModuleNotFoundError:\n path, _, class_name = path.rpartition('.')\n module = importlib.import_module(path)\n classes.append(getattr(module, class_name))\n for source_path in uqbar.apis.collect_source_paths(initial_source_paths, recurse_subpackages=recurse_subpackages):\n package_path = uqbar.apis.source_path_to_package_path(source_path)\n module = importlib.import_module(package_path)\n for name in dir(module):\n if not name.startswith('_'):\n object_ = getattr(module, name)\n if isinstance(object_, type) and object_.__module__ == module.__name__:\n classes.append(object_)\n return sorted(classes, key=lambda x: (x.__module__, x.__name__))"} +{"i": 70, "s": 4, "got": "def _collect_classes(self, package_paths: Sequence[str], recurse_subpackages: bool=True) -> Sequence[type]:\n \"\"\"pass\"\"\"\n import uqbar.apis\n classes = []\n initial_source_paths = set()\n for path in package_paths:\n try:\n module = importlib.import_module(path)\n if hasattr(module, '__path__'):\n initial_source_paths.update(getattr(module, '__path__'))\n else:\n initial_source_paths.add(module.__file__)\n except ModuleNotFoundError:\n path, _, class_name = path.rpartition('.')\n module = importlib.import_module(path)\n classes.append(getattr(module, class_name))\n for source_path in uqbar.apis.collect_source_paths(initial_source_paths, recurse_subpackages=recurse_subpackages):\n package_path = uqbar.apis.source_path_to_package_path(source_path)\n module = importlib.import_module(package_path)\n for name in dir(module):\n if not name.startswith('_'):\n object_ = getattr(module, name)\n if isinstance(object_, type) and object_.__module__ == module.__name__:\n classes.append(object_)\n return sorted(classes, key=lambda x: (x.__module__, x.__name__))"} +{"i": 73, "s": 0, "got": "def relative_to(source_path: Union[str, pathlib.Path], target_path: Union[str, pathlib.Path]) -> pathlib.Path:\n \"\"\"pass\"\"\"\n source_path = pathlib.Path(source_path).absolute()\n if source_path.is_file():\n source_path = source_path.parent\n target_path = pathlib.Path(target_path).absolute()\n common_prefix = find_common_prefix([source_path, target_path])\n if not common_prefix:\n raise ValueError('No common prefix')\n source_path = source_path.relative_to(common_prefix)\n target_path = target_path.relative_to(common_prefix)\n result = pathlib.Path(*['..'] * len(source_path.parts))\n return result / target_path"} +{"i": 97, "s": 0, "got": "def print_user_sets(wordsets, print_terms):\n \"\"\"pass\"\"\"\n if not wordsets:\n print('No sets found')\n return\n else:\n print('Found sets: {}'.format(len(wordsets)))\n for wordset in wordsets:\n print(' {}'.format(wordset))\n if print_terms:\n for term in wordset.terms:\n print(' {}'.format(term))"} +{"i": 97, "s": 1, "got": "def print_user_sets(wordsets, print_terms):\n \"\"\"pass\"\"\"\n if not wordsets:\n print('No sets found')\n else:\n print('Found sets: {}'.format(len(wordsets)))\n for wordset in wordsets:\n print(' {}' . format(wordset))\n if print_terms:\n for term in wordset.terms:\n print(' {}'.format(term))"} +{"i": 99, "s": 0, "got": "def print_common_terms(common_terms):\n \"\"\"pass\"\"\"\n if not common_terms:\n print('No duplicates')\n return\n for set_pair in common_terms:\n set1, set2, terms = set_pair\n print('{} and {} have in common:'.format(set1, set2))\n for term in terms:\n print(' {}'.format(term))"} +{"i": 99, "s": 1, "got": "def print_common_terms(common_terms):\n \"\"\"pass\"\"\"\n if not common_terms:\n print('No duplicates')\n else:\n for set_pair in common_terms:\n set1, set2, terms = set_pair\n print('{} and {} have in common:'.format(set1, set2))\n for term in terms:\n print(' {}'.format(term))"} +{"i": 107, "s": 0, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 1, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n if len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 2, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True and ret or None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 3, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 4, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 5, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 6, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n if len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 7, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n continue\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 8, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 9, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 10, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 11, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 12, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 13, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 14, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 15, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 16, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 17, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 18, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 19, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 20, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True and ret or None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 21, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 22, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 23, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 24, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 25, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 26, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 27, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 28, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 29, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n continue\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 107, "s": 30, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 109, "s": 0, "got": "def __insert(self):\n \"\"\"pass\"\"\"\n if len(self.__buffer) > 0:\n statement = self.__table.insert()\n if self.__autoincrement:\n statement = statement.returning(getattr(self.__table.c, self.__autoincrement))\n statement = statement.values(self.__buffer)\n res = statement.execute()\n for id in res:\n row = self.__buffer.pop(0)\n yield WrittenRow(row, False, id)\n else:\n statement.execute(self.__buffer)\n for row in self.__buffer:\n yield WrittenRow(row, False, None)\n self.__buffer = []"} +{"i": 109, "s": 1, "got": "def __insert(self):\n \"\"\"pass\"\"\"\n if len(self.__buffer) > 0:\n statement = self.__table.insert()\n if self.__autoincrement:\n statement = statement.returning(getattr(self.__table.c, self.__autoincrement))\n statement = statement.values(self.__buffer)\n res = statement.execute()\n for id, in res:\n row = self.__buffer.pop(0)\n yield WrittenRow(row, False, id)\n else:\n statement.execute(self.__buffer)\n for row in self.__buffer:\n yield WrittenRow(row, False, None)\n self.__buffer = []"} +{"i": 119, "s": 0, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 600 * 1024 * 1000:\n chunk_size = int((mem_free - 1000 * 1000) * 4 / (n * N))\n elif mem_free > 400 * 1024 * 1000:\n chunk_size = int((mem_free - 700 * 1000) * 4 / (n * N))\n elif mem_free > 1400 * 1024 * 1000:\n chunk_size = int((mem_free - 200 * 1024) * 4 / (n * N))\n elif mem_free > 800 * 1024 * 1000:\n chunk_size = int((mem_free - 1400 * 1000) * 4 / (n * N))\n elif mem_free > 200 * 1024 * 1000:\n chunk_size = int((mem_free - 900 * 1000) * 4 / (n * N))\n elif mem_free > 1000 * 1024 * 1000:\n chunk_size = int((mem_free - 400 * 1000) * 4 / (n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 1, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60 * 10 ** 6:\n chunk_size = int((mem_free - 10 ** 6) * 1000 / (4 * n * N))\n elif mem_free > 4 * 10 ** 7:\n chunk_size = int((mem_free - 7 * 10 ** 6) * 1000 / (4 * n * N))\n elif mem_free > 14 * 10 ** 6:\n chunk_size = int((mem_free - 2 * 10 ** 6) * 1000 / (4 * n * N))\n elif mem_free > 8 * 10 ** 6:\n chunk_size = int((mem_free - 7 * 10 ** 6) * 1000 / (4 * n * N))\n elif mem_free > 2 * 10 ** 6:\n chunk_size = int((mem_free - 8 * 10 ** 6) * 1000 / (4 * n * N))\n elif mem_free > 10 * 10 ** 5:\n chunk_size = int((mem_free - 3 * 10 ** 5) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 2, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 600 * 10 ** 6:\n chunk_size = int((mem_free - 1000 * 1000) * 4 / (n * N))\n elif mem_free > 400 * 10 ** 6:\n chunk_size = int((mem_free - 700 * 1000) * 4 / (n * N))\n elif mem_free > 1400 * 10 ** 6:\n chunk_size = int((mem_free - 200 * 1000) * 4 / (n * N))\n elif mem_free > 800 * 10 ** 6:\n chunk_size = int((mem_free - 1400 * 1000) * 4 / (n * N))\n elif mem_free > 200 * 10 ** 6:\n chunk_size = int((mem_free - 900 * 1000) * 4 / (n * N))\n elif mem_free > 100 * 10 ** 6:\n chunk_size = int((mem_free - 400 * 1000) * 4 / (n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 3, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 600 * 1000 * 1000:\n chunk_size = int((mem_free - 1000 * 1000) * 4 / (n * N))\n elif mem_free > 400 * 1000 * 1000:\n chunk_size = int((mem_free - 700 * 1000) * 4 / (n * N))\n elif mem_free > 1400 * 1000 * 1000:\n chunk_size = int((mem_free - 200 * 1000) * 4 / (n * N))\n elif mem_free > 800 * 1000 * 1000:\n chunk_size = int((mem_free - 1400 * 1000) * 4 / (n * N))\n elif mem_free > 2000 * 1000 * 1000:\n chunk_size = int((mem_free - 900 * 1000) * 4 / (n * N))\n elif mem_free > 1000 * 1000 * 1000:\n chunk_size = int((mem_free - 400 * 1000) * 4 / (n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 4, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60 * 10000000:\n chunk_size = int((mem_free - 10000000) * 1000 / (4 * n * N))\n elif mem_free > 4 * 10000000:\n chunk_size = int((mem_free - 7000000) * 1000 / (4 * n * N))\n elif mem_free > 14 * 1000000:\n chunk_size = int((mem_free - 2000000) * 1000 / (4 * n * N))\n elif mem_free > 8 * 1000000:\n chunk_size = int((mem_free - 1400000) * 1000 / (4 * n * N))\n elif mem_free > 2 * 1000000:\n chunk_size = int((mem_free - 900000) * 1000 / (4 * n * N))\n elif mem_free > 1 * 1000000:\n chunk_size = int((mem_free - 400000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 5, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 600 * 1000000:\n chunk_size = int((mem_free - 10000000) * 1000 / (4 * n * N))\n return chunk_size\n elif mem_free > 400 * 1000000:\n chunk_size = int((mem_free - 700 * 1000) * 1000 / (4 * n * N))\n return chunk_size\n elif mem_free > 1400 * 1000:\n chunk_size = int((mem_free - 200 * 1000) * 1000 / (4 * n * N))\n return chunk_size\n elif mem_free > 800 * 1000:\n chunk_size = int((mem_free - 1400 * 1000) * 1000 / (4 * n * N))\n return chunk_size\n elif mem_free > 200 * 1000:\n chunk_size = int((mem_free - 900 * 1000) * 1000 / (4 * n * N))\n return chunk_size\n elif mem_free > 1000 * 1000:\n chunk_size = int((mem_free - 400 * 1000) * 1000 / (4 * n * N))\n return chunk_size\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return None"} +{"i": 119, "s": 6, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60 * 1000 * 10:\n chunk_size = int((mem_free - 1000 * 1000) / (4 * n * N))\n elif mem_free > 40 * 1000 * 10:\n chunk_size = int((mem_free - 7000000) * 1000 / (4 * n * N))\n elif mem_free > 14 * 1000 * 10:\n chunk_size = int((mem_free - 2000000) * 1000 / (4 * n * N))\n elif mem_free > 8 * 1000 * 10:\n chunk_size = int((mem_free - 1400000) * 1000 / (4 * n * N))\n elif mem_free > 2 * 1000 * 10:\n chunk_size = int((mem_free - 900000) * 1000 / (4 * n * N))\n elif mem_free > 1 * 1000 * 10:\n chunk_size = int((mem_free - 400000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 7, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 6000 * 1000:\n chunk_size = int((mem_free - 1000 * 1000) * 4 / (n * N))\n elif mem_free > 4000 * 1000:\n chunk_size = int((mem_free - 7000 * 1000) * 4 / (n * N))\n elif mem_free > 14000 * 1000:\n chunk_size = int((mem_free - 2000 * 1000) * 4 / (n * N))\n elif mem_free > 8000 * 1000:\n chunk_size = int((mem_free - 14000 * 1000) * 4 / (n * N))\n elif mem_free > 2000 * 1000:\n chunk_size = int((mem_free - 9000 * 1000) * 4 / (n * N))\n elif mem_free > 1000 * 1000:\n chunk_size = int((mem_free - 4000 * 1000) * 4 / (n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 8, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60000000:\n chunk_size = int((mem_free - 10000000) * 1000 / (4 * n * N))\n elif mem_free > 40000000:\n chunk_size = int((mem_free - 7000000) * 1000 / (4 * n * N))\n elif mem_free > 14000000:\n chunk_size = int((mem_free - 2000000) * 1000 / (4 * n * N))\n elif mem_free > 8000000:\n chunk_size = int((mem_free - 1400000) * 1000 / (4 * n * N))\n elif mem_free > 2000000:\n chunk_size = int((mem_free - 900000) * 1000 / (4 * n * N))\n elif mem_free > 1000000:\n chunk_size = int((mem_free - 400000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 9, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60000000:\n chunk_size = int((mem_free - 1000 * 1000) / (4 * n * N))\n elif mem_free > 40000000:\n chunk_size = int((mem_free - 7000 * 1000) / (4 * n * N))\n elif mem_free > 14000000:\n chunk_size = int((mem_free - 2000 * 1000) / (4 * n * N))\n elif mem_free > 8000000:\n chunk_size = int((mem_free - 14000 * 1000) / (4 * n * N))\n elif mem_free > 2000000:\n chunk_size = int((mem_free - 9000 * 1000) / (4 * n * N))\n elif mem_free > 1000000:\n chunk_size = int((mem_free - 400000) / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 10, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60000000:\n chunk_size = int((mem_free - 10000000) * 1000 / (4 * n * N))\n elif mem_free > 40000000:\n chunk_size = int((mem_free - 7000000) * 1000 / (4 * n * N))\n elif mem_free > 14000000:\n chunk_size = int((mem_free - 2000000) * 1000 / (4 * n * N))\n elif mem_free > 8000000:\n chunk_size = int((mem_free - 1400000) * 1000 / (4 * n * N))\n elif mem_free > 2000000:\n chunk_size = int((mem_free - 900000) * 1000 / (4 * n * N))\n elif mem_free > 1000000:\n chunk_size = int((mem_free - 400000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 11, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 600 * 1000000:\n chunk_size = int((mem_free - 100 * 1000) * 4 / (n * N))\n elif mem_free > 400 * 1000000:\n chunk_size = int((mem_free - 700 * 1000) * 4 / (n * N))\n elif mem_free > 1400 * 1000:\n chunk_size = int((mem_free - 2000 * 1000) * 4 / (n * N))\n elif mem_free > 800 * 1000000:\n chunk_size = int((mem_free - 1400 * 1000) * 4 / (n * N))\n elif mem_free > 2000 * 1000:\n chunk_size = int((mem_free - 9000 * 1000) * 4 / (n * N))\n elif mem_free > 1000 * 1000:\n chunk_size = int((mem_free - 4000 * 1000) * 4 / (n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 12, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 600 * 1000:\n chunk_size = int((mem_free - 1000 * 1000) * 4 / (n * N))\n elif mem_free > 4 * 1000 * 1000:\n chunk_size = int((mem_free - 7 * 1000 * 1000) * 4 / (n * N))\n elif mem_free > 13 * 1000 * 1000:\n chunk_size = int((mem_free - 2 * 1000 * 1000) * 4 / (n * N))\n elif mem_free > 8 * 1000 * 1000:\n chunk_size = int((mem_free - 3 * 1000 * 1000) * 4 / (n * N))\n elif mem_free > 2 * 1000 * 1000:\n chunk_size = int((mem_free - 1 * 1000 * 1000) * 4 / (n * N))\n elif mem_free > 1 * 1000 * 1000:\n chunk_size = int((mem_free - 1 * 1000 * 1000) * 4 / (n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 13, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 600 * 1024 * 1024:\n chunk_size = int((mem_free - 100 * 1024 * 1024) * 4 / (n * N))\n elif mem_free > 400 * 1024 * 1024:\n chunk_size = int((mem_free - 700 * 1024 * 1024) * 4 / (n * N))\n elif mem_free > 1400 * 1024 * 1024:\n chunk_size = int((mem_free - 200 * 1024 * 1024) * 4 / (n * N))\n elif mem_free > 800 * 1024 * 1024:\n chunk_size = int((mem_free - 1400 * 1024 * 1024) * 4 / (n * N))\n elif mem_free > 200 * 1024 * 1024:\n chunk_size = int((mem_free - 900 * 1024 * 1024) * 4 / (n * N))\n elif mem_free > 100 * 1024 * 1024:\n chunk_size = int((mem_free - 400 * 1024 * 1024) * 4 / (n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 14, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60 * 1024 * 1024:\n chunk_size = int((mem_free - 1000 * 1000) * 4 / (n * N))\n elif mem_free > 40 * 1024 * 1024:\n chunk_size = int((mem_free - 70 * 1024) * 4 / (n * N))\n elif mem_free > 14 * 1024 * 1024:\n chunk_size = int((mem_free - 20 * 1024) * 4 / (n * N))\n elif mem_free > 8 * 1024 * 1024:\n chunk_size = int((mem_free - 14 * 1024) * 4 / (n * N))\n elif mem_free > 2 * 1024 * 1024:\n chunk_size = int((mem_free - 9 * 1024) * 4 / (n * N))\n elif mem_free > 10 * 1024 * 1024:\n chunk_size = int((mem_free - 4 * 1024) * 4 / (n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 15, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60 * 1024 * 1024:\n chunk_size = int((mem_free - 10 * 1024 * 1024) * 1024 / (4 * n * N))\n elif mem_free > 4 * 1024 * 1024:\n chunk_size = int((mem_free - 7 * 1024 * 1024) * 1024 / (4 * n * N))\n elif mem_free > 14 * 1024 * 1024:\n chunk_size = int((mem_free - 2 * 1024 * 1024) * 1024 / (4 * n * N))\n elif mem_free > 8 * 1024 * 1024:\n chunk_size = int((mem_free - 14 * 1024 * 1024) * 1024 / (4 * n * N))\n elif mem_free > 2 * 1024 * 1024:\n chunk_size = int((mem_free - 9 * 1024 * 1024) * 1024 / (4 * n * N))\n elif mem_free > 10 * 1024 * 1024:\n chunk_size = int((mem_free - 4 * 1024 * 1024) * 1024 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 16, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60000000:\n chunk_size = int((mem_free - 10000000) * 1000 / (4 * n * N))\n elif mem_free > 40000000:\n chunk_size = int((mem_free - 7000000) * 1000 / (4 * n * N))\n elif mem_free > 14000000:\n chunk_size = int((mem_free - 2000000) * 1000 / (4 * n * N))\n elif mem_free > 8000000:\n chunk_size = int((mem_free - 1400000) * 1000 / (4 * n * N))\n elif mem_free > 2000000:\n chunk_size = int((mem_free - 900000) * 1000 / (4 * n * N))\n elif mem_free > 1000000:\n chunk_size = int((mem_free - 400000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 17, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 600 * 1024 * 1000:\n chunk_size = int((mem_free - 1000 * 1000) * 1000 / (4 * n * N))\n elif mem_free > 400 * 1024 * 1000:\n chunk_size = int((mem_free - 700 * 1000) * 1000 / (4 * n * N))\n elif mem_free > 1400 * 1024 * 1000:\n chunk_size = int((mem_free - 2000 * 1000) * 1000 / (4 * n * N))\n elif mem_free > 800 * 1024 * 1000:\n chunk_size = int((mem_free - 1400 * 1000) * 1000 / (4 * n * N))\n elif mem_free > 200 * 1024 * 1000:\n chunk_size = int((mem_free - 900 * 1000) * 1000 / (4 * n * N))\n elif mem_free > 1000 * 1024 * 1000:\n chunk_size = int((mem_free - 400 * 1000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 18, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60000000:\n chunk_size = int((mem_free - 10000000) * 1000 / (4 * n * N))\n elif mem_free > 40000000:\n chunk_size = int((mem_free - 7000000) * 1000 / (4 * n * N))\n elif mem_free > 14000000:\n chunk_size = int((mem_free - 2000000) * 1000 / (4 * n * N))\n elif mem_free > 8000000:\n chunk_size = int((mem_free - 1400000) * 1000 / (4 * n * N))\n elif mem_free > 2000000:\n chunk_size = int((mem_free - 900000) * 1000 / (4 * n * N))\n elif mem_free > 1000000:\n chunk_size = int((mem_free - 400000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 19, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60000000:\n chunk_size = int((mem_free - 10000000) * 1000 / (4 * n * N))\n elif mem_free > 40000000:\n chunk_size = int((mem_free - 7000000) * 1000 / (4 * n * N))\n elif mem_free > 14000000:\n chunk_size = int((mem_free - 2000000) * 1000 / (4 * n * N))\n elif mem_free > 8000000:\n chunk_size = int((mem_free - 1400000) * 1000 / (4 * n * N))\n elif mem_free > 2000000:\n chunk_size = int((mem_free - 900000) * 1000 / (4 * n * N))\n elif mem_free > 1000000:\n chunk_size = int((mem_free - 400000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 20, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60 * 10 ** 7:\n chunk_size = int((mem_free - 10 * 10 ** 5) * 1000 / (4 * n * N))\n elif mem_free > 4 * 10 ** 6:\n chunk_size = int((mem_free - 7 * 10 ** 5) * 1000 / (4 * n * N))\n elif mem_free > 13 * 10 ** 6:\n chunk_size = int((mem_free - 2 * 10 ** 6) * 1000 / (4 * n * N))\n elif mem_free > 8 * 10 ** 6:\n chunk_size = int((mem_free - 13 * 10 ** 5) * 1000 / (4 * n * N))\n elif mem_free > 2 * 10 ** 6:\n chunk_size = int((mem_free - 9 * 10 ** 5) * 1000 / (4 * n * N))\n elif mem_free > 1 * 10 ** 6:\n chunk_size = int((mem_free - 3 * 10 ** 5) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 21, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60 * 1024 * 1024:\n chunk_size = int((mem_free - 10 * 1024 * 1024) * 1000 / (4 * n * N))\n elif mem_free > 40 * 1024 * 1024:\n chunk_size = int((mem_free - 7 * 1024 * 1024) * 1000 / (4 * n * N))\n elif mem_free > 14 * 1024 * 1024:\n chunk_size = int((mem_free - 2 * 1024 * 1024) * 1000 / (4 * n * N))\n elif mem_free > 8 * 1024 * 1024:\n chunk_size = int((mem_free - 13 * 1024 * 1024) * 1000 / (4 * n * N))\n elif mem_free > 2 * 1024 * 1024:\n chunk_size = int((mem_free - 8 * 1024 * 1024) * 1000 / (4 * n * N))\n elif mem_free > 1 * 1024 * 1024:\n chunk_size = int((mem_free - 7 * 1024 * 1024) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 22, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60 * 1024 * 1000:\n chunk_size = int((mem_free - 10 * 1024 * 1000) * 1000 / (4 * n * N))\n elif mem_free > 40 * 1024 * 1000:\n chunk_size = int((mem_free - 7 * 1024 * 1000) * 1000 / (4 * n * N))\n elif mem_free > 14 * 1024 * 1000:\n chunk_size = int((mem_free - 2 * 1024 * 1000) * 1000 / (4 * n * N))\n elif mem_free > 8 * 1024 * 1000:\n chunk_size = int((mem_free - 7 * 1024 * 1000) * 1000 / (4 * n * N))\n elif mem_free > 2 * 1024 * 1000:\n chunk_size = int((mem_free - 9 * 1024 * 1000) * 1000 / (4 * n * N))\n elif mem_free > 1 * 1024 * 1000:\n chunk_size = int((mem_free - 4 * 1024 * 1000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 23, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60 * 1000000:\n chunk_size = int((mem_free - 10000000) * 1000 / (4 * n * N))\n elif mem_free > 40 * 1000000:\n chunk_size = int((mem_free - 70 * 1000000) * 1000 / (4 * n * N))\n elif mem_free > 14 * 1000000:\n chunk_size = int((mem_free - 2 * 1000000) * 1000 / (4 * n * N))\n elif mem_free > 8 * 1000000:\n chunk_size = int((mem_free - 14 * 1000000) * 1000 / (4 * n * N))\n elif mem_free > 2 * 1000000:\n chunk_size = int((mem_free - 9 * 1000000) * 1000 / (4 * n * N))\n elif mem_free > 1 * 1000000:\n chunk_size = int((mem_free - 4 * 1000000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 24, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60000 * 1000:\n chunk_size = int((mem_free - 10000000) * 1000 / (4 * n * N))\n elif mem_free > 40000 * 1000:\n chunk_size = int((mem_free - 7000000) * 1000 / (4 * n * N))\n elif mem_free > 14000 * 1000:\n chunk_size = int((mem_free - 2000000) * 1000 / (4 * n * N))\n elif mem_free > 8000 * 1000:\n chunk_size = int((mem_free - 1400000) * 1000 / (4 * n * N))\n elif mem_free > 2000 * 1000:\n chunk_size = int((mem_free - 900000) * 1000 / (4 * n * N))\n elif mem_free > 1000 * 1000:\n chunk_size = int((mem_free - 400000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 25, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60 * 1000 * 1000:\n chunk_size = int((mem_free - 1000 * 1000) * 4 * n * N)\n elif mem_free > 40 * 1000 * 1000:\n chunk_size = int((mem_free - 7000 * 1000) * 4 * n * N)\n elif mem_free > 14 * 1000 * 1000:\n chunk_size = int((mem_free - 20 * 1000 * 1000) * 4 * n * N)\n elif mem_free > 8 * 1000 * 1000:\n chunk_size = int((mem_free - 14 * 1000 * 1000) * 4 * n * N)\n elif mem_free > 2 * 1000 * 1000:\n chunk_size = int((mem_free - 9000 * 1000) * 4 * n * N)\n elif mem_free > 1 * 1000 * 1000:\n chunk_size = int((mem_free - 4000 * 1000) * 4 * n * N)\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 26, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60 * 1000 * 1000:\n chunk_size = int((mem_free - 1000 * 1000) * 4 / (n * N))\n elif mem_free > 40 * 1000 * 1000:\n chunk_size = int((mem_free - 700 * 1000) * 4 / (n * N))\n elif mem_free > 14 * 1000 * 1000:\n chunk_size = int((mem_free - 200 * 1000) * 4 / (n * N))\n elif mem_free > 8 * 1000 * 1000:\n chunk_size = int((mem_free - 140 * 1000) * 4 / (n * N))\n elif mem_free > 2 * 1000 * 1000:\n chunk_size = int((mem_free - 900 * 1000) * 4 / (n * N))\n elif mem_free > 1 * 1000 * 1000:\n chunk_size = int((mem_free - 400 * 1000) * 4 / (n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 27, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 600 * 1000 * 10:\n chunk_size = int((mem_free - 1000 * 1000) * 4 / (n * N))\n elif mem_free > 400 * 1000 * 10:\n chunk_size = int((mem_free - 700 * 1000) * 4 / (n * N))\n elif mem_free > 1400 * 1000 * 10:\n chunk_size = int((mem_free - 200 * 1000) * 4 / (n * N))\n elif mem_free > 800 * 1000 * 10:\n chunk_size = int((mem_free - 1400 * 1000) * 4 / (n * N))\n elif mem_free > 200 * 1000 * 10:\n chunk_size = int((mem_free - 900 * 1000) * 4 / (n * N))\n elif mem_free > 1000 * 1000 * 10:\n chunk_size = int((mem_free - 400 * 1000) * 4 / (n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 28, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60000000:\n chunk_size = int((mem_free - 10000000) * 1000 / (4 * n * N))\n elif mem_free > 40000000:\n chunk_size = int((mem_free - 7000000) * 1000 / (4 * n * N))\n elif mem_free > 14000000:\n chunk_size = int((mem_free - 2000000) * 1000 / (4 * n * N))\n elif mem_free > 8000000:\n chunk_size = int((mem_free - 1400000) * 1000 / (4 * n * N))\n elif mem_free > 2000000:\n chunk_size = int((mem_free - 900000) * 1000 / (4 * n * N))\n elif mem_free > 1000000:\n chunk_size = int((mem_free - 400000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 29, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60 * 1000:\n chunk_size = int((mem_free - 10000000) * 1000 / (4 * n * N))\n elif mem_free > 4 * 1000 * 500:\n chunk_size = int((mem_free - 7000000) * 1000 / (4 * n * N))\n elif mem_free > 12 * 1000 * 300:\n chunk_size = int((mem_free - 2000000) * 1000 / (4 * n * N))\n elif mem_free > 8 * 1000 * 200:\n chunk_size = int((mem_free - 1400000) * 1000 / (4 * n * N))\n elif mem_free > 3 * 1000 * 100:\n chunk_size = int((mem_free - 2000000) * 1000 / (4 * n * N))\n elif mem_free > 2 * 1000 * 50:\n chunk_size = int((mem_free - 1000000) * 1000 / (4 * n * N))\n elif mem_free > 1 * 1000 * 25:\n chunk_size = int((mem_free - 400000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 119, "s": 30, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60 * 1000 * 1000:\n chunk_size = int((mem_free - 100 * 1000) * 4 / (n * N))\n elif mem_free > 40 * 1000 * 1000:\n chunk_size = int((mem_free - 7 * 1000) * 4 / (n * N))\n elif mem_free > 14 * 1000 * 1000:\n chunk_size = int((mem_free - 2 * 1000) * 4 / (n * N))\n elif mem_free > 8 * 1000 * 1000:\n chunk_size = int((mem_free - 13 * 1000) * 4 / (n * N))\n elif mem_free > 2 * 1000 * 1000:\n chunk_size = int((mem_free - 8 * 1000) * 4 / (n * N))\n elif mem_free > 1 * 1000 * 1000:\n chunk_size = int((mem_free - 3 * 1000) * 4 / (n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 124, "s": 0, "got": "def obfuscate(p, action):\n \"\"\"pass\"\"\"\n key = 'ru7sll3uQrGtDPcIW3okutpFLo6YYtd5bWSpbZJIopYQ0Du0a1WlhvJOaZEH'\n s = list()\n if action == 'store':\n if PY2:\n for i in range(len(p)):\n kc = key[i % len(key)]\n ec = chr((ord(p[i]) + ord(kc)) % 256)\n s.append(ec)\n else:\n return base64.urlsafe_b64encode(p.encode()).decode()\n elif PY2:\n e = base64.urlsafe_b64decode(p)\n for i in range(len(e)):\n kc = key[i % len(key)]\n dc = chr((256 + ord(e[i]) - ord(kc)) % 256)\n s.append(dc)\n else:\n e = base64.urlsafe_b64decode(p)\n return e.decode()\n return ''.join(s)"} +{"i": 124, "s": 1, "got": "def obfuscate(p, action):\n \"\"\"pass\"\"\"\n key = 'ru7sll3uQrGtDPcIW3okutpFLo6YYtd5bWSpbZJIopYQ0Du0a1WlhvJOaZEH'\n s = list()\n if action == 'store':\n if PY2:\n for i in range(len(p)):\n kc = key[i % len(key)]\n ec = chr((ord(p[i]) + ord(kc) % 256))\n s.append(ec)\n return base64.urlsafe_b64encode(''.join(s))\n else:\n return base64.urlsafe_b64encode(p.encode()).decode()\n if PY2:\n e = base64.urlsafe_b64decode(p)\n for i in range(len(e)):\n kc = key[i % len(key)]\n dc = chr((256 + ord(e[i]) - ord(kc)) % 256)\n s.append(dc)\n return ''.join(s)\n e = base64.urlsafe_b64decode(p)\n return e.decode()"} +{"i": 124, "s": 2, "got": "def obfuscate(p, action):\n \"\"\"pass\"\"\"\n key = 'ru7sll3uQrGtDPcIW3okutpFLo6YYtd5bWSpbZJIopYQ0Du0a1WlhvJOaZEH'\n s = list()\n if action == 'store':\n if PY2:\n for i in range(len(p)):\n kc = key[i % len(key)]\n ec = chr((ord(p[i]) + ord(kc)) % 256)\n s.append(ec)\n return base64.urlsafe_b64encode(''.join(s))\n else:\n return base64.urlsafe_b64encode(p.encode()).decode()\n elif PY2:\n e = base64.urlsafe_b64decode(p)\n for i in range(len(e)):\n kc = key[i % len(key)]\n dc = chr((256 + ord(e[i]) - ord(kc)) % 256)\n s.append(dc)\n return ''.join(s)\n else:\n e = base64.urlsafe_b64decode(p)\n return e.decode()"} +{"i": 144, "s": 0, "got": "def contourf_to_geojson(contourf, geojson_filepath=None, min_angle_deg=None, ndigits=5, unit='', stroke_width=1, fill_opacity=0.9, geojson_properties=None, strdump=False, serialize=True):\n \"\"\"pass\"\"\"\n polygon_features = []\n mps = []\n contourf_idx = 0\n for coll in contourf.collections:\n color = coll.get_facecolor()\n for path in coll.get_paths():\n for coord in path.to_polygons():\n if min_angle_deg:\n coord = keep_high_angle(coord, min_angle_deg)\n coord = np.around(coord, ndigits) if ndigits else coord\n op = MP(contourf.levels[conturf_idx], rgb2hex(color[0]))\n if op in mps:\n for i, k in enumerate(mps):\n if k == op:\n mps[i].add_coords(coord.tolist())\n else:\n op.add_coords(coord.tolist())\n mps.append(op)\n contourf_idx += 1\n contourf_idx = 0\n for muli in mps:\n polygon = muli.mpoly()\n fcolor = muli.color\n properties = set_contourf_properties(stroke_width, fcolor, fill_opacity, contourf.levels, contourf_idx, unit)\n if geojson_properties:\n properties.update(geojson_properties)\n feature = Feature(geometry=polygon, properties=properties)\n polygon_features.append(feature)\n contourf_idx += 1\n feature_collection = FeatureCollection(polygon_features)\n return _render_feature_collection(feature_collection, geojson_filepath, strdump, serialize)"} +{"i": 144, "s": 1, "got": "def contourf_to_geojson(contourf, geojson_filepath, min_angle_deg=None, ndigits=None, unit=5, stroke_width=1, fill_opacity=0.9, geojson_properties=None, strdump=False, serialize=True):\n \"\"\"pass\"\"\"\n polygon_features = []\n mps = []\n contourf_idx = 0\n for coll in contourf.collections:\n color = coll.get_facecolor()\n for path in coll.get_paths():\n for coord in path.to_polygons():\n if min_angle_deg:\n coord = keep_high_angle(coord, min_angle_deg)\n coord = np.around(coord, ndigits) if ndigits else coord\n op = MP(contourf.levels[conturf_idx], rgb2hex(color[0]))\n if op in mps:\n for i, k in enumerate(mps):\n if k == op:\n mps[i].add_coords(coord.tolist())\n else:\n op.add_coords(coord.tolist())\n mps.append(op)\n contourf_idx += 1\n contourf_idx = 0\n for muli in mps:\n polygon = muli.mpoly()\n fcolor = muli.color\n properties = set_contourf_properties(stroke_width, fcolor, fill_opacity, contourf.levels, contourf_idx, unit)\n if geojson_properties:\n properties.update(geojson_properties)\n feature = Feature(geometry=polygon, properties=properties)\n polygon_features.append(feature)\n contourf_idx += 1\n feature_collection = FeatureCollection(polygon_features)\n return _render_feature_collection(feature_collection, geojson_filepath, strdump, serialize)"} +{"i": 144, "s": 2, "got": "def contourf_to_geojson(contourf, geojson_filepath=None, min_angle_deg=None, ndigits=5, unit='', stroke_width=1, fill_opacity=0.9, geojson_properties=None, strdump=False, serialize=True):\n \"\"\"pass\"\"\"\n polygon_features = []\n mps = []\n contourf_idx = 0\n for coll in contourf.collections:\n color = coll.get_facecolor()\n for path in coll.get_paths():\n for coord in path.to_polygons():\n if min_angle_deg:\n coord = keep_high_angle(coord, min_angle_deg)\n coord = np.around(coord, ndigits) if ndigits else coord\n op = MP(contourf.levels[conturf_idx], rgb2hex(color[0]))\n if op in mps:\n for i, k in enumerate(mps):\n if k == op:\n mps[i].add_coords(coord.tolist())\n else:\n op.add_coords(coord.tolist())\n mps.append(op)\n contourf_idx += 1\n contourf_idx = 0\n for muli in mps:\n polygon = muli.mpoly()\n fcolor = muli.color\n properties = set_contourf_properties(stroke_width, fcolor, fill_opacity, contourf.levels, contourf_idx, unit)\n if geojson_properties:\n properties.update(geojson_properties)\n feature = Feature(geometry=polygon, properties=properties)\n polygon_features.append(feature)\n contourf_idx += 1\n feature_collection = FeatureCollection(polygon_features)\n return _render_feature_collection(feature_collection, geojson_filepath, strdump, serialize)"} +{"i": 144, "s": 3, "got": "def contourf_to_geojson(contourf, geojson_filepath=None, min_angle_deg=None, ndigits=5, unit='', stroke_width=1, fill_opacity=0.9, geojson_properties=None, strdump=False, serialize=True):\n \"\"\"pass\"\"\"\n polygon_features = []\n mps = []\n contourf_idx = 0\n for coll in contourf.collections:\n color = coll.get_facecolor()\n for path in coll.get_paths():\n for coord in path.to_polygons():\n if min_angle_deg:\n coord = keep_high_angle(coord, min_angle_deg)\n coord = np.around(coord, ndigits) if ndigits else coord\n op = MP(contourf.levels[conturf_idx], rgb2hex(color[0]))\n if op in mps:\n for i, k in enumerate(mps):\n if k == op:\n mps[i].add_coords(coord.tolist())\n else:\n op.add_coords(coord.tolist())\n mps.append(op)\n contourf_idx += 1\n contourf_idx = 0\n for muli in mps:\n polygon = muli.mpoly()\n fcolor = muli.color\n properties = set_contourf_properties(stroke_width, fcolor, fill_opacity, contourf.levels, contourf_idx, unit)\n if geojson_properties:\n properties.update(geojson_properties)\n feature = Feature(geometry=polygon, properties=properties)\n polygon_features.append(feature)\n contourf_idx += 1\n feature_collection = FeatureCollection(polygon_features)\n return _render_feature_collection(feature_collection, geojson_filepath, strdump, serialize)"} +{"i": 144, "s": 4, "got": "def contourf_to_geojson(contourf, geojson_filepath, min_angle_deg=None, ndigits=None, unit='5', stroke_width=1, fill_opacity=0.9, geojson_properties=None, strdump=False, serialize=True):\n \"\"\"pass\"\"\"\n polygon_features = []\n mps = []\n contourf_idx = 0\n for coll in contourf.collections:\n color = coll.get_facecolor()\n for path in coll.get_paths():\n for coord in path.to_polygons():\n if min_angle_deg:\n coord = keep_high_angle(coord, min_angle_deg)\n coord = np.around(coord, ndigits) if ndigits else coord\n op = MP(contourf.levels[conturf_idx], rgb2hex(color[0]))\n if op in mps:\n for i, k in enumerate(mps):\n if k == op:\n mps[i].add_coords(coord.tolist())\n else:\n op.add_coords(coord.tolist())\n mps.append(op)\n contourf_idx += 1\n contourf_idx = 0\n for muli in mps:\n polygon = muli.mpoly()\n fcolor = muli.color\n properties = set_contourf_properties(stroke_width, fcolor, fill_opacity, contourf.levels, contourf_idx, unit)\n if geojson_properties:\n properties.update(geojson_properties)\n feature = Feature(geometry=polygon, properties=properties)\n polygon_features.append(feature)\n contourf_idx += 1\n feature_collection = FeatureCollection(polygon_features)\n return _render_feature_collection(feature_collection, geojson_filepath, strdump, serialize)"} +{"i": 144, "s": 5, "got": "def contourf_to_geojson(contourf, geojson_filepath=None, min_angle_deg=None, ndigits=5, unit='', stroke_width=1, fill_opacity=0.9, geojson_properties=None, strdump=False, serialize=True):\n \"\"\"pass\"\"\"\n polygon_features = []\n mps = []\n contourf_idx = 0\n for coll in contourf.collections:\n color = coll.get_facecolor()\n for path in coll.get_paths():\n for coord in path.to_polygons():\n if min_angle_deg:\n coord = keep_high_angle(coord, min_angle_deg)\n coord = np.around(coord, ndigits) if ndigits else coord\n op = MP(contourf.levels[contourf_idx], rgb2hex(color[0]))\n if op in mps:\n for i, k in enumerate(mps):\n if k == op:\n mps[i].add_coords(coord.tolist())\n else:\n op.add_coords(coord.tolist())\n mps.append(op)\n contourf_idx += 1\n contourf_idx = 0\n for muli in mps:\n polygon = muli.mpoly()\n fcolor = muli.color\n properties = set_contourf_properties(stroke_width, fcolor, fill_opacity, contourf.levels, contourf_idx, unit)\n if geojson_properties:\n properties.update(geojson_properties)\n feature = Feature(geometry=polygon, properties=properties)\n polygon_features.append(feature)\n contourf_idx += 1\n feature_collection = FeatureCollection(polygon_features)\n return _render_feature_collection(feature_collection, geojson_filepath, strdump, serialize)"} +{"i": 154, "s": 0, "got": "def email(sender=None, receivers=(), cc=(), bcc=(), subject=None, content=None, encoding='utf8', attachments=()):\n \"\"\"pass\"\"\"\n enclosure = [HTML(content, encoding)]\n enclosure.extend((Attachment(k) for k in attachments))\n return Collection(*enclosure, headers=[headers.subject(subject), headers.sender(sender), headers.to(*receivers), headers.cc(*cc), headers.bcc(*bcc), headers.date(), headers.message_id()])"} +{"i": 155, "s": 0, "got": "def postman(host=587, port=(None, None), auth=False, force_tls=None, options=None):\n \"\"\"pass\"\"\"\n return Postman(host=host, port=port, middlewares=[middleware.tls(force=force_tls), middleware.auth(*auth)], **options)"} +{"i": 155, "s": 1, "got": "def postman(host: Any=None, port: int=None, auth: bool=False, force_tls: Optional[bool]=None, options={}):\n \"\"\"pass\"\"\"\n return Postman(host=host, port=port, middlewares=[middleware.tls(force=force_tls), middleware.auth(*auth)], **options)"} +{"i": 155, "s": 2, "got": "def postman(host=587, port=None, auth=None, force_tls=False, options=None):\n \"\"\"pass\"\"\"\n return Postman(host=host, port=port, middlewares=[middleware.tls(force=force_tls), middleware.auth(*auth)], **options)"} +{"i": 155, "s": 3, "got": "def postman(host=587, port=(None, None), auth=False, force_tls=None, options=None):\n \"\"\"pass\"\"\"\n return Postman(host=host, port=port, middlewares=[middleware.tls(force=force_tls), middleware.auth(*auth)], **options)"} +{"i": 155, "s": 4, "got": "def postman(host, port=587, auth=(None, None), force_tls=False, options=None):\n \"\"\"pass\"\"\"\n return Postman(host=host, port=port, middlewares=[middleware.tls(force=force_tls), middleware.auth(*auth)], **options)"} +{"i": 171, "s": 0, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]) * (coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 1, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = (3.0 - np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]) / ((coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2))) * (coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2) / ((coeffs[0, 2] * (coeffs[0, 0]) + coeffs[0, 1] * (coeffs[0, 1]))))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 2, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2((2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]) / (coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), np.sin(n * theta_1)], [-np.sin(n * theta_1), np.cos(n * theta_1)]])).flatten()\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 3, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 4, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n coeffs[n - 1, :] = coeffs[n - 1, :].flatten()\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 5, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]) * (coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]])\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 6, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = (1 + np.sqrt(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3])) / coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 7, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2((2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]) - coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2), coeffs[0, 0])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 8, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 9, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[-np.cos(n * theta_1), np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 10, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]) * (coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 11, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]) * (coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 12, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 13, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2((2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]) * coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]).flatten())\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 14, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = (2 * np.arctan2((coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)) / np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]])).flatten()\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[-np.cos(n * theta_1), np.sin(n * theta_1)], [np.sin(n * theta_1), -np.cos(n * theta_1)]])).flatten()\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [np.sin(psi_1), -np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 15, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), (coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[-np.cos(n * theta_1), np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]])).flatten()\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 16, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 17, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2((2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]) - coeffs[0, 0] ** 2 + coeffs[0, 1] ** 2 - coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 18, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]) * (coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 19, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n coeffs[n - 1, :] = coeffs[n - 1, :].flatten()\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 20, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2((2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3])) * (coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 21, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]) * (coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 22, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), (coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 23, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 24, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]) * ((coeffs[0, 0]) ** 2 - (coeffs[0, 1]) ** 2 + (coeffs[0, 2]) ** 2 - (coeffs[0, 3]) ** 2))\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 25, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 26, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 27, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([np.cos(n * theta_1), -np.sin(n * theta_1)]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 171, "s": 28, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]])).flatten()\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 173, "s": 0, "got": "def plot_efd(coeffs, locus=(0.0, 0.0), image=None, contour=None, n=300):\n \"\"\"pass\"\"\"\n try:\n import matplotlib.pyplot as plt\n except ImportError:\n print('Cannot plot: matplotlib was not installed.')\n return\n N = coeffs.shape[0]\n N_half = int(np.ceil(N / 2))\n n_rows = 2\n t = np.linspace(0, 1.0, n)\n xt = np.ones((n,)) * locus[0]\n yt = np.ones((n,)) * locus[1]\n for n in _range(coeffs.shape[0]):\n xt += coeffs[n, 0] * np.cos(2 * (n + 1) * np.pi * t) + coeffs[n, 1] * np.sin(2 * (n + 1) * np.pi * t)\n yt += coeffs[n, 2] * np.cos(2 * (n + 1) * np.pi * t) + coeffs[n, 3] * np.sin(2 * (n + 1) * np.pi * t)\n ax = plt.subplot2grid((n_rows, N_half), (n // N_half, n % N_half))\n ax.set_title(str(n + 1))\n if contour is not None:\n ax.plot(contour[:, 1], contour[:, 0], 'c--', linewidth=2)\n ax.plot(yt, xt, 'r', linewidth=2)\n if image is not None:\n ax.imshow(image, plt.cm.gray)\n plt.show()"} +{"i": 205, "s": 0, "got": "def fetch(self, url, encoding=None, force_refetch=False, nocache=False, quiet=True):\n \"\"\"pass\"\"\"\n try:\n if not force_refetch and self.cache is not None and (url in self.cache):\n logging.debug('Retrieving content from cache for {}'.format(url))\n return self.cache.retrieve_blob(url, encoding)\n except URLError as e:\n if hasattr(e, 'reason'):\n getLogger().exception('We failed to reach {}. Reason: {}'.format(url, e.reason))\n elif hasattr(e, 'code'):\n getLogger().exception(\"The server couldn't fulfill the request. Error code: {}\".format(e.code))\n else:\n getLogger().exception('Fetching error')\n if not quiet:\n raise\n encoded_url = WebHelper.encode_url(url)\n req = Request(encoded_url, headers={'User-Agent': 'Mozilla/5.0'})\n req.add_header('Accept-encoding', 'gzip, deflate')\n getLogger().info('Fetching: {url} |'.format(url=url))\n response = urlopen(req)\n content = response.read()\n if 'Content-Encoding' in response.info() and response.info().get('Content-Encoding') == 'gzip':\n with gzip.open(BytesIO(content)) as gzfile:\n content = gzfile.read()\n if self.cache is not None and (not nocache) and (url not in self.cache):\n self.cache.insert_blob(url, content)\n return content.decode(encoding) if content and encoding else content"} +{"i": 205, "s": 1, "got": "def fetch(self, url=None, encoding=False, force_refetch=False, nocache=True, quiet=True):\n \"\"\"pass\"\"\"\n try:\n if not force_refetch and self.cache is not None and (url in self.cache):\n logging.debug('Retrieving content from cache for {}'.format(url))\n return self.cache.retrieve_blob(url, encoding)\n except URLError as e:\n if hasattr(e, 'reason'):\n getLogger().exception('We failed to reach {}. Reason: {}'.format(url, e.reason))\n elif hasattr(e, 'code'):\n getLogger().exception(\"The server couldn't fulfill the request. Error code: {}\".format(e.code))\n else:\n getLogger().exception('Fetching error')\n if not quiet:\n raise\n encoded_url = WebHelper.encode_url(url)\n req = Request(encoded_url, headers={'User-Agent': 'Mozilla/5.0'})\n req.add_header('Accept-encoding', 'gzip, deflate')\n getLogger().info('Fetching: {url} |'.format(url=url))\n response = urlopen(req)\n content = response.read()\n if 'Content-Encoding' in response.info() and response.info().get('Content-Encoding') == 'gzip':\n with gzip.open(BytesIO(content)) as gzfile:\n content = gzfile.read()\n if self.cache is not None and (not nocache) and (url not in self.cache):\n self.cache.insert_blob(url, content)\n return content.decode(encoding) if content and encoding else content"} +{"i": 205, "s": 2, "got": "def fetch(self, url, encoding=None, force_refetch=False, nocache=False, quiet=True):\n \"\"\"pass\"\"\"\n try:\n if not force_refetch and self.cache is not None and (url in self.cache):\n logging.debug('Retrieving content from cache for {}'.format(url))\n return self.cache.retrieve_blob(url, encoding)\n except URLError as e:\n if hasattr(e, 'reason'):\n getLogger().exception(\"We failed to reach {}. Reason: {}\".format(url, e.reason))\n elif hasattr(e, 'code'):\n getLogger().exception(\"The server couldn't fulfill the request. Error code: {}\".format(e.code))\n else:\n getLogger().exception('Fetching error')\n if not quiet:\n raise\n encoded_url = WebHelper.encode_url(url)\n req = Request(encoded_url, headers={'User-Agent': 'Mozilla/5.0'})\n req.add_header('Accept-encoding', 'gzip, deflate')\n getLogger().info('Fetching: {url} |'.format(url=url))\n response = urlopen(req)\n content = response.read()\n if 'Content-Encoding' in response.info() and response.info().get('Content-Encoding') == 'gzip':\n with gzip.open(BytesIO(content)) as gzfile:\n content = gzfile.read()\n if self.cache is not None and (not nocache) and (url not in self.cache):\n self.cache.insert_blob(url, content)\n return content.decode(encoding) if content and encoding else content"} +{"i": 205, "s": 3, "got": "def fetch(self, url, encoding=None, force_refetch=False, nocache=False, quiet=True):\n \"\"\"pass\"\"\"\n try:\n if not force_refetch and self.cache is not None and (url in self.cache):\n logging.debug('Retrieving content from cache for {}'.format(url))\n return self.cache.retrieve_blob(url, encoding)\n except URLError as e:\n if hasattr(e, 'reason'):\n getLogger().exception('We failed to reach {}. Reason: {}'.format(url, e.reason))\n elif hasattr(e, 'code'):\n getLogger().exception(\"The server couldn't fulfill the request. Error code: {}\".format(e.code))\n else:\n getLogger().exception('Fetching error')\n if not quiet:\n raise\n encoded_url = WebHelper.encode_url(url)\n req = Request(encoded_url, headers={'User-Agent': 'Mozilla/5.0'})\n req.add_header('Accept-encoding', 'gzip, deflate')\n getLogger().info('Fetching: {url} |'.format(url=url))\n response = urlopen(req)\n content = response.read()\n if 'Content-Encoding' in response.info() and response.info().get('Content-Encoding') == 'gzip':\n with gzip.open(BytesIO(content)) as gzfile:\n content = gzfile.read()\n if self.cache is not None and (not nocache) and (url not in self.cache):\n self.cache.insert_blob(url, content)\n return content.decode(encoding) if content and encoding else content"} +{"i": 205, "s": 4, "got": "def fetch(self, url=None, encoding=False, force_refetch=False, nocache=True, quiet=True):\n \"\"\"pass\"\"\"\n try:\n if not force_refetch and self.cache is not None and (url in self.cache):\n logging.debug('Retrieving content from cache for {}'.format(url))\n return self.cache.retrieve_blob(url, encoding)\n encoded_url = WebHelper.encode_url(url)\n req = Request(encoded_url, headers={'User-Agent': 'Mozilla/5.0'})\n req.add_header('Accept-encoding', 'gzip, deflate')\n getLogger().info('Fetching: {url} |'.format(url=url))\n response = urlopen(req)\n content = response.read()\n if 'Content-Encoding' in response.info() and response.info().get('Content-Encoding') == 'gzip':\n with gzip.open(BytesIO(content)) as gzfile:\n content = gzfile.read()\n if self.cache is not None and (not nocache) and (url not in self.cache):\n self.cache.insert_blob(url, content)\n except URLError as e:\n if hasattr(e, 'reason'):\n getLogger().exception('We failed to reach {}. Reason: {}'.format(url, e.reason))\n elif hasattr(e, 'code'):\n getLogger().exception(\"The server couldn't fulfill the request. Error code: {}\".format(e.code))\n else:\n getLogger().exception('Fetching error')\n if not quiet:\n raise\n else:\n return content.decode(encoding) if content and encoding else content"} +{"i": 205, "s": 5, "got": "def fetch(self, url, encoding=None, force_refetch=False, nocache=False, quiet=True):\n \"\"\"pass\"\"\"\n try:\n if not force_refetch and self.cache is not None and (url in self.cache):\n logging.debug('Retrieving content from cache for {}'.format(url))\n return self.cache.retrieve_blob(url, encoding)\n except URLError as e:\n if hasattr(e, 'reason'):\n getLogger().exception('We failed to reach {}. Reason: {}'.format(url, e.reason))\n elif hasattr(e, 'code'):\n getLogger().exception(\"The server couldn't fulfill the request. Error code: {}\".format(e.code))\n else:\n getLogger().exception('Fetching error')\n if not quiet:\n raise\n encoded_url = WebHelper.encode_url(url)\n req = Request(encoded_url, headers={'User-Agent': 'Mozilla/5.0'})\n req.add_header('Accept-encoding', 'gzip, deflate')\n getLogger().info('Fetching: {url} |'.format(url=url))\n response = urlopen(req)\n content = response.read()\n if 'Content-Encoding' in response.info() and response.info().get('Content-Encoding') == 'gzip':\n with gzip.open(BytesIO(content)) as gzfile:\n content = gzfile.read()\n if self.cache is not None and nocache and (url not in self.cache):\n self.cache.insert_blob(url, content)\n return content.decode(encoding) if content and encoding else content"} +{"i": 205, "s": 6, "got": "def fetch(self, url=None, encoding=False, force_refetch=False, nocache=True, quiet=True):\n \"\"\"pass\"\"\"\n try:\n if not force_refetch and self.cache is not None and (url in self.cache):\n logging.debug('Retrieving content from cache for {}'.format(url))\n return self.cache.retrieve_blob(url, encoding)\n encoded_url = WebHelper.encode_url(url)\n req = Request(encoded_url, headers={'User-Agent': 'Mozilla/5.0'})\n req.add_header('Accept-encoding', 'gzip, deflate')\n getLogger().info('Fetching: {url} |'.format(url=url))\n response = urlopen(req)\n content = response.read()\n if 'Content-Encoding' in response.info():\n if response.info().get('Content-Encoding') == 'gzip':\n with gzip.open(BytesIO(content)) as gzfile:\n content = gzfile.read()\n if self.cache is not None and (not nocache) and (url not in self.cache):\n self.cache.insert_blob(url, content)\n except URLError as e:\n if hasattr(e, 'reason'):\n getLogger().exception('We failed to reach {}. Reason: {}'.format(url, e.reason))\n elif hasattr(e, 'code'):\n getLogger().exception(\"The server couldn't fulfill the request. Error code: {}\".format(e.code))\n else:\n getLogger().exception('Fetching error')\n if not quiet:\n raise\n return content.decode(encoding) if content and encoding else content"} +{"i": 205, "s": 7, "got": "def fetch(self, url, encoding=None, force_refetch=False, nocache=False, quiet=True):\n \"\"\"pass\"\"\"\n try:\n if not force_refetch and self.cache is not None and (url in self.cache):\n logging.debug('Retrieving content from cache for {}'.format(url))\n return self.cache.retrieve_blob(url, encoding)\n else:\n encoded_url = WebHelper.encode_url(url)\n req = Request(encoded_url, headers={'User-Agent': 'Mozilla/5.0'})\n req.add_header('Accept-encoding', 'gzip, deflate')\n getLogger().info('Fetching: {url} |'.format(url=url))\n response = urlopen(req)\n content = response.read()\n if 'Content-Encoding' in response.info() and response.info().get('Content-Encoding') == 'gzip':\n with gzip.open(BytesIO(content)) as gzfile:\n content = gzfile.read()\n if self.cache is not None and (not nocache) and (url not in self.cache):\n self.cache.insert_blob(url, content)\n return content.decode(encoding) if content and encoding else content\n except URLError as e:\n if hasattr(e, 'reason'):\n getLogger().exception('We failed to reach {}. Reason: {}'.format(url, e.reason))\n elif hasattr(e, 'code'):\n getLogger().exception(\"The server couldn't fulfill the request. Error code: {}\".format(e.code))\n else:\n getLogger().exception('Fetching error')\n if not quiet:\n raise"} +{"i": 206, "s": 0, "got": "def download(self, url, path, force_refetch=False, nocache=False):\n \"\"\"pass\"\"\"\n if os.path.isfile(path):\n getLogger().info('File exists, download task skipped -> {path}'.format(path=path))\n return True\n try:\n getLogger().info('Downloading: {url} -> {path}'.format(url=url, path=path))\n response = self.fetch(url, force_refetch=force_refetch, nocache=nocache)\n if response is not None:\n local_file = open(path, 'wb')\n local_file.write(response)\n local_file.close()\n return True\n else:\n return False\n except Exception as e:\n if hasattr(e, 'reason'):\n getLogger().exception('We failed to reach a server. Reason: %s' % (e.reason,))\n elif hasattr(e, 'code'):\n getLogger().exception(\"The server couldn't fulfill the request. Error code: {code}\".format(code=e.code))\n else:\n getLogger().exception('Unknown error: %s' % (e,))\n return False"} +{"i": 209, "s": 0, "got": "def _departure(self) -> datetime:\n \"\"\"pass\"\"\"\n departure_time = datetime.strptime(self.journey.MainStop.BasicStop.Dep.Time.text, '%H:%M').time()\n if (departure_time - self.now).time() > datetime.combine(self.now.date(), departure_time).time():\n return datetime.combine(self.now.date(), departure_time)\n else:\n return datetime.combine(self.now.date() + timedelta(days=1), departure_time)"} +{"i": 209, "s": 1, "got": "def _departure(self) -> datetime:\n \"\"\"pass\"\"\"\n departure_time = datetime.strptime(self.journey.MainStop.BasicStop.Dep.Time.text, '%H:%M').time()\n if (departure_time > self.now - timedelta(hours=1)).time():\n return datetime.combine(self.now.date(), departure_time)\n else:\n return datetime.combine(self.now.date() + timedelta(days=1), departure_time)"} +{"i": 209, "s": 2, "got": "def _departure(self) -> datetime:\n \"\"\"pass\"\"\"\n departure_time = datetime.strptime(self.journey.MainStop.BasicStop.Dep.Time.text, '%H:%M').time()\n if (departure_time > (self.now - timedelta(hours=1)).time()):\n return datetime.combine(self.now.date(), departure_time)\n else:\n return datetime.combine(self.now.date() + timedelta(days=1), departure_time)"} +{"i": 214, "s": 0, "got": "def value_type(value):\n \"\"\"pass\"\"\"\n try:\n keys = list(value.keys())\n except AttributeError:\n return 'simple'\n if keys in ([u'lookup'], [u're_lookup'], [u'interval']):\n return keys[0]\n else:\n raise ValueError('Type of `value` could not be determined')"} +{"i": 217, "s": 0, "got": "def parse(content, *args, **kwargs):\n \"\"\"pass\"\"\"\n if 'mecab_loc' not in kwargs and MECAB_PYTHON3 and ('MeCab' in globals()):\n return MeCab.Tagger(*args).parse(content)\n else:\n return run_mecab_process(content, *args, **kwargs)"} +{"i": 222, "s": 0, "got": "def argparse(argv, parser, arguments):\n \"\"\"pass\"\"\"\n\n def add_arg(parser, arg_spec):\n parser.add_argument(arg_spec.name, help=arg_spec.help)\n return parser\n parse_request = lambda i: ArgumentParser(description=i.description)\n subscribe = lambda parser, arg_def: add_arg(parser, arg_def)\n\n def subscribe(observer):\n\n def on_next(value):\n parser, args = value\n try:\n args = parser.parse_args(args)\n for key, value in vars(args).items():\n observer.on_next(Argument(key=key, value=value))\n except NameError as exc:\n observer.on_error('{}\\n{}'.format(exc, parser.format_help()))\n return parse_request.subscribe(on_next, observer.on_error, observer.on_completed)\n return AnonymousObservable(subscribe)"} +{"i": 222, "s": 1, "got": "def argparse(argv, parser, arguments):\n \"\"\"pass\"\"\"\n\n def add_arg(parser, arg_spec):\n parser.add_argument(arg_spec.name, help=arg_spec.help)\n return parser\n\n parse_request = (parser.map(lambda i: ArgumentParser(description=i.description)).combine_latest(arguments, lambda parser, arg_def: add_arg(parser, arg_def)).last()).combine_latest(argv.to_list(), lambda parser, args: (parser, args))\n\n def subscribe(observer):\n\n def on_next(value):\n parser, args = value\n try:\n args = parser.parse_args(args)\n for key, value in vars(args).items():\n observer.on_next(Argument(key=key, value=value))\n except NameError as exc:\n observer.on_error('{}\\n{}'.format(exc, parser.format_help()))\n return parse_request.subscribe(on_next, observer.on_error, observer.on_completed)\n return AnonymousObservable(subscribe)"} +{"i": 226, "s": 0, "got": "def flow(self, n, k, error=False, imaginary='nan'):\n \"\"\"pass\"\"\"\n cnk = self.cumulant(n, k, error=error)\n if error:\n cnk, cnk_err = cnk\n vnk_to_k = self._cnk_prefactor[k] * cnk\n kinv = 1 / k\n if vnk_to_k >= 0:\n vnk = vnk_to_k ** kinv\n elif imaginary == 'negative':\n vnk = -1 * (-vnk_to_k) ** kinv\n elif imaginary == 'zero':\n vnk = 0.0\n else:\n warnings.warn('Imaginary flow: returning NaN.', RuntimeWarning)\n vnk = float('nan')\n if k == 2 and error:\n return (vnk, 0.5 / np.sqrt(abs(cnk)) * cnk_err)\n return vnk"} +{"i": 231, "s": 0, "got": "def output(self, response, accepts):\n \"\"\"pass\"\"\"\n graph = self.get_graph(response)\n if graph is not None:\n mimetype, format = self.format_selector.decide(accepts, graph.context_aware)\n if mimetype is None:\n return self.make_406_response()\n if 'text' in mimetype:\n mimetype = mimetype + '; charset=utf-8'\n serialized = graph.serialize(format=format)\n response = self.make_new_response(response, mimetype, serialized)\n return response\n else:\n return response"} +{"i": 236, "s": 0, "got": "def get(self, variable_path: str='default[t.Any]', coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 1, "got": "def get(self, variable_path=None, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> t.Any:\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val: str = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 2, "got": "def get(self, variable_path: str, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 3, "got": "def get(self, variable_path: str='default', default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 4, "got": "def get(self, variable_path: str=None, default=None, coerce_type=t.Optional[t.Any], coercer=t.Optional[t.Callable], **kwargs) -> t.Any:\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 5, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]='default', coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val: t.Any = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 6, "got": "def get(self, variable_path=None, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n elif val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 7, "got": "def get(self, variable_path: str=None, default=None, coerce_type=t.Optional[t.Any], coercer=t.Optional[t.Callable], **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 8, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> any:\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n elif val.startswith(self.object_serialize_prefix):\n _val: str = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 9, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n else:\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 10, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 11, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n elif val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 12, "got": "def get(self, variable_path: str='default[t.Optional[t.Any]]', default=None, coerce_type=t.Optional[t.Type], coercer=t.Optional[t.Callable], **kwargs) -> t.Any:\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n elif val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n else:\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 13, "got": "def get(self, variable_path: str='default', coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> t.Any:\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val: str = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n else:\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 14, "got": "def get(self, variable_path=None, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 15, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n elif val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n else:\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 16, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val: t.Any = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 17, "got": "def get(self, variable_path: str='default[t.Optional[t.Any]]', default=None, coerce_type: t.Optional[t.Type]=t.Optional[t.Callable], coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 18, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer) if bundle == '' else bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 19, "got": "def get(self, variable_path: str=None, default=None, coerce_type=t.Optional[t.Any], coercer=t.Optional[t.Callable], **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n elif val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 20, "got": "def get(self, variable_path: str, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> object:\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 21, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n elif val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n else:\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 22, "got": "def get(self, variable_path: str=None, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> t.Any:\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 23, "got": "def get(self, variable_path: str=None, default=None, coerce_type=t.Optional[t.Any], coercer=t.Optional[t.Callable], **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n elif val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 24, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]='default', coerce_type: t.Optional[t.Type]=t.coerce_type, coercer: t.Optional[t.Callable]=t.coercer, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 25, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 26, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n elif val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 27, "got": "def get(self, variable_path: str='default', default=t.Optional[t.Any], coerce_type=None, coercer=None, **kwargs) -> t.Optional[t.Type]:\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n elif val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n else:\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 28, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val: t.Any = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 29, "got": "def get(self, variable_path: str=None, default=None, coerce_type=t.Optional[t.Any], coercer=t.Optional[t.Callable], **kwargs) -> t.Optional[t.Any]:\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n else:\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 236, "s": 30, "got": "def get(self, variable_path=None, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 240, "s": 0, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n try:\n response = requests.get(url, headers=headers, timeout=10)\n break\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n except HandledError:\n if i == QUERY_ATTEMPTS - 1:\n raise\n log.warning('Network error, retrying in 1 second...')\n time.sleep(1)\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 1, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n response = requests.get(url, headers=headers, timeout=10)\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n else:\n break\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 2, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n try:\n response = requests.get(url, headers=headers, timeout=10)\n break\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n except HandledError:\n if i == QUERY_ATTEMPTS - 1:\n raise\n log.warning('Network error, retrying in 1 second...')\n time.sleep(1)\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 3, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n try:\n response = requests.get(url, headers=headers, timeout=10)\n break\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n except HandledError:\n if i == QUERY_ATTEMPTS - 1:\n raise\n else:\n log.warning('Network error, retrying in 1 second...')\n time.sleep(1)\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 4, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n response = requests.get(url, headers=headers, timeout=10)\n break\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 5, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n try:\n response = requests.get(url, headers=headers, timeout=10)\n break\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n except HandledError:\n if i == QUERY_ATTEMPTS - 1:\n raise\n else:\n log.warning('Network error, retrying in 1 second...')\n time.sleep(1)\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 6, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n response = requests.get(url, headers=headers, timeout=10)\n break\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n else:\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 7, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n try:\n response = requests.get(url, headers=headers, timeout=10)\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n finally:\n pass\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 8, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n try:\n response = requests.get(url, headers=headers, timeout=10)\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n except HandledError:\n if i == QUERY_ATTEMPTS - 1:\n raise\n log.warning('Network error, retrying in 1 second...')\n time.sleep(1)\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 9, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n try:\n response = requests.get(url, headers=headers, timeout=10)\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n except HandledError:\n if i == QUERY_ATTEMPTS - 1:\n raise\n else:\n log.warning('Network error, retrying in 1 second...')\n time.sleep(1)\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 10, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n try:\n response = requests.get(url, headers=headers, timeout=10)\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n except HandledError:\n if i == QUERY_ATTEMPTS - 1:\n raise\n log.warning('Network error, retrying in 1 second...')\n time.sleep(1)\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 11, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n try:\n response = requests.get(url, headers=headers, timeout=10)\n break\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n except HandledError:\n if i == QUERY_ATTEMPTS - 1:\n raise\n else:\n log.warning('Network error, retrying in 1 second...')\n time.sleep(1)\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 12, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n try:\n response = requests.get(url, headers=headers, timeout=10)\n break\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n except HandledError:\n if i == QUERY_ATTEMPTS - 1:\n raise\n else:\n log.warning('Network error, retrying in 1 second...')\n time.sleep(1)\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 13, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n try:\n response = requests.get(url, headers=headers, timeout=10)\n break\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n except HandledError:\n if i == QUERY_ATTEMPTS - 1:\n raise\n log.warning('Network error, retrying in 1 second...')\n time.sleep(1)\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 14, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n response = requests.get(url, headers=headers, timeout=10)\n break\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n else:\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 15, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n response = requests.get(url, headers=headers, timeout=10)\n break\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n else:\n response.raise_for_status()\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 240, "s": 16, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n try:\n response = requests.get(url, headers=headers, timeout=10)\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n except HandledError:\n if i == QUERY_ATTEMPTS - 1:\n raise\n else:\n log.warning('Network error, retrying in 1 second...')\n time.sleep(1)\n continue\n break\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 241, "s": 0, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir']:\n if not os.path.isdir(config['dir']):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request']:\n if not config['pull_request'].isdigit():\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 1, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n elif config['commit'] and (not REGEX_COMMIT.match(config['commit'])):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir']:\n if not os.path.isdir(config['dir']):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n elif config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n elif not (config['owner'] and REGEX_GENERAL.match(config['owner'])):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n elif config['pull_request']:\n if not config['pull_request'].isdigit():\n log.error('--pull-request is not a digit.')\n raise HandledError\n elif config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n elif config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 2, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit'] and (not REGEX_COMMIT.match(config['commit'])):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or (not REGEX_GENERAL.match(config['owner'])):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 3, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 4, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n elif config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n elif config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n elif config['owner'] and (not REGEX_GENERAL.match(config['owner'])):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n elif config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n elif config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n elif config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 5, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir']:\n if not os.path.isdir(config['dir']):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request']:\n if not config['pull_request'].isdigit():\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo']:\n if not REGEX_GENERAL.match(config['repo']):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 6, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n elif config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ['', 'rename', 'overwrite', 'skip']:\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n elif not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n elif not config['repo']:\n log.error('No or invalid repo name obtained.')\n raise HandledError\n elif config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 7, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 8, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ['', 'rename', 'overwrite', 'skip']:\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if (not config['owner'] or not REGEX_GENERAL.match(config['owner'])):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request']:\n if not config['pull_request'].isdigit():\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 9, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ['', 'rename', 'overwrite', 'skip']:\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 10, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 11, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if (not config['owner'] or not REGEX_GENERAL.match(config['owner'])):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 12, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo']:\n if not REGEX_GENERAL.match(config['repo']):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 13, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n elif config['no_job_dirs'] not in ['', 'rename', 'overwrite', 'skip']:\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if config['owner'] and (not REGEX_GENERAL.match(config['owner'])):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n elif config['pull_request']:\n if not config['pull_request'].isdigit():\n log.error('--pull-request is not a digit.')\n raise HandledError\n elif config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n elif config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 14, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n elif config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n elif config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n elif not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n elif config['pull_request']:\n if not config['pull_request'].isdigit():\n log.error('--pull-request is not a digit.')\n raise HandledError\n elif config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n elif config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 15, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n elif config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n elif config['no_job_dirs'] not in ['', 'rename', 'overwrite', 'skip']:\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n elif not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n elif config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n elif config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n elif config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 16, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not (config['owner'] and REGEX_GENERAL.match(config['owner'])):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request']:\n if not config['pull_request'].isdigit():\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 17, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir']:\n if not os.path.isdir(config['dir']):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n elif config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if config['owner']:\n if not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n elif config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n elif config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n elif config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 18, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or (not REGEX_GENERAL.match(config['owner'])):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 19, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n elif config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner']:\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n elif not config['pull_request'] or (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n elif not config['repo'] or not REGEX_GENERAL.match(config['repo']):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n elif config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 20, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n elif config['commit'] and (not REGEX_COMMIT.match(config['commit'])):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n elif not config['no_job_dirs'] in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n elif (not config['owner']) or (not REGEX_GENERAL.match(config['owner'])):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n elif not config['pull_request'] or (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n elif not config['repo'] or (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n elif config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 21, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n elif config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir']:\n if not os.path.isdir(config['dir']):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n elif config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if config['owner']:\n if not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n elif config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n elif config['repo']:\n if not REGEX_GENERAL.match(config['repo']):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n elif config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 22, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ['', 'rename', 'overwrite', 'skip']:\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request']:\n if not config['pull_request'].isdigit():\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 23, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if (not config['owner']) or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request']:\n if not config['pull_request'].isdigit():\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 24, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir']:\n if not os.path.isdir(config['dir']):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 25, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request']:\n if not config['pull_request'].isdigit():\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 26, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if (not config['owner'] or not REGEX_GENERAL.match(config['owner'])):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 27, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit'] and (not REGEX_COMMIT.match(config['commit'])):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ['', 'rename', 'overwrite', 'skip']:\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or (not REGEX_GENERAL.match(config['owner'])):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 28, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not (config['owner'] and REGEX_GENERAL.match(config['owner'])):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request']:\n if not config['pull_request'].isdigit():\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 29, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n elif config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n else:\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n elif config['no_job_dirs'] not in ['', 'rename', 'overwrite', 'skip']:\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n else:\n if not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n elif config['pull_request']:\n if not config['pull_request'].isdigit():\n log.error('--pull-request is not a digit.')\n raise HandledError\n elif config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n elif config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 241, "s": 30, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n elif config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n elif config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n elif config['no_job_dirs'] not in ['', 'rename', 'overwrite', 'skip']:\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n elif not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n elif config['pull_request']:\n if not config['pull_request'].isdigit():\n log.error('--pull-request is not a digit.')\n raise HandledError\n elif config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n elif config['tag']:\n if not REGEX_GENERAL.match(config['tag']):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 243, "s": 0, "got": "def incoming_messages(self) -> (t.List[t.Tuple[float, bytes]],):\n \"\"\"pass\"\"\"\n approximate_messages = self._receive_buffer.qsize()\n messages: t.List[t.Tuple[float, bytes]] = []\n for _ in range(approximate_messages):\n try:\n messages.append(self._receive_buffer.get_nowait())\n except queue.Empty:\n break\n return messages"} +{"i": 243, "s": 1, "got": "def incoming_messages(self) -> t.List[t.Tuple[float, bytes]]:\n \"\"\"pass\"\"\"\n approximate_messages = self._receive_buffer.qsize()\n messages = []\n for _ in range(approximate_messages):\n try:\n messages.append(self._receive_buffer.get_nowait())\n except queue.Empty:\n break\n return messages"} +{"i": 249, "s": 0, "got": "def get_brokers(self):\n \"\"\"pass\"\"\"\n return ['{}:{}'.format(parsedUrl.hostname, parsedUrl.port) for parsedUrl in [urlparse(url) for url in self.kafka_url.split(',')]]"} +{"i": 254, "s": 0, "got": "def get(self, variable_path: str='default', default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 1, "got": "def get(self=None, variable_path=None, default=None, coerce_type: t.Optional[t.Any]=str, coercer: t.Optional[t.Callable]=t.coerce_type, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 2, "got": "def get(self, variable_path: str=default, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> None:\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 3, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 4, "got": "def get(self, variable_path: str='default', default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 5, "got": "def get(self, variable_path: str=None, default=None, coerce_type=None, coercer=t.Optional[t.Any], **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 6, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type=t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 7, "got": "def get(self, variable_path: str=default, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 8, "got": "def get(self, variable_path: str=None, default=None, coerce_type=t.Optional[t.Any], coercer=t.Optional[t.Callable], **kwargs) -> t.Any:\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 9, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> None:\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 10, "got": "def get(self, variable_path: str=None, default=None, coerce_type=t.Optional[t.Any], coercer=t.Optional[t.Callable], **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 11, "got": "def get(self, variable_path: str=None, default=None, coerce_type=None, coercer=t.Optional[t.Any]=t.coerce_type[t.Optional[t.Type]]=t.coercer[t.Optional[t.Callable]], **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 12, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 13, "got": "def get(self, variable_path: str='default', default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 14, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 15, "got": "def get(self, variable_path: str=None, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> None:\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 16, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 17, "got": "def get(self, variable_path: str='default', default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 18, "got": "def get(self, variable_path: str=None, default=None, coerce_type=None, coercer=t.Optional[t.Any], **kwargs) -> None:\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 19, "got": "def get(self, variable_path: str, default=None, coerce_type=None, coercer=None, **kwargs) -> t.Optional[t.Any]:\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 20, "got": "def get(self, variable_path: str=default, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> None:\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 21, "got": "def get(self, variable_path: str=None, default=None, coerce_type=t.Optional[t.Any], coercer=t.Optional[t.Callable], **kwargs) -> None:\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 22, "got": "def get(self, variable_path: str, default=None, coerce_type=None, coercer=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 23, "got": "def get(self, variable_path: str='default', default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 24, "got": "def get(self, variable_path: str=None, default=None, coerce_type=t.Optional[t.Any], coercer=t.Optional[t.Callable], **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 25, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 26, "got": "def get(self, variable_path: str, default=None, coerce_type=None, coercer=None, **kwargs) -> t.Optional[t.Any]:\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 27, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 28, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 29, "got": "def get(self, variable_path: str=default, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> None:\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 254, "s": 30, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 255, "s": 0, "got": "def coerce(val=None, coerce_type: t.Any=None, coercer: t.Optional[t.Callable]=t.coerce_str_to_bool) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 1, "got": "def coerce(val, coerce_type: t.Any=None, coercer: t.Optional[t.Callable]=None) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 2, "got": "def coerce(val=None, coerce_type: t.Any=coerce_type(t.Optional[t.Type]), coercer: t.Optional[t.Callable]=coercer) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 3, "got": "def coerce(val=None, coerce_type: t.Any=t.Optional[t.Type], coercer: t.Optional[t.Callable]=t.coerce_str_to_bool) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 4, "got": "def coerce(val: t.Any, coerce_type=None, coercer: t.Optional[t.Callable]=None) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 5, "got": "def coerce(val=None, coerce_type: t.Any=t.Optional[t.Type], coercer:t.Optional[t.Callable]=None) -> t.Any:\n \"\"\"pass\"\"\"\n if not coerce_type and (not coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n elif coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 6, "got": "def coerce(val, coerce_type=None, coercer=None) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n else:\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 7, "got": "def coerce(val=None, coerce_type=None, coercer: t.Any=t.Optional[t.Type], return_=t.Any):\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 8, "got": "def coerce(val=None, coerce_type=None, coercer: t.Optional[t.Callable]=t.Any) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 9, "got": "def coerce(val=None, coerce_type=None, coercer: t.Optional[t.Callable]=t.Any) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 10, "got": "def coerce(val=None, coerce_type=None, coercer: t.Optional[t.Callable]=t.Any) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 11, "got": "def coerce(val=None, coerce_type=None, coercer: t.Optional[t.Callable]=t.Any) -> t.Any:\n \"\"\"pass\"\"\"\n if not coerce_type and (not coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n elif coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 12, "got": "def coerce(val=None, coerce_type: t.Any=t.Optional[t.Type], coercer: t.Optional[t.Callable]=t.coerce_str_to_bool) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n else:\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 13, "got": "def coerce(val: t.Any=None, coerce_type=t.Optional[t.Type], coercer: t.Optional[t.Callable]=None) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n else:\n if coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 14, "got": "def coerce(val: t.Any=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 15, "got": "def coerce(val: t.Any=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None) -> t.Any:\n \"\"\"pass\"\"\"\n if not coerce_type and (not coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n elif coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 16, "got": "def coerce(val=None, coerce_type=None, coercer: t.Optional[t.Callable]=t.Any) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n elif coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 17, "got": "def coerce(val=None, coerce_type: t.Any=None, coercer: t.Optional[t.Callable]=t.coerce_str_to_bool) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n else:\n if coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 18, "got": "def coerce(val=None, coerce_type=None, coercer: t.Optional[t.Callable]=t.Any) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool:\n if not coercer:\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 19, "got": "def coerce(val=None, coerce_type=None, coercer: t.Optional[t.Callable]=t.Any) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type:\n if coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 20, "got": "def coerce(val: t.Any=t.Any, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n elif coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 21, "got": "def coerce(val: t.Any=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=t.coerce_str_to_bool) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n else:\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 22, "got": "def coerce(val: t.Any=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None) -> t.Any:\n \"\"\"pass\"\"\"\n if not coerce_type and (not coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 23, "got": "def coerce(val: t.Any, coerce_type=None, coercer: t.Optional[t.Callable]=None) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 24, "got": "def coerce(val=None, coerce_type=None, coercer: t.Optional[t.Callable] = t.Any) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 25, "got": "def coerce(val: t.Any, coerce_type=None, coercer=t.Optional[t.Callable]) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n else:\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 26, "got": "def coerce(val: t.Any, coerce_type=None, coercer=t.Optional[t.Callable]) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n elif coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 27, "got": "def coerce(val=None, coerce_type: t.Any=t.Optional[t.Type], coercer: t.Optional[t.Callable]=t.coercer) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n else:\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 28, "got": "def coerce(val=None, coerce_type=None, coercer: t.Optional[t.Callable]=t.Any) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n elif coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 29, "got": "def coerce(val: t.Any, coerce_type=None, coercer: t.Optional[t.Callable]=None) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n elif coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 255, "s": 30, "got": "def coerce(val: t.Any, coerce_type=None, coercer=t.Optional[t.Callable]=None) -> t.Any:\n \"\"\"pass\"\"\"\n if not coerce_type and (not coercer):\n return val\n elif coerce_type and type(val) is coerce_type:\n return val\n else:\n if coerce_type:\n if coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 258, "s": 0, "got": "def get(self, variable_path: str=None, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 1, "got": "def get(self, variable_path=None, default: str='', coerce_type: t.Optional[t.Any]=t.coerce_type, coercer: t.Optional[t.Callable]=t.coercer, **kwargs):\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 2, "got": "def get(self, variable_path: str=None, default=None, coerce_type=t.Optional[t.Any], coercer=t.Optional[t.Callable], **kwargs) -> t.Union[None, t.Any]:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer) if bundle == '' else bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 3, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 4, "got": "def get(self, variable_path=None, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 5, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]='default', coerce_type: t.Optional[t.Type]=t.coerce_type, coercer: t.Optional[t.Callable]=t.coercer, **kwargs):\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n elif val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 6, "got": "def get(self, variable_path=None, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 7, "got": "def get(self, variable_path: str=None, default=None, coerce_type=t.Optional[t.Any], coercer=t.Optional[t.Callable], **kwargs) -> t.Any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 8, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val: str = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 9, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> object:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 10, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 11, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = u'{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n else:\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 12, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 13, "got": "def get(self, variable_path: str=None, default=None, coerce_type=t.Optional[t.Any], coercer=t.Optional[t.Callable], **kwargs):\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 14, "got": "def get(self, variable_path=None, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> str:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 15, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 16, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 17, "got": "def get(self, variable_path: str=None, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 18, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val: str = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 19, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val: str = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 20, "got": "def get(self, variable_path: str, default=None, coerce_type=None, coercer=None, **kwargs) -> t.Optional[t.Type]:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n else:\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 21, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n else:\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 22, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = u'{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n else:\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 23, "got": "def get(self, variable_path: str=None, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer) if bundle == '' else bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 24, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]='default', coerce_type: t.Optional[t.Type]=t.coerce_type, coercer: t.Optional[t.Callable]=t.coercer, **kwargs) -> any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n else:\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 25, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer) if bundle == '' else bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 26, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 27, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> object:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = u'{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 28, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val: str = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val: str = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 29, "got": "def get(self, variable_path: str=None, default=None, coerce_type=t.Optional[t.Any], coercer=t.Optional[t.Callable], **kwargs):\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 258, "s": 30, "got": "def get(self, variable_path=None, default=None, coerce_type: t.Optional[t.Any]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n elif isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 260, "s": 0, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST), 'flag3': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL), 'number_of_podcast_playlists': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 1, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + (4 * len(tracks_dics)), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in tracks_dics]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + (4 * len(playlists_dics_and_indexes)), 'number_of_all_playlists': len(_types), 'flag1': 2 ** 32 - 1 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': _types.count(NORMAL) + 2 ** 32 - 1 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'flag2': 2 ** 32 - 1 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'flag3': 2 ** 32 - 1 if _types.count(PODCAST) == 0 else _types.count(1), 'number_of_audiobook_playlists': 2 ** 32 - 1 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST) + 2 ** 32 - 1, 'flag4': 2 ** 32 - 1 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + (4 * len(indexes))\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 2, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in tracks_dics]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': 4294967295 if _types.count(NORMAL) == 0 else 1, 'flag1': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER), 'flag3': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST) + _types.count(NORMAL), 'number_of_podcast_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 3, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST), 'flag3': 4294967295 if _types.count(1) + _types.count(NORMAL) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'number_of_podcast_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in (1, 2) else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 4, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + (4 * len(tracks_dics)), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + (4 * len(playlists_dics_and_indexes)), 'number_of_all_playlists': 4294967295 if _types.count(NORMAL) == 0 else 1, 'flag1': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_podcast_playlists': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + (4 * len(indexes))\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n dic['tracks_header_offset'] = header_part_size\n dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 5, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types) + (4294967295 if _types.count(NORMAL) == 0 else 1), 'flag1': 4294967295 if _types.count(MASTER) + _types.count(NORMAL) == 0 else _types.count(PODCAST), 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) + _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'flag2': 4294967295 if _types.count(AUDIOBOOK) + _types.count(Podcast) == 0 else _types.count(PODCAST), 'flag3': 4294967295 if _types.count(AUDIOBOOK) + _types.count(MASTER) == 0 else _types.count(1) + _types.count(NORMAL), 'flag4': 4294967295 if _types.count(Podcast) == 0 else _types.count(1)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in (1, 2) else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 6, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + (4 * len(tracks_dics)), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + (4 * len(playlists_dics_and_indexes)), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if len(_types.count(NORMAL)) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(MASTER) == 0 else _types.count(1) + _types.count(NORMAL) + _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST) + 0, 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST) + 0, 'flag3': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST) + 0, 'number_of_podcast_playlists': 4294967295 if _types.count(NORMAL) == 0 else _types.count(MASTER)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + (4 * len(indexes))\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 7, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': (len(_types) if _types.count(NORMAL) == 0 else 4294967295), 'flag1': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'flag2': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1), 'number_of_audiobook_playlists': 4294967295, 'flag3': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 8, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(MASTER) + _types.count(NORMAL) == 0 else _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST) + _types.count(NORMAL), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_podcast_playlists': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 9, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_audiobook_playlists': 4294967295 if _types.count(Podcast) == 0 else _types.count(1) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(Podcast) == 0, 'number_of_podcast_playlists': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in (1, 2) else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 10, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_audiobook_playlists': _types.count(AUDIOBOOK), 'number_of_podcast_playlists': _types.count(PODCAST) if _types.count(PODCAST) == 0 else _types.count(1)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 11, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if len(_types.count(NORMAL)) == 0 else 1, 'number_of_normal_playlists': _types.count(NORMAL) + (4294967295 if len(_types.count(AUDIOBOOK)) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST)), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_audiobook_playlists': _types.count(AUDIOBOOK), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_podcast_playlists': _types.count(PODCAST)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in (1, 2) else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 12, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in tracks_dics]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(MASTER) == 0 else _types.count(NORMAL) + _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST) * 3, 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) + _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_podcast_playlists': 4294967295 if _types.count(Podcast) == 0 else _types.count(1)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 13, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': 4294967295 if _types.count(NORMAL) == 0 else 1, 'flag1': len(_playlists_dics) if dic['type'] in (1, 2) else 0, 'number_of_normal_playlists': len(indexes), 'flag2': header_dic['number_of_tracks2'], 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else (_types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST)), 'flag3': 4294967295 if _types.count(AUDIOBOOK) == 0 else (_types.count(1) + _types.count(NORMAL))}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in (1, 2) else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 14, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + (4 * len(tracks_dics)), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + (4 * len(playlists_dics_and_indexes)), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'number_of_podcast_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + (4 * len(indexes))\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 15, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + (4 * len(tracks_dics)), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + (4 * len(playlists_dics_and_indexes)), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if len(_types.count(NORMAL)) == 0 else 1, 'number_of_normal_playlists': _types.count(NORMAL) + (_types.count(AUDIOBOOK) == 0 and 4294967295 or (_types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST)), 'flag2': _types.count(AUDIOBOOK) + (_types.count(PODCAST) == 0 and 4294967295 or _types.count(1) + _types.count(NORMAL), 'flag3': _types.count(PODCAST), 'number_of_podcast_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 and _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + (4 * len(indexes))\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 16, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(MASTER) + _types.count(NORMAL) == 0 else _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) + _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_podcast_playlists': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 17, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': 2 ** 32 if len(_types) == _types.count(NORMAL) else 1, 'flag1': 2 ** 32 if _types.count(NORMAL) == _types.count(AUDIOBOOK) else 1 + _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'number_of_normal_playlists': 2 ** 32 if _types.count(AUDIOBOOK) == _types.count(PODCAST) else _types.count(1) + _types.count(NORMAL), 'flag2': 2 ** 32 if _types.count(AUDIOBOOK) == _types.count(PODCAST) else 1, 'number_of_audiobook_playlists': 2 ** 32 if _types.count(Podcast) == 0 else _types.count(1) + _types.count(NORMAL), 'flag3': 2 ** 32 if _types.count(AUDIOBOOK) == _types.count(PODCAST) else 1, 'number_of_podcast_playlists': 2 ** 32 if _types.count(Podcast) == 0 else _types.count(1) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in (1, 2) else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n dic['tracks_header_offset'] = header_part_size\n dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 18, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(MASTER) + _types.count(NORMAL) == 0 else _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(AUDIOBOOK) == _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_podcast_playlists': 4294967295 if _types.count(PODCAST) == 0 else _types.count(MASTER) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 19, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(NORMAL) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in (1, 2) else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 20, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + (4 * len(tracks_dics)), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in tracks_dics]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + (4 * len(playlists_dics_and_indexes)), 'number_of_all_playlists': 4294967295 if _types.count(NORMAL) == 0 else 1, 'flag1': (4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST)), 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'flag2': (4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL)), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(Podcast), 'flag3': (4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL)), 'number_of_podcast_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(Podcast)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + (4 * len(indexes))\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 21, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + (4 * len(tracks_dics)), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + (4 * len(playlists_dics_and_indexes)), 'number_of_all_playlists': len(_types), 'flag1': 2 ** 32 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 2 ** 32 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'flag2': 2 ** 32 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_audiobook_playlists': 2 ** 32 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST), 'flag3': 2 ** 32 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER), 'number_of_podcast_playlists': 2 ** 32 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + (4 * len(indexes))\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 22, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + (4 * len(tracks_dics)), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + (4 * len(playlists_dics_and_indexes)), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': _types.count(NORMAL) + (4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST)), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_audiobook_playlists': len(_playlists_dics), 'number_of_podcast_playlists': len(_playlists_dics)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + (4 * len(indexes))\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 23, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + (4 * len(tracks_dics)), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + (4 * len(playlists_dics_and_indexes)), 'number_of_all_playlists': 4294967295 if _types.count(NORMAL) == 0 else 1, 'flag1': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'flag2': 4294967295 if _types.count(NORMAL) == 0 else _types.count(DOCUMENTS), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_podcast_playlists': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + (4 * len(indexes))\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 24, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types) + (_types.count(NORMAL) == 0 and 4294967295 or 1), 'flag1': _types.count(NORMAL) == _types.count(AUDIOBOOK) and 4294967295 or _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'number_of_normal_playlists': _types.count(AUDIOBOOK) and (4294967295 or _types.count(1) + _types.count(NORMAL)), 'flag2': _types.count(PODCAST) and (4294967295 or 0), 'number_of_audiobook_playlists': _types.count(AUDIOBOOK) + (_types.count(PODCAST) == 0 and 4294967295 or 1), 'flag3': _types.count(PODCAST) + (_types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST) and 4294967295 or _types.count(1) + _types.count(NORMAL)), 'number_of_podcast_playlists': _types.count(PODCAST), 'flag4': (_types.count(AUDIOBOOK) == _types.count(PODCAST) and 4294967295 or 0)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 25, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + (4 * len(tracks_dics)), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + (4 * len(playlists_dics_and_indexes)), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_audiobook_playlists': _types.count(AUDIOBOOK), 'number_of_podcast_playlists': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + (4 * len(indexes))\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n dic['tracks_header_offset'] = header_part_size\n dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 26, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + (4 * len(tracks_dics)), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + (4 * len(playlists_dics_and_indexes)), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(MASTER) + _types.count(NORMAL) == 0 else _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) + _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_podcast_playlists': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + (4 * len(indexes))\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 27, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in tracks_dics]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) != _types.count(PODCAST) else 0}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 28, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': _types.count(NORMAL) + (4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(PODCAST)), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST) + _types.count(1) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in (1, 2) else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 29, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + (4 * len(tracks_dics)), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + (4 * len(playlists_dics_and_indexes)), 'number_of_all_playlists': 4294967295 if _types.count(NORMAL) == 0 else 1, 'flag1': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'flag2': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_audiobook_playlists': _types.count(AUDIOBOOK), 'flag3': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_podcast_playlists': _types.count(PODCAST)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + (4 * len(indexes))\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 260, "s": 30, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + (4 * len(tracks_dics)), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + (4 * len(playlists_dics_and_indexes)), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(MASTER) + _types.count(NORMAL) == 0 else _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) + _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL), 'flag3': 4294967295 if _types.count(Podcast) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_podcast_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + (4 * len(indexes))\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 261, "s": 0, "got": "def create_plan(existing_users=None, proposed_users=None, purge_undefined=None, protected_users=None, allow_non_unique_id=True, manage_home=True, manage_keys=True):\n \"\"\"pass\"\"\"\n plan = list()\n proposed_usernames = list()\n if not purge_undefined:\n purge_undefined = constants.PURGE_UNDEFINED\n if not protected_users:\n protected_users = constants.PROTECTED_USERS\n if not allow_non_unique_id:\n allow_non_unique_id = constants.ALLOW_NON_UNIQUE_ID\n for proposed_user in proposed_users:\n proposed_usernames.append(proposed_user.name)\n user_matching_name = existing_users.describe_users(users_filter=dict(name=proposed_user.name))\n user_matching_id = get_user_by_uid(uid=proposed_user.uid, users=existing_users)\n if not allow_non_unique_id and user_matching_id and (not user_matching_name):\n plan.append(dict(action='fail', error='uid_clash', proposed_user=proposed_user, state='existing', result=None))\n elif not user_matching_name:\n plan.append(dict(action='add', proposed_user=proposed_user, state='missing', result=None, manage_home=manage_home, manage_keys=manage_keys))\n else:\n user_comparison = compare_user(passed_user=proposed_user, user_list=existing_users)\n if user_comparison.get('result'):\n plan.append(dict(action='update', proposed_user=proposed_user, state='existing', user_comparison=user_comparison, manage_home=manage_home, manage_keys=manage_keys))\n if purge_undefined:\n for existing_user in existing_users:\n if existing_user.name not in proposed_usernames and existing_user.name not in protected_users:\n plan.append(dict(action='delete', username=existing_user.name, state='existing', manage_home=manage_home, manage_keys=manage_keys))\n return plan"} +{"i": 261, "s": 1, "got": "def create_plan(existing_users=None, proposed_users=None, purge_undefined=None, protected_users=None, allow_non_unique_id=None, manage_home=True, manage_keys=True):\n \"\"\"pass\"\"\"\n plan = list()\n proposed_usernames = list()\n if not purge_undefined:\n purge_undefined = constants.PURGE_UNDEFINED\n if not protected_users:\n protected_users = constants.PROTECTED_USERS\n if not allow_non_unique_id:\n allow_non_unique_id = constants.ALLOW_NON_UNIQUE_ID\n for proposed_user in proposed_users:\n proposed_usernames.append(proposed_user.name)\n user_matching_name = existing_users.describe_users(users_filter=dict(name=proposed_user.name))\n user_matching_id = get_user_by_uid(uid=proposed_user.uid, users=existing_users)\n if not allow_non_unique_id and user_matching_id and (not user_matching_name):\n plan.append(dict(action='fail', error='uid_clash', proposed_user=proposed_user, state=u'existing', result=None))\n elif not user_matching_name:\n plan.append(dict(action='add', proposed_user=proposed_user, state=u'missing', result=None, manage_home=manage_home, manage_keys=manage_keys))\n else:\n user_comparison = compare_user(passed_user=proposed_user, user_list=existing_users)\n if user_comparison.get('result'):\n plan.append(dict(action='update', proposed_user=proposed_user, state=u'existing', user_comparison=user_comparison, manage_home=manage_home, manage_keys=manage_keys))\n if purge_undefined:\n for existing_user in existing_users:\n if not (existing_user.name not in proposed_usernames) or (not (existing_user.name not in protected_users)):\n plan.append(dict(action='delete', username=existing_user.name, state=u'existing', manage_home=manage_home, manage_keys=manage_keys))\n return plan"} +{"i": 261, "s": 2, "got": "def create_plan(existing_users=None, proposed_users=None, purge_undefined=None, protected_users=None, allow_non_unique_id=True, manage_home=True, manage_keys=True):\n \"\"\"pass\"\"\"\n plan = list()\n proposed_usernames = list()\n if not purge_undefined:\n purge_undefined = constants.PURGE_UNDEFINED\n if not protected_users:\n protected_users = constants.PROTECTED_USERS\n if not allow_non_unique_id:\n allow_non_unique_id = constants.ALLOW_NON_UNIQUE_ID\n for proposed_user in proposed_users:\n proposed_usernames.append(proposed_user.name)\n user_matching_name = existing_users.describe_users(users_filter=dict(name=proposed_user.name))\n user_matching_id = get_user_by_uid(uid=proposed_user.uid, users=existing_users)\n if not allow_non_unique_id and user_matching_id and (not user_matching_name):\n plan.append(dict(action='fail', error='uid_clash', proposed_user=proposed_user, state='existing', result=None))\n elif not user_matching_name:\n plan.append(dict(action='add', proposed_user=proposed_user, state='missing', result=None, manage_home=manage_home, manage_keys=manage_keys))\n else:\n user_comparison = compare_user(passed_user=proposed_user, user_list=existing_users)\n if user_comparison.get('result'):\n plan.append(dict(action='update', proposed_user=proposed_user, state='existing', user_comparison=user_comparison, manage_home=manage_home, manage_keys=manage_keys))\n if purge_undefined:\n for existing_user in existing_users:\n if existing_user.name not in proposed_usernames and existing_user.name not in protected_users:\n plan.append(dict(action='delete', username=existing_user.name, state='existing', manage_home=manage_home, manage_keys=manage_keys))\n return plan"} +{"i": 261, "s": 3, "got": "def create_plan(existing_users=None, proposed_users=None, purge_undefined=None, protected_users=None, allow_non_unique_id=True, manage_home=True, manage_keys=True):\n \"\"\"pass\"\"\"\n plan = list()\n proposed_usernames = list()\n if not purge_undefined:\n purge_undefined = constants.PURGE_UNDEFINED\n if not protected_users:\n protected_users = constants.PROTECTED_USERS\n if not allow_non_unique_id:\n allow_non_unique_id = constants.ALLOW_NON_UNIQUE_ID\n for proposed_user in proposed_users:\n proposed_usernames.append(proposed_user.name)\n user_matching_name = existing_users.describe_users(users_filter=dict(name=proposed_user.name))\n user_matching_id = get_user_by_uid(uid=proposed_user.uid, users=existing_users)\n if not allow_non_unique_id and user_matching_id and (not user_matching_name):\n plan.append(dict(action='fail', error='uid_clash', proposed_user=proposed_user, state='existing', result=None))\n elif not user_matching_name:\n plan.append(dict(action='add', proposed_user=proposed_user, state='missing', result=None, manage_home=manage_home, manage_keys=manage_keys))\n else:\n user_comparison = compare_user(passed_user=proposed_user, user_list=existing_users)\n if user_comparison.get('result'):\n plan.append(dict(action='update', proposed_user=proposed_user, state='existing', user_comparison=user_comparison, manage_home=manage_home, manage_keys=manage_keys))\n if purge_undefined:\n for existing_user in existing_users:\n if existing_user.name not in proposed_usernames and existing_user.name not in protected_users:\n plan.append(dict(action='delete', username=existing_user.name, state='existing', manage_home=manage_home, manage_keys=manage_keys))\n return plan"} +{"i": 261, "s": 4, "got": "def create_plan(existing_users=None, proposed_users=None, purge_undefined=None, protected_users=None, allow_non_unique_id=None, manage_home=True, manage_keys=True):\n \"\"\"pass\"\"\"\n plan = list()\n proposed_usernames = list()\n if not purge_undefined:\n purge_undefined = constants.PURGE_UNDEFINED\n if not protected_users:\n protected_users = constants.PROTECTED_USERS\n if not allow_non_unique_id:\n allow_non_unique_id = constants.ALLOW_NON_UNIQUE_ID\n for proposed_user in proposed_users:\n proposed_usernames.append(proposed_user.name)\n user_matching_name = existing_users.describe_users(users_filter=dict(name=proposed_user.name))\n user_matching_id = get_user_by_uid(uid=proposed_user.uid, users=existing_users)\n if not allow_non_unique_id and user_matching_id and (not user_matching_name):\n plan.append(dict(action='fail', error='uid_clash', proposed_user=proposed_user, state='existing', result=None))\n elif not user_matching_name:\n plan.append(dict(action='add', proposed_user=proposed_user, state='missing', result=None, manage_home=manage_home, manage_keys=manage_keys))\n else:\n user_comparison = compare_user(passed_user=proposed_user, user_list=existing_users)\n if user_comparison.get('result'):\n plan.append(dict(action='update', proposed_user=proposed_user, state='existing', user_comparison=user_comparison, manage_home=manage_home, manage_keys=manage_keys))\n if purge_undefined:\n for existing_user in existing_users:\n if existing_user.name not in proposed_usernames and existing_user.name not in protected_users:\n plan.append(dict(action='delete', username=existing_user.name, state='existing', manage_home=manage_home, manage_keys=manage_keys))\n return plan"} +{"i": 278, "s": 0, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if not method in ('get', 'patch', 'post'):\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))[0]\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, 'Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n raise FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__ + '.' + exc.__class__.__qualname__, url=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__ + '.' + exc.__class__.__qualname__, url=url)\n raise\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 1, "got": "def send_http(session, method='get', url=None, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if not method in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = await getattr(session, method)(url, **kwargs)\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), url=url)\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 2, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if not method in ('get', 'patch', 'post'):\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = await getattr(session, method)(url, **kwargs)\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, code='Non-retryable response code', message='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=exc, url=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__ + '.' + exc.__class__.__qualname__, url=url)\n finally:\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 3, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if not method in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))[0]\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), url=url)\n attempt -= 1\n return None"} +{"i": 278, "s": 4, "got": "def send_http(session, method='get', url='', *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = await getattr(session, method)(url, **kwargs)\n if response.status == 200:\n return (await fn(response))\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__,'.%s' % exc.__class__.__qualname__, url=url)\n else:\n attempt -= 1\n return None"} +{"i": 278, "s": 5, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if not method in ['get', 'patch', 'post']:\n raise ValueError\n elif retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))[0]\n if response.status == 200:\n return (await fn(response))\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, 'Non-retryable response code', 'aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__.'%s'.format(exc.__class__.__qualname__), url=url)\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 6, "got": "def send_http(session, method='get', url='', *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n elif retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))[0]\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, 'Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=exc, url=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__+'.'+exc.__class__.__qualname__, url=url)\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 7, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ('get', 'patch', 'post'):\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))[0]\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, 'Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n raise\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), url=url)\n raise\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 8, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = await getattr(session, method)(url, **kwargs)\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, 'Non-retryable response code', 'aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=exc, url=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__.'%s.%s' % (exc.__class__.__qualname__,), url=url)\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 9, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))[0]\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=exc, url=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__ + '.' + exc.__class__.__qualname__, url=url)\n finally:\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 10, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = await getattr(session, method)(url, **kwargs)\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n exc = None\n del exc\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), url=url)\n exc = None\n del exc\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 11, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = await getattr(session, method)(url, **kwargs)\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, code='Non-retryable response code', message='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__.'%s'% exc.__class__.__qualname__, url=url)\n else:\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 12, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if not method in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))[0]\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, code='Non-retryable response code', message='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__('.' + exc.__class__.__qualname__), url=url)\n attempt -= 1\n return None"} +{"i": 278, "s": 13, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if not method in ('get', 'patch', 'post'):\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n continue\n try:\n response = (await getattr(session, method)(url, **kwargs))\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, 'Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=exc, url=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__+'.'+exc.__class__.__qualname__, url=url)\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 14, "got": "def send_http(session, method='get', url='', *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))[0]\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised=aiohttp.ClientResponseError, url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=exc, url=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc, url=url)\n attempt -= 1\n return None"} +{"i": 278, "s": 15, "got": "def send_http(session, method='get', url='', *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ('get', 'patch', 'post'):\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = await getattr(session, method)(url, **kwargs)\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=exc, url=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__ + '.' + exc.__class__.__qualname__, url=url)\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 16, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n continue\n try:\n response = (await getattr(session, method)(url, **kwargs)) # pylint: disable=unformatted-string-literal\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, 'Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n raise\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__.'.%s' % (exc.__class__.__qualname__,), url=url)\n raise\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 17, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if not method in ('get', 'patch', 'post'):\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, 'Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), url=url)\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 18, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))[0]\n if response.status == 200:\n return await fn(response)\n if response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=exc, url=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__ + '.' + exc.__class__.__qualname__, url=url)\n else:\n attempt -= 1\n if not raised_exc and attempt != 0:\n continue"} +{"i": 278, "s": 19, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ('get', 'patch', 'post'):\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))[0]\n if response.status == 200:\n return (await fn(response))\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, 'Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=exc, url=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__+'.'+exc.__class__.__qualname__, url=url)\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 20, "got": "def send_http(session, method='get', url=None, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ('get', 'patch', 'post'):\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = await getattr(session, method)(url, **kwargs)\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, 'Non-retryable response code', 'aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__.'%s' % exc.__class__.__qualname__)\n finally:\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 21, "got": "def send_http(session, method='get', url='', *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ('get', 'patch', 'post'):\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n raise\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), url=url)\n raise\n attempt -= 1\n return None"} +{"i": 278, "s": 22, "got": "def send_http(session, method='get', url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ('get', 'patch', 'post'):\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n continue\n try:\n response = (await getattr(session, method)(url, **kwargs))[0]\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__,'%s' % exc.__class__.__qualname__, url=url)\n finally:\n attempt -= 1\n if raised_exc:\n raise raised_exc\n return None"} +{"i": 278, "s": 23, "got": "def send_http(session, method='get', url='', *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, 'Non-retryable response code', 'aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__ + '.' + exc.__class__.__qualname__, url=url)\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 24, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n elif retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n raise\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), url=url)\n raise\n attempt -= 1"} +{"i": 278, "s": 25, "got": "def send_http(session, method='get', url='', *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))[0]\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__ + '.' + exc.__class__.__qualname__, url=url)\n else:\n attempt -= 1\n return None"} +{"i": 278, "s": 26, "got": "def send_http(session, method='get', url='', *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = await getattr(session, method)(url, **kwargs)\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n raise\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), url=url)\n raise\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 27, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if not method in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = await getattr(session, method)(url, **kwargs)\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=exc, url=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__ + '.' + exc.__class__.__qualname__, url=url)\n else:\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 28, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs)) # type: ignore\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), url=url)\n else:\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 29, "got": "def send_http(session, method='get', url='', *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if not method in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = await getattr(session, method)(url, **kwargs)\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(response.status, 'Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), url=url)\n finally:\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 278, "s": 30, "got": "def send_http(session, method='get', url='', *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ('get', 'patch', 'post'):\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n else:\n try:\n response = await getattr(session, method)(url, **kwargs)\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=exc, url=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__ + '.' + exc.__class__.__qualname__, url=url)\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 279, "s": 0, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is not getattr(p, 'date', None), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 1, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: not p != u'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, u'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, u'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get(u'authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is None and getattr(p, 'date', None) is None, self.context.get(u'DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], u'modified', getattr(articles_sorted[0], u'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 2, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: not getattr(p, 'index'), self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: not getattr(p, 'index'), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 3, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is not getattr(p, 'date', None), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 4, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is not None and getattr(p, 'date', None) is not None, self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 5, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if not index_reference is None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is None and getattr(p, 'date', None) is None, self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 6, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p, d: p != 'index', self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 7, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != u'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: p != u'index', self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, u'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 8, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: p != 'index', self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 9, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is not getattr(p, 'date', None), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 10, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is not getattr(p, 'date', None), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 11, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: p != 'index', self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 12, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is not getattr(p, 'date', None), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 13, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is not getattr(p, 'date', None), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 14, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is not getattr(p, 'date', None), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 15, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: p != 'index', self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 16, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 17, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is None and getattr(p, 'date', None) is None, self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 18, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is None or getattr(p, 'date', None) is None, self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 19, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is None and getattr(p, 'date', None) is None, self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 20, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: not getattr(p, 'modified', None) is None and getattr(p, 'date', None) is None, self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in filter(lambda p: not getattr(p, 'modified', None) is None and getattr(p, 'date', None) is None, self.context.get('DIRECT_TEMPLATES')):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 21, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: p != 'index', self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 22, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is not None and getattr(p, 'date', None) is not None, self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 23, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is None and getattr(p, 'date', None) is None, self.context.get('DIRECT_TEMPLATES')):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 24, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if not index_reference is None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is not getattr(p, 'date', None), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 25, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is not None and getattr(p, 'date', None) is None, self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 26, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: p != 'index', self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 27, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: not (p != 'index'), self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: not (p != 'index'), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 28, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 29, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: p != 'index', self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 279, "s": 30, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 281, "s": 0, "got": "def __process_url_wrapper_elements(self, elements):\n \"\"\"pass\"\"\"\n urls = ''\n for url_wrapper, articles in elements:\n urls += self.__create_url_node_for_content(url_wrapper, 'others', url=urljoin(self.url_site, url_wrapper.url), modification_time=self.__get_date_key(sorted(articles, key=self.__get_date_key, reverse=True)[0]))\n return urls"} +{"i": 282, "s": 0, "got": "def __create_url_node_for_content(self, content, content_type, url=None, modification_time=None):\n \"\"\"pass\"\"\"\n loc = url\n if loc is None:\n loc = urljoin(self.url_site, self.context.get('ARTICLE_URL').format(**content.url_format))\n lastmod = None\n if modification_time is not None:\n lastmod = modification_time.strftime('%Y-%m-%d')\n elif content is not None and getattr(content, 'modified', None) is not None:\n lastmod = getattr(content, 'modified').strftime('%Y-%m-%d')\n elif getattr(content, 'date', None) is not None:\n lastmod = getattr(content, 'date').strftime('%Y-%m-%d')\n output = '{}'.format(loc)\n if lastmod is not None:\n output += '\\n{}'.format(lastmod)\n output += '\\n{}'.format(self.settings.get('changefrequencies').get(content_type))\n output += '\\n{:.2f}'.format(self.settings.get('priorities').get(content_type))\n return self.template_url.format(output)"} +{"i": 282, "s": 1, "got": "def __create_url_node_for_content(self, content, content_type=None, url=None, modification_time=None):\n \"\"\"pass\"\"\"\n loc = url\n if loc is None:\n loc = urljoin(self.url_site, self.context.get('ARTICLE_URL').format(**content.url_format))\n lastmod = None\n if modification_time is not None:\n lastmod = modification_time.strftime('%Y-%m-%d')\n elif content is not None:\n if getattr(content, 'modified', None) is not None:\n lastmod = getattr(content, 'modified').strftime('%Y-%m-%d')\n elif getattr(content, 'date', None) is not None:\n lastmod = getattr(content, 'date').strftime('%Y-%m-%d')\n output = '{}'.format(loc)\n if lastmod is not None:\n output += '\\n{}'.format(lastmod)\n output += '\\n{}'.format(self.settings.get('changefrequencies').get(content_type))\n output += '\\n{:.2f}'.format(self.settings.get('priorities').get(content_type))\n return self.template_url.format(output)"} +{"i": 282, "s": 2, "got": "def __create_url_node_for_content(self, content, content_type, url=None, modification_time=None):\n \"\"\"pass\"\"\"\n loc = url\n if loc is None:\n loc = urljoin(self.url_site, self.context.get('ARTICLE_URL').format(**content.url_format))\n lastmod = None\n if modification_time is not None:\n lastmod = modification_time.strftime('%Y-%m-%d')\n elif content is not None:\n if getattr(content, 'modified', None) is not None:\n lastmod = getattr(content, 'modified').strftime('%Y-%m-%d')\n elif getattr(content, 'date', None) is not None:\n lastmod = getattr(content, 'date').strftime('%Y-%m-%d')\n output = '{}'.format(loc)\n if lastmod is not None:\n output += '\\n{}'.format(lastmod)\n output += '\\n{}'.format(self.settings.get('changefrequencies').get(content_type))\n output += '\\n{:.2f}'.format(self.settings.get('priorities').get(content_type))\n return self.template_url.format(output)"} +{"i": 298, "s": 0, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in ('.', '!', '?', '\u2026', '\u00bb'):\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n elif not tok[-1] != '.':\n continue\n elif tok1[0] == '(':\n continue\n elif tok in ABBRS:\n continue\n else:\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 1, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n continue\n elif tok[-1] in ['.!', '?', '\u2026', '\u00bb']:\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n if tok[-1] != '.' and (not tok1.isupper()) and (tok not in ABBRS):\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 2, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif not tok[-1] in ['.', '!', '?', '\u2026', '\u00bb']:\n continue\n else:\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper() and (not tok1.isupper()) and (tok[-1] != '.') and (not tok1[0] == '(') and (tok in ABBRS):\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 3, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in ['.', '!', '?', '\u2026', '\u00bb']:\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n if not tok[-1] != '.':\n continue\n if not tok1[0] == '(':\n continue\n if tok in ABBRS:\n continue\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 4, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n continue\n if tok[-1] in ('.', '!', '?', '\u2026', '\u00bb'):\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n elif not tok[-1] != '.' and (not tok1[0] == '(') and (tok in ABBRS):\n continue\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 5, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in [u'.', u'!', u'?', u'\u2026', u'\u00bb']:\n tok1 = tok[u'search([.!?\u2026\u00bb]', tok).start() - 1\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n elif not tok[-1] != '.':\n continue\n elif not tok1[0] == u'(' and (not tok in ABBRS):\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 6, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n continue\n if tok[-1] in ['.', '!', '?', u'\u2026', u'\u00bb']:\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n elif not tok[-1] != '.' and (not tok1[0] == '(') and (tok in ABBRS):\n continue\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 7, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif not tok[-1] in ['.', '!', '?', '\u2026', '\u00bb']:\n continue\n else:\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if not next_tok[0].isupper():\n continue\n elif tok1.isupper():\n continue\n elif tok[-1] != '.':\n continue\n elif tok1[0] == '(':\n continue\n else:\n if tok in ABBRS:\n continue\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 8, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in ('.', '!', '?', '\u2026', '\u00bb'):\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n if not tok[-1] != '.':\n continue\n if not tok1[0] == '(':\n continue\n if tok in ABBRS:\n continue\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 9, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in ['.', '!', '?', '\u2026', u'\u00bb']:\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n elif tok[-1] != '.' or tok1[0] == '(':\n continue\n if tok in ABBRS:\n continue\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 10, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in ('.', '!', '?', '\u2026', '\u00bb'):\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n elif not tok[-1] != '.':\n continue\n elif not tok1[0] == '(':\n continue\n elif tok in ABBRS:\n continue\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 11, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in ('.', '!', '?', '\u2026', '\u00bb'):\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if not (next_tok[0].isupper() and tok1.isupper()) and (tok[-1] != '.') and (not tok1[0] == '('):\n if tok in ABBRS:\n pass\n else:\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 12, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in ('.', '!', '?', '\u2026', '\u00bb'):\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n elif not (tok[-1] != '.' or tok1[0] == '('):\n if tok in ABBRS:\n continue\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 13, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in ['.', '!', '?', '\u2026', '\u00bb']:\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper() and (not tok1.isupper()) and (tok[-1] != '.') and (tok1[0] == '(') and (tok in ABBRS):\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 14, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n continue\n if tok[-1] in ['.', '!', '?', '\u2026', '\u00bb']:\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n if tok[-1] != '.':\n continue\n if not tok1[0] == '(' and (not tok in ABBRS):\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 15, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n continue\n if tok[-1] in ('.', '!', '?', u'\u2026', u'\u00bb'):\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if not next_tok[0].isupper():\n continue\n if tok1.isupper() or tok[-1] != '.' or (tok1[0] == '('):\n continue\n if tok in ABBRS:\n continue\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 16, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in ['.', '!', '?', '\u2026', '\u00bb']:\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper() and (not tok1.isupper()) and (tok[-1] != '.') and (not tok1[0] == '(') and (tok in ABBRS):\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 17, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in ('.', '!', '?', '\u2026', '\u00bb'):\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n elif not tok[-1] != '.':\n continue\n elif tok1[0] == '(':\n continue\n elif tok in ABBRS:\n continue\n else:\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 18, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in ('.', '!', '?', '\u2026', '\u00bb'):\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n if not tok[-1] != '.' and (not tok1[0] == '(') and (tok in ABBRS):\n continue\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 19, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in ['.', '!', '?', '\u2026', '\u00bb']:\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n pass\n elif not tok1.isupper() and tok[-1] != '.' and (not tok1[0] == '(') and (tok in ABBRS):\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 20, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n continue\n elif not tok[-1] in ('.', '!', '?', u'\u2026', u'\u00bb'):\n continue\n else:\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n elif not tok1.isupper():\n continue\n elif tok[-1] != '.':\n continue\n elif tok1[0] == '(':\n continue\n if tok in ABBRS:\n continue\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 298, "s": 21, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n continue\n if tok[-1] in ('.', '!', '?', '\u2026', '\u00bb'):\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if not next_tok[0].isupper():\n continue\n if tok1.isupper():\n continue\n if tok[-1] != '.':\n continue\n if tok1[0] == '(':\n continue\n if tok in ABBRS:\n continue\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 320, "s": 0, "got": "def get_summary(list_all=[], **kwargs):\n \"\"\"pass\"\"\"\n all_summary = []\n for module in list_all:\n summary = {'module_name': module['Name'], 'show_all': kwargs.get('show_all', True), 'project_name': kwargs.get('proj_name', 'TestProject'), 'home_page': kwargs.get('home_page', __about__.HOME_PAGE), 'start_time': '', 'end_time': '', 'duration_seconds': len(module['TestCases']), 'total_case_num': 0, 'pass_cases_num': 0, 'fail_cases_num': 0, 'details': []}\n for case in module['TestCases']:\n case_detail = {}\n case_detail['linkurl'] = './caselogs/%s_%s.log' % (case['case_name'], case['exec_date'])\n if case['status'].lower() == 'pass':\n summary['pass_cases_num'] += 1\n case_detail['c_style'] = 'tr_pass'\n else:\n summary['fail_cases_num'] += 1\n case_detail['c_style'] = 'tr_fail'\n case_detail.update(case)\n summary['details'].append(case_detail)\n try:\n st = module['TestCases'][0].get('start_at')\n et = module['TestCases'][-1].get('end_at')\n summary['start_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(st))\n summary['end_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(et))\n summary['duration_seconds'] = float('%.2f' % (et - st))\n except Exception as _:\n logger.log_warning(\"Will set 'start_at' and 'end_at' to 'None'\")\n summary['start_time'], summary['end_time'], summary['duration_seconds'] = (None, None, None)\n if summary['fail_cases_num'] > 0:\n summary['dict_report'] = {'result': 0, 'message': 'failure', 'pass': summary['pass_cases_num'], 'fail': summary['fail_cases_num']}\n else:\n summary['dict_report'] = {'result': 1, 'message': 'success', 'pass': summary['pass_cases_num'], 'fail': summary['fail_cases_num']}\n all_summary.append(summary)\n return all_summary"} +{"i": 320, "s": 1, "got": "def get_summary(list_all=[], **kwargs):\n \"\"\"pass\"\"\"\n all_summary = []\n for module in list_all:\n summary = {'module_name': module['Name'], 'show_all': kwargs.get('show_all', True), 'project_name': kwargs.get('proj_name', 'TestProject'), 'home_page': kwargs.get('home_page', __about__.HOME_PAGE), 'start_time': '', 'end_time': '', 'duration_seconds': 0, 'total_case_num': len(module['TestCases']), 'pass_cases_num': 0, 'fail_cases_num': 0, 'details': []}\n for case in module['TestCases']:\n case_detail = {}\n case_detail['linkurl'] = './caselogs/%s_%s.log' % (case['case_name'], case['exec_date'])\n if case['status'].lower() == 'pass':\n summary['pass_cases_num'] += 1\n case_detail['c_style'] = 'tr_pass'\n else:\n summary['fail_cases_num'] += 1\n case_detail['c_style'] = 'tr_fail'\n case_detail.update(case)\n summary['details'].append(case_detail)\n try:\n st = module['TestCases'][0].get('start_at')\n et = module['TestCases'][-1].get('end_at')\n summary['start_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(st))\n summary['end_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(et))\n summary['duration_seconds'] = float('%.2f' % (et - st))\n except Exception as _:\n logger.log_warning(\"Will set 'start_at' and 'end_at' to 'None'\")\n summary['start_time'], summary['end_time'], summary['duration_seconds'] = (None, None, None)\n if summary['fail_cases_num'] > 0:\n summary['dict_report'] = {'result': 0, 'message': 'failure', 'pass': summary['pass_cases_num'], 'fail': summary['fail_cases_num']}\n else:\n summary['dict_report'] = {'result': 1, 'message': 'success', 'pass': summary['pass_cases_num'], 'fail': summary['fail_cases_num']}\n all_summary.append(summary)\n return all_summary"} +{"i": 320, "s": 2, "got": "def get_summary(list_all=[], **kwargs):\n \"\"\"pass\"\"\"\n all_summary = []\n for module in list_all:\n summary = {'module_name': module['Name'], 'show_all': kwargs.get('show_all', True), 'project_name': kwargs.get('proj_name', 'TestProject'), 'home_page': kwargs.get('home_page', __about__.HOME_PAGE), 'start_time': '', 'end_time': '', 'duration_seconds': '', 'total_case_num': len(module['TestCases']), 'pass_cases_num': 0, 'fail_cases_num': 0, 'details': []}\n for case in module['TestCases']:\n case_detail = {}\n case_detail['linkurl'] = './caselogs/%s_%s.log' % (case['case_name'], case['exec_date'])\n if case['status'].lower() == 'pass':\n summary['pass_cases_num'] += 1\n case_detail['c_style'] = 'tr_pass'\n else:\n summary['fail_cases_num'] += 1\n case_detail['c_style'] = 'tr_fail'\n case_detail.update(case)\n summary['details'].append(case_detail)\n try:\n st = module['TestCases'][0].get('start_at')\n et = module['TestCases'][-1].get('end_at')\n summary['start_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(st))\n summary['end_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(et))\n summary['duration_seconds'] = float('%.2f' % (et - st))\n except Exception as _:\n logger.log_warning(\"Will set 'start_at' and 'end_at' to 'None'\")\n summary['start_time'], summary['end_time'], summary['duration_seconds'] = (None, None, None)\n if summary['fail_cases_num'] > 0:\n summary['dict_report'] = {'result': 0, 'message': 'failure', 'pass': summary['pass_cases_num'], 'fail': summary['fail_cases_num']}\n else:\n summary['dict_report'] = {'result': 1, 'message': 'success', 'pass': summary['pass_cases_num'], 'fail': summary['fail_cases_num']}\n all_summary.append(summary)\n return all_summary"} +{"i": 321, "s": 0, "got": "def add_report_data(list_all=[], module_name='TestModule', **kwargs):\n \"\"\"pass\"\"\"\n start_at = kwargs.get('start_at')\n case_name = kwargs.get('case_name', 'TestCase')\n raw_case_name = kwargs.get('raw_case_name', 'TestCase')\n exec_date_time = time.localtime(start_at)\n execdate = time.strftime('%Y-%m-%d', exec_date_time)\n exectime = time.strftime('%H:%M:%S', exec_date_time)\n _case_report = {'resp_tester': kwargs.get('resp_tester', 'administrator'), 'tester': kwargs.get('tester', 'administrator'), 'case_name': case_name, 'raw_case_name': raw_case_name, 'status': kwargs.get('status', 'Pass'), 'exec_date': execdate, 'exec_time': exectime, 'start_at': start_at, 'end_at': kwargs.get('end_at')}\n for module in list_all:\n if module_name != module['Name']:\n continue\n for case in module['TestCases']:\n if raw_case_name == case['raw_case_name']:\n case.update(_case_report)\n return list_all\n module['TestCases'].append(_case_report)\n return list_all\n list_all.append({'Name': module_name, 'TestCases': [_case_report]})\n return list_all"} +{"i": 325, "s": 0, "got": "def load_stats(self, cache=None, wait=None):\n \"\"\"pass\"\"\"\n if cache is None:\n cache = not self.debug\n if wait is None:\n wait = self.debug\n if not (cache and self._stats) or (wait and self._stats.get('status') == 'compiling'):\n self._stats = self._load_stats()\n start = time.time()\n while not wait or self._stats.get('status') == 'compiling':\n if self.timeout:\n if time.time() - start > self.timeout:\n raise RuntimeError('Webpack {0!r} timed out while compiling'.format(self.stats_file.path))\n time.sleep(0.1)\n return self._stats"} +{"i": 325, "s": 1, "got": "def load_stats(self, cache=None, wait=None):\n \"\"\"pass\"\"\"\n if cache is None:\n cache = not self.debug\n if wait is None:\n wait = self.debug\n if not (cache and self._stats is not None):\n self._stats = self._load_stats()\n start = time.time()\n while wait and self._stats.get('status') == 'compiling':\n if self.timeout and time.time() - start > self.timeout:\n raise RuntimeError('Webpack {0!r} timed out while compiling'.format(self.stats_file.path))\n time.sleep(0.1)\n self._stats = self._load_stats()\n return self._stats"} +{"i": 333, "s": 0, "got": "def get_client(self):\n \"\"\"pass\"\"\"\n if self._ssh is None:\n self._connect()\n return self._ssh\n else:\n try:\n chan = self._ssh.get_transport().open_session()\n except (socket.error, paramiko.SSHException):\n logger.warning('Lost connection, reconnecting...')\n self._ssh.close()\n self._connect()\n return self._ssh\n chan.close()\n return self._ssh"} +{"i": 333, "s": 1, "got": "def get_client(self):\n \"\"\"pass\"\"\"\n if self._ssh is None:\n self._connect()\n else:\n pass\n try:\n chan = self._ssh.get_transport().open_session()\n except (socket.error, paramiko.SSHException):\n logger.warning('Lost connection, reconnecting...')\n self._ssh.close()\n self._connect()\n return self._ssh\n chan.close()\n return self._ssh"} +{"i": 333, "s": 2, "got": "def get_client(self):\n \"\"\"pass\"\"\"\n if self._ssh is None:\n self._connect()\n return self._ssh\n try:\n chan = self._ssh.get_transport().open_session()\n except (socket.error, paramiko.SSHException):\n logger.warning('Lost connection, reconnecting...')\n self._ssh.close()\n self._connect()\n else:\n chan.close()\n return self._ssh"} +{"i": 335, "s": 0, "got": "def workon(ctx, issue_id, new, base_branch):\n \"\"\"pass\"\"\"\n lancet = ctx.obj\n if not (issue_id or new):\n raise click.UsageError('Provide either an issue ID or the --new flag.')\n if issue_id and new:\n raise click.UsageError('Provide either an issue ID or the --new flag, but not both.')\n if new:\n summary = click.prompt('Issue summary')\n issue = create_issue(lancet, summary=summary, add_to_active_sprint=True)\n else:\n issue = get_issue(lancet, issue_id)\n username = lancet.tracker.whoami()\n active_status = lancet.config.get('tracker', 'active_status')\n if not base_branch:\n base_branch = lancet.config.get('repository', 'base_branch')\n branch = get_branch(lancet, issue, base_branch)\n transition = get_transition(ctx, lancet, issue, active_status)\n assign_issue(lancet, issue, username, active_status)\n set_issue_status(lancet, issue, active_status, transition)\n with taskstatus('Checking out working branch') as ts:\n lancet.repo.checkout(branch.name)\n ts.ok('Checked out working branch based on \"{}\"'.format(base_branch))\n with taskstatus('Starting harvest timer') as ts:\n lancet.timer.start(issue)\n ts.ok('Started harvest timer')"} +{"i": 342, "s": 0, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': os.path.join(p, 'testcase'), 'case': os.path.join(p, 'data'), 'data': os.path.join(p, 'buffer'), 'buffer': os.path.join(p, 'resource'), 'resource': os.path.join(p, 'tools'), 'tools': os.path.join(p, 'result'), 'rst': os.path.join(p, 'result', 'testcase'), 'rst_log': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 1, "got": "def init_project_env(subject, proj_path='Automation', sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 2, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 3, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 4, "got": "def init_project_env(subject, proj_path='Automation', sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': os.path.join(p, 'testcase'), 'case': os.path.join(p, 'data'), 'data': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf\n proj_path = executable_file_path"} +{"i": 342, "s": 5, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': os.path.join(p, 'testcase'), 'case': os.path.join(p, 'data'), 'data': os.path.join(p, 'buffer'), 'buffer': os.path.join(p, 'resource'), 'resource': os.path.join(p, 'tools'), 'tools': os.path.join(p, 'result'), 'rst': os.path.join(p, 'result', 'testcase'), 'rst_log': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''"} +{"i": 342, "s": 6, "got": "def init_project_env(subject, proj_path='Automation', sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n return proj_conf\n else:\n print('')\n return proj_conf"} +{"i": 342, "s": 7, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n else:\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 8, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': os.path.join(p, 'testcase'), 'case': os.path.join(p, 'data'), 'data': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n pass\n return proj_conf"} +{"i": 342, "s": 9, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 10, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': os.path.join(p, 'testcase'), 'case': os.path.join(p, 'data'), 'data': os.path.join(p, 'buffer'), 'buffer': os.path.join(p, 'resource'), 'resource': os.path.join(p, 'tools'), 'tools': os.path.join(p, 'result'), 'rst': os.path.join(p, 'result', 'testcase'), 'rst_log': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 11, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': os.path.join(p, 'testcase'), 'case': os.path.join(p, 'data'), 'data': os.path.join(p, 'buffer'), 'buffer': os.path.join(p, 'resource'), 'resource': os.path.join(p, 'tools'), 'tools': os.path.join(p, 'result'), 'rst': os.path.join(p, 'result', 'testcase'), 'rst_log': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf\n raise executable_file_path"} +{"i": 342, "s": 12, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 13, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 14, "got": "def init_project_env(subject, proj_path='Automation', sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 15, "got": "def init_project_env(subject, proj_path='Automation', sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n return proj_conf\n else:\n print('')\n return proj_conf"} +{"i": 342, "s": 16, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 17, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': os.path.join(p, 'testcase'), 'case': os.path.join(p, 'data'), 'data': os.path.join(p, 'buffer'), 'buffer': os.path.join(p, 'resource'), 'resource': os.path.join(p, 'tools'), 'tools': os.path.join(p, 'result'), 'rst': os.path.join(p, 'result', 'testcase'), 'rst_log': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n pass\n return proj_conf"} +{"i": 342, "s": 18, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': os.path.join(p, 'testcase'), 'case': os.path.join(p, 'data'), 'data': os.path.join(p, 'buffer'), 'buffer': os.path.join(p, 'resource'), 'resource': os.path.join(p, 'tools'), 'tools': os.path.join(p, 'result'), 'rst': os.path.join(p, 'result', 'testcase'), 'rst_log': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n pass\n return proj_conf"} +{"i": 342, "s": 19, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 20, "got": "def init_project_env(subject, proj_path='Automation', sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': os.path.join(p, 'testcase'), 'case': os.path.join(p, 'data'), 'data': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 21, "got": "def init_project_env(subject, proj_path='Automation', sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 22, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': os.path.join(p, 'case'), 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 23, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 24, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': os.path.join(p, 'testcase'), 'case': os.path.join(p, 'data'), 'data': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 25, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 26, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 342, "s": 27, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n pass\n return proj_conf"} +{"i": 342, "s": 28, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf\n proj_path = ''\n return proj_conf"} +{"i": 342, "s": 29, "got": "def init_project_env(subject, proj_path='Automation', sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': os.path.join(p, 'testcase'), 'case': os.path.join(p, 'data'), 'data': os.path.join(p, 'buffer'), 'buffer': os.path.join(p, 'resource'), 'resource': os.path.join(p, 'tools'), 'tools': os.path.join(p, 'result'), 'rst': os.path.join(p, 'result', 'testcase'), 'rst_log': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n pass\n return proj_conf"} +{"i": 342, "s": 30, "got": "def init_project_env(subject, proj_path='Automation', sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf\n raise executable_file_path"} +{"i": 345, "s": 0, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in [os.walk(dir_name)] if not path.startswith('./build')])"} +{"i": 345, "s": 1, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([[u'{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in [os.walk(dir_name) if not path.startswith('./build') else []])"} +{"i": 345, "s": 2, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in [x for x in os.walk(dir_name) if not path.startswith('./build')]])"} +{"i": 345, "s": 3, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in [path for path, _, files in os.walk(dir_name) if not path.startswith('./build')]])"} +{"i": 345, "s": 4, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([{f'/{path}/{f}' for f in files if f.endswith('.py')} for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 5, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 6, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten(['{0}/{1}'.format(path, f) for path, _, files in [path for path, _, files in os.walk(dir_name) if not path.startswith('./build')] if x else [] for x in [x for x in files if f.endswith('.py')]])"} +{"i": 345, "s": 7, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 8, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 9, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 10, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 11, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 12, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in [path for path, _, files in os.walk(dir_name) if not path.startswith('./build')]])"} +{"i": 345, "s": 13, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in [x for x in os.walk(dir_name) if not path.startswith('./build')]])"} +{"i": 345, "s": 14, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([{u'{0}/{1}'.format(path, f) for f in files if f.endswith('.py')} for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 15, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 16, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 17, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in [x for x in os.walk(dir_name) if not path.startswith('./build')]])"} +{"i": 345, "s": 18, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 19, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 20, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([{u'{0}/{1}'.format(path, f) for f in files if f.endswith('.py')} for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 21, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 22, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 23, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 24, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 25, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 26, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 27, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in [path for path, _, files in os.walk(dir_name) if not path.startswith('./build')]])"} +{"i": 345, "s": 28, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 29, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 345, "s": 30, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([{f for f in files if f.endswith('.py')} for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 351, "s": 0, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': ('bodyr', 'body', 'headr', 'head'), 'ascii': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '|=(###)=|', 'body': '|=(###)=|', 'headr': '/\u2299 \u2299\\\\', 'head': '\\\\\u2299 \u2299/'}, 'default': {'bodyr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'body': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n return output\n if comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 1, "got": "def millipede(size=None, comment=False, reverse='default', template='0', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'bocal': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n return output\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 2, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': {'bodyr': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'body': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'love': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'bocal': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': '|=(###)=|', 'default': '|=(###)=|', 'inception': '/\u2299 \u2299\\\\', 'humancentipede': '\\\\\u2299 \u2299/', 'heart': {'bodyr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'body': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 3, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'bocal': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 4, "got": "def millipede(size=None, comment=False, reverse='default', template=0, position=False, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'bocal': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 5, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'ascii': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'default': '\u2554\u2299 \u2299\u2557', 'inception': '\u255a\u2299 \u2299\u255d', 'humancentipede': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'fish': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, '|=(###)=|': {'bodyr': '|=(', 'body': '=)', 'headr': '/\u2299 \u2299\\\\', 'head': '\\\\\u2299 \u2299/'}, 'inception': {'bodyr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'body': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'smile': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * ((padding_offsets[position % padding_suite_length] + head_padding_extra_offset) if reverse else template['head']), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position % padding_suite_length]), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 6, "got": "def millipede(size=None, comment=False, reverse='default', template=0, position=False, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {u'bodyr': u'\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', u'body': u'\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, 'ascii': {u'bodyr': u'\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', u'body': u'\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, 'default': {u'bodyr': u'\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', u'body': u'\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, 'inception': {u'bodyr': u'\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', u'body': u'\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, 'humancentipede': {u'bodyr': u'|=(###)=|', u'body': u'|=(###)=|', u'headr': u'/\u2299 \u2299\\\\', u'head': u'\\\\\u2299 \u2299/'}, 'heart': {u'bodyr': u'\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', u'body': u'\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, u'corporate': {u'bodyr': u'\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', u'body': u'\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, u'musician': {u'bodyr': u'\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', u'body': u'\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, u'love': {u'bodyr': u'\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', u'body': u'\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template[u'headr'] if reverse else template[u'head'])\n body_lines = ['{}{}\\n'.format(u' ' * (padding_offsets[x + position] % padding_suite_length), template[u'bodyr'] if reverse else template[u'body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = u''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + u'\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 7, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': u'\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': u'\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': u'\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': u'\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': u'\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': u'\u2554\u2299 \u2299\u2557', 'head': u'\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': u'\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': u'\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': u'\u2554\u2299 \u2299\u2557', 'head': u'\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': u'\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': u'\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': u'\u2554\u2299 \u2299\u2557', 'head': u'\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template[template['headr']] if reverse else template[template['head']])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template[template['bodyr']] if reverse else template[template['body']]) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += u'\\n' + comment + u'\\n'\n elif comment:\n output += comment + u'\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 8, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': ('bodyr' => '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body' => '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'), 'ascii': {'bodyr' => '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body' => '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'}, 'default': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'inception': {'bodyr' => '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body' => '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr' => '/\u2299 \u2299\\\\', 'body' => '\\\\\u2299 \u2299/', 'headr' => '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head' => '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr' => '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body' => '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr' => '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body' => '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'}, 'love': {'bodyr' => '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body' => '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 9, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'bocal': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template[headerr] if reverse else template[head])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template[bodyr] if reverse else template[body]) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n else:\n if comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 10, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': ('bodyr', 'body', 'headr', 'head'), 'ascii': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '|=(###)=|', 'body': '|=(###)=|', 'headr': '/\u2299 \u2299\\\\', 'head': '\\\\\u2299 \u2299/'}, 'default': {'bodyr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'body': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 11, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'ascii': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'default': '\u2554\u2299 \u2299\u2557', 'inception': '\u255a\u2299 \u2299\u255d', 'humancentipede': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'frozen': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'love': '|=(###)=|', 'corporate': '/\u2299 \u2299\\\\', 'musician': '\\\\\u2299 \u2299/', 'bocal': {'bodyr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'body': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\u2026)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\u2026)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\ud83d\ude37\u2026)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\u2026)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2026)=|', 'body': '\u255a\u2550(\u2764\ufe0f\u2026)=|', 'headr': '/\\\\', 'head': '\\\\/'}, 'humancentipede': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '\u2554\u2550(\u266b\u2026)=|', 'body': '\u255a\u2550(\u266b\u2026)=|', 'headr': '/\\\\', 'head': '\\\\/'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 12, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': ('bodyr' => '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body' => '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'), 'ascii': ('bodyr' => '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body' => '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'), 'default': ('bodyr' => '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body' => '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'), 'inception': ('bodyr' => '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body' => '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'), 'humancentipede': '|=(###)=|', 'heart': '|=(###)=|', 'default': '/\u2299 \u2299\\\\', 'inception': '\\\\\u2299 \u2299/'}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template[headr] if reverse else template[head])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template[bodyr] if reverse else template[body]) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n return output\n if comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 13, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'bocal': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 14, "got": "def millipede(size=None, comment=False, reverse='default', template=0, position=False, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b)==\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b)==\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\ud83d\ude37)!==\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37)===\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'bocal': {'bodyr': '\u2554\u2550(\u2764\ufe0f)!==\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f)===\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template[template['headr']] if reverse else template[template['head']])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template[template['bodyr']] if reverse else template[template['body']]) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n else:\n if comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 15, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': ('bodyr', 'body', 'headr', 'head'), 'ascii': {'frozen': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'love': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d'}, 'default': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'inception': {'frozen': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'love': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '|=(###)=|', 'body': '|=(###)=|', 'headr': '/\u2299 \u2299\\\\', 'head': '\\\\\u2299 \u2299/'}, 'default': {'frozen': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'love': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d'}, 'inception': {'frozen': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'love': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'frozen': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'love': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 16, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'bocal': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 17, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': ('bodyr' => '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body' => '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'), 'ascii': ('bodyr' => '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body' => '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'), 'default': ('bodyr' => '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body' => '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'), 'inception': ('bodyr' => '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body' => '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'), 'humancentipede': '|=(###)=|', 'heart': '/\u2299 \u2299\\\\', 'default': ('bodyr' => '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'body' => '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'), 'corporate': ('bodyr' => '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body' => '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'), 'musician': ('bodyr' => '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body' => '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d'), 'bocal': ('bodyr' => '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body' => '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr' => '\u2554\u2299 \u2299\u2557', 'head' => '\u255a\u2299 \u2299\u255d')}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 18, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'ascii': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'default': '\u2554\u2299 \u2299\u2557', 'inception': '\u255a\u2299 \u2299\u255d', 'humancentipede': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'love': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'corporate': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'musician': '\u2554\u2299 \u2299\u2557', 'bocal': '\u255a\u2299 \u2299\u255d', 'ascii': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'default': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', 'inception': '\u2554\u2299 \u2299\u2557', 'humancentipede': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'love': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n else:\n if comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 19, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {u'frozen': u'\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', u'love': u'\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', u'corporate': u'\u2554\u2299 \u2299\u2557', u'musician': u'\u255a\u2299 \u2299\u255d'}, u'bocal': {u'bodyr': u'\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', u'body': u'\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, u'musician': {u'bodyr': u'\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', u'body': u'\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, u'heart': {u'bodyr': u'\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', u'body': u'\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template[headr] if reverse else template[head])\n body_lines = ['{}{}\\n'.format(u' ' * (padding_offsets[x + position] % padding_suite_length), template[u'bodyr'] if reverse else template[u'body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + u'\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 20, "got": "def millipede(size=None, comment=False, reverse='default', template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'ascii': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'default': '\u2554\u2299 \u2299\u2557', 'inception': '\u255a\u2299 \u2299\u255d', 'humancentipede': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'heart': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d'}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template[template['headr'] if reverse else template['head']])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template[template['bodyr']] if reverse else template[template['body']]) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 21, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'ascii': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'default': '\u2554\u2299 \u2299\u2557', 'inception': '\u255a\u2299 \u2299\u255d', 'humancentipede': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'heart': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'ascii': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'default': '\u2554\u2299 \u2299\u2557', 'inception': '\u255a\u2299 \u2299\u255d', 'humancentipede': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'heart': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'corporate': '|=(###)=|', 'musician': '|=(###)=|', 'bocal': '/\u2299 \u2299\\\\', 'ascii': '\\\\\u2299 \u2299/', 'default': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'inception': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', 'humancentipede': '\u2554\u2299 \u2299\u2557', 'heart': '\u255a\u2299 \u2299\u255d', 'corporate': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'musician': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'bocal': '\u2554\u2299 \u2299\u2557', 'ascii': '\u255a\u2299 \u2299\u255d', 'default': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'inception': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'humancentipede': '\u2554\u2299 \u2299\u2557', 'heart': '\u255a\u2299 \u2299\u255d'}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 22, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': ('bodyr', 'body', 'headr', 'head'), 'ascii': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '|=(###)=|', 'body': '|=(###)=|', 'headr': '/\u2299 \u2299\\\\', 'head': '\\\\\u2299 \u2299/'}, 'default': {'bodyr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'body': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 23, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\u2026)\u2550\u2557', 'body': '\u255a\u2550(\u2026)\u2026\u2550\u2550}', 'musician': {'bodyr': '\u2554\u2550(\ud83d\ude37\u2026)\u2550\u2557', 'body': '\u255a\u2550(\u2026)\u2026\u2550\u2550}', 'bocal': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2026)\u2550\u2557', 'body': '\u255a\u2550(\u2026)\u2026\u2550\u2550}', 'love': {'bodyr': '\u2554\u2550(\u2665\ufe0f\u2026)\u2550\u2557', 'body': '\u255a\u2550(\u2026)\u2026\u2550\u2550}'}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template[template['headr'] if reverse else template['head']])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 24, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {u'bodyr': u'\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', u'body': u'\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, 'ascii': {u'bodyr': u'\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', u'body': u'\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, 'default': {u'bodyr': u'\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', u'body': u'\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, 'inception': {u'bodyr': u'\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', u'body': u'\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, 'humancentipede': {u'bodyr': u'|=(###)=|', u'body': u'|=(###)=|', u'headr': u'/\u2299 \u2299\\\\', u'head': u'\\\\\u2299 \u2299/'}, 'heart': {u'bodyr': u'\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', u'body': u'\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, 'love': {u'bodyr': u'\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', u'body': u'\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, u'corporate': {u'bodyr': u'\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', u'body': u'\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}, u'musician': {u'bodyr': u'\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', u'body': u'\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', u'headr': u'\u2554\u2299 \u2299\u2557', u'head': u'\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(u' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template[~u'headr'] if reverse else template[u'head'])\n body_lines = ['{}{}\\n'.format(u' ' * (padding_offsets[x + position % padding_suite_length]), template[u'bodyr'] if reverse else template[u'body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = u''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + u'\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 25, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'bocal': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 26, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'bocal': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 27, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'bocal': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 28, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': {'bodyr': '|=(###)=|', 'body': '|=(###)=|', 'headr': '/\u2299 \u2299\\\\', 'head': '\\\\\u2299 \u2299/'}, 'heart': {'bodyr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'body': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 29, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'bocal': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 351, "s": 30, "got": "def millipede(size=None, comment=False, reverse='default', template=0, position=False, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': ('bodyr', 'body', 'headr', 'head'), 'ascii': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'heart': {'bodyr': '|=(###)=|', 'body': '|=(###)=|', 'headr': '/\u2299 \u2299\\\\', 'head': '\\\\\u2299 \u2299/'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 355, "s": 0, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n else:\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found and extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n elif extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file and auth_found:\n raise SessionError('More than one authorisation given!')\n elif basic_auth_file:\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 1, "got": "def get_session(user_agent, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found and extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n elif extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file and auth_found:\n raise SessionError('More than one authorisation given!')\n elif basic_auth_file:\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 2, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n else:\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 3, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 4, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n else:\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found and extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n elif extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth and auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 5, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth and auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 6, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found and extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n elif extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file and auth_found:\n raise SessionError('More than one authorisation given!')\n elif basic_auth_file:\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 7, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n else:\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 8, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 9, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file and auth_found:\n raise SessionError('More than one authorisation given!')\n if basic_auth_file:\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 10, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 11, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n elif extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 12, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth and auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file and auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 13, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n else:\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found and extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n elif extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 14, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file and auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 15, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(max_retries=retries, pool_connections=100, pool_maxsize=100))\n s.mount('https://', HTTPAdapter(max_retries=retries, pool_connections=100, pool_maxsize=100))\n return s"} +{"i": 355, "s": 16, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 17, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n else:\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 18, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 19, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 20, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n else:\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found and extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n elif extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file and auth_found:\n raise SessionError('More than one authorisation given!')\n if basic_auth_file:\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 21, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 22, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(max_retries=retries, pool_connections=100, pool_maxsize=100))\n s.mount('https://', HTTPAdapter(max_retries=retries, pool_connections=100, pool_maxsize=100))\n return s"} +{"i": 355, "s": 23, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 24, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 25, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth and auth_found:\n raise SessionError('More than one authorisation given!')\n else:\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 355, "s": 26, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(max_retries=retries, pool_connections=100, pool_maxsize=100))\n s.mount('https://', HTTPAdapter(max_retries=retries, pool_connections=100, pool_maxsize=100))\n return s"} +{"i": 370, "s": 0, "got": "def check(response, expected_status=200, url=None):\n \"\"\"pass\"\"\"\n if response.status_code != expected_status:\n if url is None:\n url = response.url\n try:\n err = response.json()\n except:\n err = {}\n if all((x in err for x in ['status', 'message', 'description', 'details'])):\n raise _APIError(err['status'], err['message'], url, err, err['description'], err['details'])\n suffix = '.html' if ' 200:\n with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as f:\n f.write(response.text.encode('utf-8'))\n msg = '{}...\\n\\n[snipped; full response written to {f.name}'.format(msg[:100], **locals())\n msg = 'Request {url!r} returned code {response.status_code}, expected {expected_status}. \\n{msg}'.format(**locals())\n raise _APIError(response.status_code, msg, url, response.text)\n if response.headers.get('Content-Type') == 'application/json':\n try:\n return response.json()\n except:\n raise Exception('Cannot decode json; text={response.text!r}'.format(**locals()))\n else:\n return response.text"} +{"i": 372, "s": 0, "got": "def request(self, url, method='get', format=None, data=None, expected_status=None, headers=None, use_xpost=True, **options):\n \"\"\"pass\"\"\"\n if expected_status is None:\n if method == 'get':\n expected_status = 200\n elif method == 'post':\n expected_status = 201\n else:\n raise ValueError('No expected status supplied and method unknown.')\n if not url.startswith('http'):\n url = '{self.host}/api/v4/{url}'.format(**locals())\n if format is not None:\n options = dict([('format', format)], **options)\n options = {field: value for field, value in options.items() if value is not None}\n headers = dict(headers or {}, Authorization='Token {}'.format(self.token))\n if method == 'get' and use_xpost:\n assert data is None\n headers.update({'X-HTTP-METHOD-OVERRIDE': method})\n data = options\n options = None\n method = 'post'\n r = requests.request(method, url, data=data, params=options, headers=headers)\n log.debug('HTTP {method} {url} (options={options!r}, data={data!r},headers={headers}) -> {r.status_code}'.format(**locals()))\n return check(r, expected_status=expected_status)"} +{"i": 372, "s": 1, "got": "def request(self, url, method='get', format='json', data=None, expected_status=None, headers=None, use_xpost=True, **options):\n \"\"\"pass\"\"\"\n if expected_status is None:\n if method == 'get':\n expected_status = 200\n elif method == 'post':\n expected_status = 201\n else:\n raise ValueError('No expected status supplied and method unknown.')\n if not url.startswith('http'):\n url = '{self.host}/api/v4/{url}'.format(**locals())\n if format is not None:\n options = dict(('format', format), **options)\n options = {field: value for field, value in options.items() if value is not None}\n headers = dict(headers or {}, Authorization='Token {}'.format(self.token))\n if method == 'get' and use_xpost:\n assert data is None\n headers.update({'X-HTTP-METHOD-OVERRIDE': method})\n data = options\n options = None\n method = 'post'\n r = requests.request(method, url, data=data, params=options, headers=headers)\n log.debug('HTTP {method} {url} (options={options!r}, data={data!r},headers={headers}) -> {r.status_code}'.format(**locals()))\n return check(r, expected_status=expected_status)"} +{"i": 372, "s": 2, "got": "def request(self, url, method='get', format=None, data=None, expected_status=None, headers=None, use_xpost=True, **options):\n \"\"\"pass\"\"\"\n if expected_status is None:\n if method == 'get':\n expected_status = 200\n elif method == 'post':\n expected_status = 201\n else:\n raise ValueError('No expected status supplied and method unknown.')\n if not url.startswith('http'):\n url = '{self.host}/api/v4/{url}'.format(**locals())\n if format is not None:\n options = dict(('format', format), **options)\n options = {field: value for field, value in options.items() if value is not None}\n headers = dict(headers or {}, Authorization='Token {}'.format(self.token))\n if method == 'get' and use_xpost:\n assert data is None\n headers.update({'X-HTTP-METHOD-OVERRIDE': method})\n data = options\n options = None\n method = 'post'\n r = requests.request(method, url, data=data, params=options, headers=headers)\n log.debug('HTTP {method} {url} (options={options!r}, data={data!r},headers={headers}) -> {r.status_code}'.format(**locals()))\n return check(r, expected_status=expected_status)"} +{"i": 372, "s": 3, "got": "def request(self, url, method='get', format=None, data=None, expected_status=None, headers=None, use_xpost=True, **options):\n \"\"\"pass\"\"\"\n if expected_status is None:\n if method == 'get':\n expected_status = 200\n elif method == 'post':\n expected_status = 201\n else:\n raise ValueError('No expected status supplied and method unknown.')\n if not url.startswith('http'):\n url = '{self.host}/api/v4/{url}'.format(**locals())\n if format is not None:\n options = dict([('format', format)], **options)\n options = {field: value for field, value in options.items() if value is not None}\n headers = dict(headers or {}, Authorization='Token {}'.format(self.token))\n if method == 'get' and use_xpost:\n assert data is None\n headers.update({'X-HTTP-METHOD-OVERRIDE': method})\n data = options\n options = None\n method = 'post'\n r = requests.request(method, url, data=data, params=options, headers=headers)\n log.debug('HTTP {method} {url} (options={options!r}, data={data!r},headers={headers}) -> {r.status_code}'.format(**locals()))\n return check(r, expected_status=expected_status)"} +{"i": 372, "s": 4, "got": "def request(self, url, method='get', format='json', data=None, expected_status=None, headers=None, use_xpost=True, **options):\n \"\"\"pass\"\"\"\n if expected_status is None:\n if method == 'get':\n expected_status = 200\n elif method == 'post':\n expected_status = 201\n else:\n raise ValueError('No expected status supplied and method unknown.')\n if not url.startswith('http'):\n url = '{self.host}/api/v4/{url}'.format(**locals())\n if format is not None:\n options = dict({'format': format}, **options)\n options = {field: value for field, value in options.items() if value is not None}\n headers = dict(headers or {}, Authorization='Token {}'.format(self.token))\n if method == 'get' and use_xpost:\n assert data is None\n headers.update({'X-HTTP-METHOD-OVERRIDE': method})\n data = options\n options = None\n method = 'post'\n r = requests.request(method, url, data=data, params=options, headers=headers)\n log.debug('HTTP {method} {url} (options={options!r}, data={data!r},headers={headers}) -> {r.status_code}'.format(**locals()))\n return check(r, expected_status=expected_status)"} +{"i": 374, "s": 0, "got": "def get_scroll(self, url, page_size=100, yield_pages=False, **filters):\n \"\"\"pass\"\"\"\n n = 0\n options = dict(page_size=page_size, **filters)\n format = filters.get('format')\n while True:\n r = self.request(url, use_xpost=False, **options)\n n += len(r['results'])\n log.debug('Got {} {n}/{total}'.format(url.split('?')[0], total=r['total'], **locals()))\n if yield_pages:\n yield r\n else:\n for row in r['results']:\n yield row\n if (url := r['next']) is None:\n break\n options = {'format': None}"} +{"i": 374, "s": 1, "got": "def get_scroll(self, url, page_size=100, yield_pages=False, **filters):\n \"\"\"pass\"\"\"\n n = 0\n options = dict(page_size=page_size, **filters)\n format = filters.get('format')\n while True:\n r = self.request(url, use_xpost=False, **options)\n n += len(r['results'])\n log.debug(u'Got {} {n}/{total}'.format(url.split('?')[0], total=r['total'], **locals()))\n if yield_pages:\n yield r\n else:\n for row in r['results']:\n yield row\n if (url := r['next']) is None:\n break\n options = {'format': None}"} +{"i": 374, "s": 2, "got": "def get_scroll(self, url, page_size=100, yield_pages=False, **filters):\n \"\"\"pass\"\"\"\n n = 0\n options = dict(page_size=page_size, **filters)\n format = filters.get('format')\n while True:\n r = self.request(url, use_xpost=False, **options)\n n += len(r['results'])\n log.debug('Got {} {n}/{total}'.format(url.split('?')[0], total=r['total'], **locals()))\n if yield_pages:\n yield r\n else:\n for row in r['results']:\n yield row\n if r['next'] is None:\n break\n url = r['next']\n options = {'format': None}"} +{"i": 386, "s": 0, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while True:\n if c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if not is_dollar and self.is_expanding() and (c in [',', '}']):\n i.rewind(1)\n return (x for x in result)\n elif self.is_expanding():\n if c in (',', '}'):\n i.rewind(1)\n return (x for x in result)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n else:\n break\n return (x for x in result)"} +{"i": 386, "s": 1, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = [u'']\n is_dollar = False\n try:\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return (x for x in result)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n except StopIteration:\n if not self.is_expanding():\n pass\n return (x for x in result)"} +{"i": 386, "s": 2, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while True:\n if c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if not self.is_expanding() or c in (',', '}'):\n i.rewind(1)\n return ((x for x in result) if isinstance(c, str) else c)\n elif self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return ((x for x in result) if isinstance(c, str) else c)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n else:\n break\n return (x for x in result)"} +{"i": 386, "s": 3, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while True:\n if c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n elif not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return ((x for x in result),)\n elif self.is_expanding():\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n else:\n return ((x for x in result),)"} +{"i": 386, "s": 4, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n elif not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n else:\n if self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return (x for x in result)\n elif self.is_expanding():\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n else:\n break\n return (x for x in result)"} +{"i": 386, "s": 5, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while True:\n if c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n elif not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n else:\n break\n except StopIteration:\n i.rewind(i.index - index)\n elif self.is_expanding() and c in ('{', '}'):\n i.rewind(1)\n return (x for x in result)\n else:\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n else:\n break\n return (x for x in result)"} +{"i": 386, "s": 6, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n elif self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return (x for x in result)\n except StopIteration:\n i.rewind(i.index - index)\n elif self.is_expanding():\n i.rewind(1)\n else:\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n return (x for x in result)"} +{"i": 386, "s": 7, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n elif not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n elif self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return ((x for x in result))\n else:\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n return ((x for x in result))"} +{"i": 386, "s": 8, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n elif self.is_expanding() and c in [',', '}']:\n i.rewind(1)\n return (x for x in result)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n return (x for x in result)"} +{"i": 386, "s": 9, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n elif self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return ((x for x in result))\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n return ((x for x in result))"} +{"i": 386, "s": 10, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if not is_dollar and self.is_expanding() and (c in [',', '}']):\n i.rewind(1)\n return (x for x in result)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n return (x for x in result)"} +{"i": 386, "s": 11, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n else:\n return (x for x in result) if self.is_expanding() and c in [',', '}']\n elif self.is_expanding():\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n return (x for x in result)"} +{"i": 386, "s": 12, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while True:\n if c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n elif not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return (x for x in result)\n elif self.is_expanding():\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n else:\n break\n else:\n break\n return (x for x in result)"} +{"i": 386, "s": 13, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while True:\n if c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n elif self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return (x for x in result)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n else:\n break\n return (x for x in result)"} +{"i": 386, "s": 14, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if not ignore_brace and self.is_expanding() and (c in [',', '}']):\n i.rewind(1)\n return (x for x in result)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n return (x for x in result)"} +{"i": 386, "s": 15, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if not is_dollar or c in (',', '}'):\n i.rewind(1)\n return ((x for x in result),)\n if self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return ((x for x in result),)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n return ((x for x in result),)"} +{"i": 386, "s": 16, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if self.is_expanding() and c in [',', '}']:\n i.rewind(1)\n return (x for x in result)\n elif self.is_expanding():\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n else:\n break\n return (x for x in result)"} +{"i": 386, "s": 17, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while True:\n if c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if self.is_expanding() and c in [',', '}']:\n i.rewind(1)\n return (x for x in result)\n if self.squash(result, [c] if isinstance(c, str) else c):\n c = next(i)\n if not c:\n break\n else:\n break\n return (x for x in result)"} +{"i": 386, "s": 18, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if not ignore_brace or self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return ((x for x in result),)\n else:\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n return ((x for x in result),)"} +{"i": 386, "s": 19, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n elif not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n elif self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return ((x for x in result))\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n return ((x for x in result))"} +{"i": 386, "s": 20, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while True:\n if c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n elif self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return ((x for x in result) if isinstance(c, str) else c)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n else:\n break\n return ((x for x in result))"} +{"i": 386, "s": 21, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if not ignore_brace and self.is_expanding() and (c in [',', '}']):\n i.rewind(1)\n return (x for x in result)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n if not c:\n break\n return (x for x in result)"} +{"i": 386, "s": 22, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n elif not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return ((x for x in result))\n else:\n if self.is_expanding():\n c = [c] if isinstance(c, str) else c\n next(i)\n return (x for x in result)"} +{"i": 386, "s": 23, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n elif not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n else:\n if self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return (x for x in result)\n else:\n if not ignore_brace or self.is_expanding():\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n continue\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n return (x for x in result)"} +{"i": 386, "s": 24, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and (c == '{'):\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if not is_dollar:\n if self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return ((x for x in result),)\n elif self.is_expanding():\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n if c:\n continue\n yield from (x for x in result)\n return ((x for x in result),)"} +{"i": 386, "s": 25, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if not is_dollar:\n return (x for x in result)\n elif self.is_expanding() and c in [',', '}']:\n i.rewind(1)\n return (x for x in result)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n if not c:\n break\n return (x for x in result)"} +{"i": 386, "s": 26, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if not ignore_brace and self.is_expanding() and (c in [',', '}']):\n i.rewind(1)\n return ((x for x in result),)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n return (x for x in result)"} +{"i": 386, "s": 27, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while True:\n if c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n elif not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n else:\n return .>(result)\n elif self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return ((x for x in result),)\n else:\n break\n is_dollar = next(i)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n while c:\n yield x\n return (x for x in result)"} +{"i": 386, "s": 28, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if self.is_expanding() and c in [',', '}']:\n i.rewind(1)\n return (x for x in result)\n if self.is_expanding():\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n else:\n break\n return (x for x in result)"} +{"i": 386, "s": 29, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n elif not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n elif self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return (x for x in result)\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n return (x for x in result)"} +{"i": 386, "s": 30, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n else:\n if self.is_expanding() and c in (',', '}'):\n i.rewind(1)\n return ((x for x in result), )\n elif self.is_expanding():\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n else:\n break\n return (x for x in result)"} +{"i": 388, "s": 0, "got": "def add_episode(self, text, text_format=None, title=None, author='watson', summary=None, publish_date='. ', synthesizer=None, synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 1, "got": "def add_episode(self, text=None, text_format='watson', title=None, author='.', summary=u'. ', publish_date=None, synthesizer='.', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"'+title+'\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 2, "got": "def add_episode(self, text, text_format='watson', title=None, author=None, summary='', publish_date=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 3, "got": "def add_episode(self, text, text_format=None, title='watson', author=None, summary='. ', publish_date=None, synthesizer=None, synth_args=' ', sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 4, "got": "def add_episode(self, text=None, text_format=None, title='watson', author=None, summary='. ', publish_date=None, synthesizer=None, synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"'+title+'\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 5, "got": "def add_episode(self, text, text_format=None, title='watson', author=None, summary='', publish_date='. ', synthesizer=None, synth_args=None, sentence_break=None):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 6, "got": "def add_episode(self, text=None, text_format=None, title='watson', author=None, summary='. ', publish_date=None, synthesizer=synthesizer, synth_args=None, sentence_break=sentence_break):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 7, "got": "def add_episode(self, text, text_format, title, author=None, summary=None, publish_date='watson', synthesizer=None, synth_args='. ', sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 8, "got": "def add_episode(self, text, text_format, title=None, author=None, summary='watson', publish_date=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 9, "got": "def add_episode(self, text, text_format, title=None, author=None, summary='watson', publish_date=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError(\"'\" + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 10, "got": "def add_episode(self, text, text_format, title=None, author=None, summary='watson', publish_date=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 11, "got": "def add_episode(self, text, text_format=None, title='watson', author=None, summary=None, publish_date='. ', synthesizer=None, synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 12, "got": "def add_episode(self, text, text_format='watson', title=None, author=None, summary='watson', publish_date=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 13, "got": "def add_episode(self, text, text_format=None, title=None, author='watson', summary=None, publish_date='. ', synthesizer=None, synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 14, "got": "def add_episode(self, text=None, text_format=None, title='watson', author=None, summary='. ', publish_date=None, synthesizer=None, synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 15, "got": "def add_episode(self, text=None, text_format=None, title='watson', author=None, summary='. ', publish_date=None, synthesizer=None, synth_args=None, sentence_break=None):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 16, "got": "def add_episode(self, text, text_format, title=None, author=None, summary='watson', publish_date=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 17, "got": "def add_episode(self, text, text_format=None, title=None, author='watson', summary=None, publish_date='. ', synthesizer=None, synth_args=None, sentence_break=None):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 18, "got": "def add_episode(self, text, text_format, title=None, author=None, summary='watson', publish_date=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 19, "got": "def add_episode(self, text, text_format, title=None, author=None, summary='watson', publish_date=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 20, "got": "def add_episode(self, text=None, text_format='watson', title=None, author=None, summary='', publish_date=None, synthesizer=u'. ', synth_args=None, sentence_break=u' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"'+title+'\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 21, "got": "def add_episode(self, text, text_format=None, title='watson', author=None, summary=u'. ', publish_date=None, synthesizer='.', synth_args=None, sentence_break=u' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(u' ', u'_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 22, "got": "def add_episode(self, text, text_format=None, title='watson', author=None, summary='.', publish_date=' ', synthesizer=None, synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 23, "got": "def add_episode(self, text, text_format, title=None, author=None, summary='watson', publish_date=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 24, "got": "def add_episode(self, text, text_format, title=None, author=None, summary='watson', publish_date=None, synthesizer='. ', synth_args='', sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 25, "got": "def add_episode(self, text, text_format, title=None, author=None, summary='watson', publish_date=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 26, "got": "def add_episode(self, text, text_format, title=None, author=None, summary='watson', publish_date=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 27, "got": "def add_episode(self, text, text_format='watson', title=None, author=None, summary='.', publish_date=None, synthesizer=None, synth_args='', sentence_break='. '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 28, "got": "def add_episode(self, text, text_format, title=None, author=None, summary='watson', publish_date=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 29, "got": "def add_episode(self, text, text_format, title, author=None, summary=None, publish_date='watson', synthesizer=None, synth_args='. ', sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError(\"'\" + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 388, "s": 30, "got": "def add_episode(self, text=None, text_format=None, title='watson', author=None, summary='. ', publish_date=None, synthesizer=None, synth_args='.', sentence_break=None):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 389, "s": 0, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author=u'none', summary=None, synthesizer=u'none', synth_args=None, sentence_break=u'. '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 1, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author=u'', summary='', synthesizer=None, synth_args=None, sentence_break=u' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 2, "got": "def add_scheduled_job(self, text_source, cron_args=None, text_format='watson', title=None, author='. ', summary='. ', synthesizer=None, synth_args=None, sentence_break='. '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 3, "got": "def add_scheduled_job(self, text_source, cron_args=None, text_format='watson', title=None, author='. ', summary='', synthesizer=None, synth_args=None, sentence_break='. '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 4, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author=' ', summary=None, synthesizer=None, synth_args='', sentence_break='. '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 5, "got": "def add_scheduled_job(self, text_source, cron_args=None, text_format='watson', title=None, author='. ', summary='', synthesizer=None, synth_args='. ', sentence_break='. '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs][title]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 6, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author='.', summary=None, synthesizer='', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs][title]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 7, "got": "def add_scheduled_job(self, text_source, cron_args, text_format='watson', title=None, author='watson', summary=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs][title]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 8, "got": "def add_scheduled_job(self, text_source, cron_args, text_format, title, author=None, summary='watson', synthesizer=None, synth_args='. ', sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs][title]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 9, "got": "def add_scheduled_job(self, text_source, cron_args, text_format, title=None, author='watson', summary=None, synthesizer='. ', synth_args=None):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 10, "got": "def add_scheduled_job(self, text_source, cron_args, text_format, title, author=None, summary='watson', synthesizer=None, synth_args='. ', sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 11, "got": "def add_scheduled_job(self, text_source, cron_args=None, text_format='watson', title=None, author='. ', summary='', synthesizer=None, synth_args=None, sentence_break='. '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self.scheduled_jobs[title] = self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 12, "got": "def add_scheduled_job(self, text_source, cron_args=None, text_format='watson', title=None, author='. ', summary='', synthesizer=None, synth_args=None, sentence_break='. '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs][title]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 13, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author=u'None', summary=None, synthesizer=None, synth_args=u'. ', sentence_break=u'. '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]] = self._scheduler.add_job\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 14, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author=u'', summary=u'', synthesizer=None, synth_args=None, sentence_break=u' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 15, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author=u'', summary=None, synthesizer='.', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 16, "got": "def add_scheduled_job(self, text_source, cron_args, text_format, title=None, author='watson', summary=None, synthesizer='. ', synth_args=None, sentence_break=None):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self.scheduled_jobs[title] = self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 17, "got": "def add_scheduled_job(self, text_source, cron_args=None, text_format='watson', title=None, author='. ', summary=' ', synthesizer=None, synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 18, "got": "def add_scheduled_job(self, text_source, cron_args, text_format, title, author=None, summary='watson', synthesizer=None, synth_args='. ', sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs][title]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 19, "got": "def add_scheduled_job(self, text_source, cron_args, text_format=None, title='watson', author=None, summary='. ', synthesizer=None, synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 20, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author=u' ', summary=u' ', synthesizer=u' ', synth_args={}, sentence_break=u' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 21, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author=u'', summary='', synthesizer=u'. ', synth_args=None, sentence_break=None):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 22, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author=u'none', summary=None, synthesizer='none', synth_args=None, sentence_break=u'. '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 23, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author='.', summary='', synthesizer=None, synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self.scheduled_jobs[title] = self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 24, "got": "def add_scheduled_job(self, text_source, cron_args, text_format, title, author=None, summary='watson', synthesizer=None, synth_args='. ', sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 25, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author='.', summary=None, synthesizer='.', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 26, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author='.', summary=None, synthesizer='.', synth_args='', sentence_break=u' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 27, "got": "def add_scheduled_job(self, text_source, cron_args=None, text_format='watson', title=None, author='. ', summary=None, synthesizer=None, synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 28, "got": "def add_scheduled_job(self, text_source, cron_args, text_format, title=None, author='watson', summary=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self.scheduled_jobs[title] = self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 29, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author=' ', summary=None, synthesizer='.', synth_args='', sentence_break=u' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 389, "s": 30, "got": "def add_scheduled_job(self, text_source=None, cron_args='watson', text_format=None, title='. ', author='.', summary='', synthesizer='.', synth_args=' ', sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs][title]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 396, "s": 0, "got": "def load_json_file(file, decoder=None):\n \"\"\"pass\"\"\"\n if decoder is None:\n decoder = DateTimeDecoder\n if not hasattr(file, 'read'):\n with io.open(file, 'r', encoding='utf-8') as f:\n return json.load(f, object_hook=decoder.decode)\n else:\n return json.load(file, object_hook=decoder.decode)"} +{"i": 396, "s": 1, "got": "def load_json_file(file, decoder=None):\n \"\"\"pass\"\"\"\n if decoder is None:\n decoder = DateTimeDecoder\n if not hasattr(file, 'read'):\n with io.open(file, 'r', encoding='utf-8') as f:\n return json.load(f, object_hook=decoder.decode)\n return json.load(file, object_hook=decoder.decode)"} +{"i": 398, "s": 0, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 1, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(u',', u': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(u',', u':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n except:\n if opened:\n file.close()\n raise\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)\n if opened:\n file.close()"} +{"i": 398, "s": 2, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',:', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 3, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 4, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 5, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)\n if opened:\n file.close()"} +{"i": 398, "s": 6, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if opened:\n file.close()\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 7, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n except:\n if opened:\n file.close()\n raise\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)\n if opened:\n file.close()"} +{"i": 398, "s": 8, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 9, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 10, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 11, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()"} +{"i": 398, "s": 12, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 13, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n except:\n if opened:\n file.close()\n raise\n finally:\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)\n if opened:\n file.close()"} +{"i": 398, "s": 14, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 15, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 16, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n else:\n return"} +{"i": 398, "s": 17, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n except:\n if opened:\n file.close()\n raise\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)\n if opened:\n file.close()"} +{"i": 398, "s": 18, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 19, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 20, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',:', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n except:\n if opened:\n file.close()\n raise\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)\n if opened:\n file.close()"} +{"i": 398, "s": 21, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)\n if opened:\n file.close()"} +{"i": 398, "s": 22, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened and sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)\n if opened:\n file.close()"} +{"i": 398, "s": 23, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 24, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)\n if opened:\n file.close()"} +{"i": 398, "s": 25, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 26, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 27, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(', ', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 398, "s": 28, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n else:\n pass"} +{"i": 398, "s": 29, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n except:\n if opened:\n file.close()\n raise\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)\n if opened:\n file.close()"} +{"i": 398, "s": 30, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()"} +{"i": 399, "s": 0, "got": "def load_yaml_file(file):\n \"\"\"pass\"\"\"\n if not hasattr(file, 'read'):\n with io.open(file, 'r', encoding='utf-8') as f:\n return yaml.load(f, yaml.FullLoader)\n else:\n return yaml.load(file, yaml.FullLoader)"} +{"i": 399, "s": 1, "got": "def load_yaml_file(file):\n \"\"\"pass\"\"\"\n if not hasattr(file, 'read'):\n with io.open(file, 'r', encoding='utf-8') as f:\n return yaml.load(f, yaml.FullLoader)\n return yaml.load(file, yaml.FullLoader)"} +{"i": 402, "s": 0, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[{}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n elif temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if content not in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]'.format(content, node_id))\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]' % node_id\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n mapping['prefix'] = ''\n mapping['identifier'] = content\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n else:\n continue\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n temp_set_string = condition_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 1, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if not indicator_node_id in ids_to_process:\n msg = u'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if not param.attrib['name'] == 'yara/set':\n continue\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError(u'yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = u'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError(u'yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError(u'Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError(u'Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = u'.//param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = u' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError(u'Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError(u'Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = u'.//param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = u' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = u'.//param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = u'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug(u'Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {u':': u'#'}\n use_condition_template = False\n negation = node.get(u'negate')\n condition = node.get(u'condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = u'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == u'yara/FileSize':\n mapping[u'prefix'] = ''\n mapping[u'identifier'] = u'filesize'\n mapping[u'postfix'] = u' ' + content\n mapping[u'condition'] = yara_condition\n use_condition_template = True\n elif search == u'yara/RuleName':\n if content not in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = u'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning(u'Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]' % (content, node_id))\n if mangle_name(content) != content:\n msg = u'Yara/RuleName contains characters which would cause libyara errors [{}]'.format(node_id)\n raise YaraConversionError(msg)\n mapping[u'prefix'] = ''\n mapping[u'identifier'] = content\n else:\n xp = u'.//param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = u'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug(u'Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping[u':'] = u'#'\n mapping[u'prefix'] = u' '\n mapping[u'postfix'] = param.findtext('value')\n mapping[u'condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug(u'Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping[u'condition'] = u'at'\n mapping[u'postfix'] = param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug(u'Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping[u'condition'] = u'in'\n mapping[u'postfix'] = param.findtext('value')\n use_condition_template = True\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = u' '.join([condition_string, joining_value, temp_string])\n elif param_name == 'yara/offset/at':\n log.debug(u'Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping[u'condition'] = u'at'\n mapping[u'postfix'] = param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug(u'Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping[u'condition'] = u'in'\n mapping[u'postfix'] = param.findtext('value')\n use_condition_template = True\n elif condition_string == '':\n temp_set_string = condition_string\n else:\n condition_string = u' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n if is_set:\n log.debug(u'Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError(u'yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning(u'yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping[u'set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = u' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 2, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[{}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}]{}'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n elif mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]' % node_id\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n if len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n set_dict['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 3, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('and', 'or'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n elif mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'.format(node_id)\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('and', 'or'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n if len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping[set_dict['set_ids']] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 4, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if not indicator_node_id in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n elif temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp):\n if has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]'.format(content, node_id))\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/set\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/set':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['identifier'] = ''\n mapping['condition'] = ' '\n mapping['postfix'] = ''\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = 'at'\n mapping['identifier'] = param.findtext('value')\n mapping['condition'] = temp_string\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = 'in'\n mapping['identifier'] = param.findtext('value')\n use_condition_template = True\n elif node.tag == 'Indicator' and is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n if len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n set_dict['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n temp_set_string = condition_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n return condition_string"} +{"i": 402, "s": 5, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if not param.attrib['name'] == 'yara/set':\n continue\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp):\n if has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if not operator in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp):\n if has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n condition_string = condition_string if condition_string == '' else ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n set_dict['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 6, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if not indicator_node_id in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[{}]]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': '', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n elif mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'.format(node_id)\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n elif node.tag == 'Indicator':\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 7, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[{}]]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n break\n elif param_name == 'yara/offset/at':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n elif param_name == 'yara/offset/in':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping[set_dict['set_ids']] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 8, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if content not in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]'.format(content, node_id))\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]' % node_id\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n elif param_name == 'yara/offset/at':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n if len(set_dict['set_ids']) == 1:\n log.warning('yara/set with "} +{"i": 402, "s": 9, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' +' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n mangle_name(content)\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]' % (content, node_id))\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'.format(node_id)\n raise YaraConversionError(msg)\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' +' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n break\n elif param_name == 'yara/offset/at':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' +' + param.findtext('value')\n use_condition_template = True\n break\n elif param_name == 'yara/offset/in':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' +' + param.findtext('value')\n use_condition_template = True\n break\n else:\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n elif node.tag == 'Indicator':\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping[set_dict['set_ids']] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 10, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'.format(node_id)\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n elif './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id) == xp:\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n return condition_string"} +{"i": 402, "s": 11, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if not node.xpath('.//param[@ref-id=\"{}\" and @name=\"yara/count\"]'.format(node_id)):\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'.format(node_id)\n raise YaraConversionError(msg)\n mapping = {'prefix': '', 'identifier': content}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if content not in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]'.format(content, node_id))\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'.format(node_id)\n raise YaraConversionError(msg)\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n continue\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n if len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 12, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}]{}'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]' % (content, node_id))\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'.format(node_id)\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n break\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n else:\n continue\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n elif node.tag == 'Indicator':\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n set_dict['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 13, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[{}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n elif temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n set_dict['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 14, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if not indicator_node_id in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp):\n if has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]'.format(content, node_id))\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]' % node_id\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")].format(node_id)'\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 15, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n elif temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [%s]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': content}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]'.format(content, node_id))\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]' % node_id\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n elif is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n if len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n set_dict['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n temp_set_string = condition_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 16, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n elif temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not (content not in self.ioc_names_set):\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n elif mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'.format(node_id)\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/set\" or @name=\"yara/count\")]' % node_id\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' '\n mapping['condition'] = yara_condition\n use_condition_template = True\n break\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n elif operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n temp_set_string = condition_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 17, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[{}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': content}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if content not in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}]{}'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]' % (content, node_id))\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/set\" or @name=\"yara/offset/at\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameter assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/set':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = param.findtext('value')\n use_condition_template = True\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = 'at'\n mapping['postfix'] = param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = 'in'\n mapping['postfix'] = param.findtext('value')\n use_condition_template = True\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n if len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n temp_set_string = condition_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 18, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n else:\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n else:\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp):\n if has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n condition_string = condition_string\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping[expected_tag] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 19, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n elif temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [%s]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n break\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 20, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if not (indicator_node_id not in ids_to_process):\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if not node_id in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['and', 'or']:\n continue\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp):\n if has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n condition_string = condition_string == '' and recursed_condition or ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n set_dict['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 21, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if not (param.attrib['name'] == 'yara/set'):\n continue\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n elif temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n condition = self.condition_to_yara_map[condition]\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]'.format(content, node_id))\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]' % node_id\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n break\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n elif node.tag != 'Indicator':\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n return temp_set_string\n else:\n return ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])"} +{"i": 402, "s": 22, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n elif temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n break\n elif param_name == 'yara/offset/at':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n elif param_name == 'yara/offset/in':\n log.debug('[%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n else:\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n if len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 23, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[{}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['and', 'or']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp):\n if has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['and', 'or']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp):\n if has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n mangle_msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n elif mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'.format(node_id)\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n break\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n elif node.tag == 'yara/set':\n continue\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 24, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if not param.attrib['name'] == 'yara/set':\n continue\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': '', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if content not in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]'.format(content, node_id))\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]' % node_id\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n elif node.tag == 'Indicator':\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping[set_dict['set_ids']] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 25, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['and', 'or']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['and', 'or']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [%s]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#'}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]'.format(content, node_id))\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [%s]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [{} attached to [{}]'.format(param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('Found [{} attached to [{}]'.format(param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [{} attached to [{}]'.format(param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n else:\n continue\n elif operator not in ['and', 'or']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [{}]' % (id, operator))\n if condition_string == '':\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n return condition_string"} +{"i": 402, "s": 26, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': ''}\n negation = False\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]' % (content, node_id))\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]' % node_id\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n break\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n break\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n else:\n continue\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 27, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n set_dict['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 28, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['and', 'or']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['and', 'or']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n elif node.tag == 'node.tag is not a Indicator/IndicatorItem [%s]' % str(id):\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n if len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n set_dict['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 29, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[{}]]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ['or', 'and']:\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if not content in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]' % (content, node_id))\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]'\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id) == xp:\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n elif use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 402, "s": 30, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if not indicator_node_id in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n elif node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('and', 'or'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")].format(node_id)'\n if not parameters_node.xpath(xp) and has_siblings(node):\n condition_string = '(%s)' % recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n raise YaraConversionError('node.tag is not a Indicator/IndicatorItem [%s]' % str(id))\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n set_dict['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 404, "s": 0, "got": "def safe_makedirs(fdir):\n \"\"\"pass\"\"\"\n if os.path.isdir(fdir):\n pass\n else:\n try:\n os.makedirs(fdir)\n except WindowsError as e:\n if 'Cannot create a file when that file already exists' in e:\n log.debug('relevant dir already exists')\n else:\n raise WindowsError(e)\n return True"} +{"i": 404, "s": 1, "got": "def safe_makedirs(fdir):\n \"\"\"pass\"\"\"\n if os.path.isdir(fdir):\n pass\n else:\n try:\n os.makedirs(fdir)\n except WindowsError as e:\n if 'Cannot create a file when that file already exists' in e:\n log.debug('relevant dir already exists')\n else:\n raise WindowsError(e)\n return True"} +{"i": 405, "s": 0, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 1, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n else:\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n pass\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if not tag in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n self.null_pruned_iocs.add(iocid)\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.pruned_11_iocs.add(iocid)\n else:\n if pruned is True:\n self.pruned_11_iocs.add(iocid)\n comment_node = ioc_obj_10.root.getprevious()\n while comment_node is not None:\n log.debug('found a comment node')\n c = et.Comment(comment_node.text)\n ioc_obj_10.root.addprevious(c)\n comment_node = comment_node.getprevious()\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 2, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_10.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 3, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 4, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n else:\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n except Exception:\n log.exception('Unknown error occured while converting [{}]'.format(iocid))\n errors.append(iocid)\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 5, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n self.null_pruned_iocs.add(iocid)\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.pruned_11_iocs.add(iocid)\n else:\n if pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 6, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n else:\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception(u'Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception(u'Could not find children for the top level criteria/children nodes for IOC [{}].'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_10.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = u'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = u'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = u'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception(u'Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 7, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n while nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n break\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n else:\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 8, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n while nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n break\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 9, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n while nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]' .format(iocid))\n errors.append(iocid)\n except Exception:\n log.exception('Unknown error occured while converting [{}]'.format(iocid))\n errors.append(iocid)\n else:\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 10, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 11, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if not tag in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n elif not ioc_obj_10.root.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n ioc_obj_10 = ioc_obj_10\n return errors"} +{"i": 405, "s": 12, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except Exception:\n log.exception('Unknown error occured while converting [{}]' .format(iocid))\n errors.append(iocid)\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 13, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}].'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n while nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n elif not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 14, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n else:\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n while nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n break\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]' .format(iocid))\n errors.append(iocid)\n continue\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 15, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_10.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if not tag in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except Exception:\n log.exception('Unknown error occured while converting [{}]'.format(iocid))\n errors.append(iocid)\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 16, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}].'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if not tag in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n while nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n break\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 17, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 18, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n while nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 19, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if not tag in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 20, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n else:\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}].'.format(iocid))\n errors.append(iocid)\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_10.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n else:\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 21, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_10.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 22, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_10.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n while nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 23, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if not tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if not tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n while nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 24, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n else:\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 25, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if not tag in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]' .format(iocid))\n errors.append(iocid)\n continue\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 26, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_10.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 27, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 28, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_10.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if not tag in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n else:\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 29, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n else:\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_10.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except Exception:\n log.exception('Unknown error occured while converting [{}]' .format(iocid))\n errors.append(iocid)\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 405, "s": 30, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n else:\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n self.null_pruned_iocs.add(iocid)\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.pruned_11_iocs.add(iocid)\n else:\n if pruned is True:\n self.pruned_11_iocs.add(iocid)\n comment_node = ioc_obj_11.root.getprevious()\n while comment_node is not None:\n log.debug('found a comment node')\n c = et.Comment(comment_node.text)\n ioc_obj_10.root.addprevious(c)\n comment_node = comment_node.getprevious()\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 450, "s": 0, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 1, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n break\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 2, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 3, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 4, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n break\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 5, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 6, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n break\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 7, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 8, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 9, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 10, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 11, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 12, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 13, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 14, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n break\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 15, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n break\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 16, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 17, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 18, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 19, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 20, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n break\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 21, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n break\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 22, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 23, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 24, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 25, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 26, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 27, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 28, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 29, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n break\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 450, "s": 30, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n break\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 478, "s": 0, "got": "def get_alter_table_sql(self, diff):\n \"\"\"pass\"\"\"\n sql = []\n for column_diff in diff.changed_columns.values():\n if self.is_unchanged_binary_column(column_diff):\n continue\n old_column_name = column_diff.old_column_name\n column = column_diff.column\n if any([column_diff.has_changed('type'), column_diff.has_changed('precision'), column_diff.has_changed('scale'), column_diff.has_changed('fixed')]):\n query = 'ALTER ' + old_column_name + ' TYPE ' + self.get_sql_type_declaration(column.to_dict())\n sql.append('ALTER TABLE ' + diff.name + ' ' + query)\n if column_diff.has_changed('default') or column_diff.has_changed('type'):\n if column.get_default() is None:\n default_clause = ' DROP DEFAULT'\n else:\n default_clause = ' SET' + self.get_default_value_declaration_sql(column.to_dict())\n query = 'ALTER ' + old_column_name + default_clause\n sql.append('ALTER TABLE ' + diff.name + ' ' + query)\n if column_diff.has_changed('notnull'):\n op = 'DROP'\n if column.get_notnull():\n op = 'SET'\n query = 'ALTER ' + old_column_name + ' ' + op + ' NOT NULL'\n sql.append('ALTER TABLE ' + diff.name + ' ' + query)\n if column_diff.has_changed('autoincrement'):\n if column.get_autoincrement():\n seq_name = self.get_identity_sequence_name(diff.name, old_column_name)\n sql.append('CREATE SEQUENCE ' + seq_name)\n sql.append(\"SELECT setval('\" + seq_name + \"', (SELECT MAX(\" + old_column_name + ') FROM ' + diff.name + \"))\")\n query = 'ALTER ' + old_column_name + \" SET DEFAULT nextval('\" + seq_name + \"')\"\n sql.append('ALTER TABLE ' + diff.name + ' ' + query)\n else:\n query = 'ALTER ' + old_column_name + ' DROP DEFAULT'\n sql.append('ALTER TABLE ' + diff.name + ' ' + query)\n if column_diff.has_changed('length'):\n query = 'ALTER ' + old_column_name + ' TYPE ' + self.get_sql_type_declaration(column.to_dict())\n sql.append('ALTER TABLE ' + diff.name + ' ' + query)\n for old_column_name, column in diff.renamed_columns.items():\n sql.append('ALTER TABLE ' + diff.name + ' RENAME COLUMN ' + old_column_name + ' TO ' + column.get_name())\n return sql"} +{"i": 480, "s": 0, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 1, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 2, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 3, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 4, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 5, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 6, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 7, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 8, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 9, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 10, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 11, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 12, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 13, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 14, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 15, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 16, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 17, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 18, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 19, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 20, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 21, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 22, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 23, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 24, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 25, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 26, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 27, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 28, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 29, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 480, "s": 30, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 482, "s": 0, "got": "def plot_best_worst_fits(assignments_df, data, modality_col='Modality', score='$\\\\log_2 K$'):\n \"\"\"pass\"\"\"\n ncols = 2\n nrows = len(assignments_df.groupby(modality_col).groups.keys())\n fig, axes = plt.subplots(nrows=nrows, ncols=ncols * 4, figsize=(ncols * 6,))\n axes_iter = axes.flat\n fits = ('Highest', 'Lowest')\n for modality, df in assignments_df.groupby(modality_col):\n df = df.sort_values(score)\n color = MODALITY_TO_COLOR[modality]\n for fit in fits:\n if fit == 'Highest':\n ids = df['Feature ID'][-10:]\n else:\n ids = df['Feature ID'][:10]\n fit_psi = data[ids]\n tidy_fit_psi = fit_psi.stack().reset_index()\n tidy_fit_psi = tidy_fit_psi.rename(columns={'level_0': 'Sample ID', 'level_1': 'Feature ID', 0: '$\\\\Psi$'})\n if tidy_fit_psi.empty:\n continue\n ax = six.next(axes_iter)\n violinplot(x='Feature ID', y='$\\\\Psi$', data=tidy_fit_psi, color=color, ax=ax)\n ax.set(title='{:} {} {}'.format(fit, score, modality), xticks=[])\n sns.despine()\n fig.tight_layout()"} +{"i": 482, "s": 1, "got": "def plot_best_worst_fits(assignments_df, data, modality_col='Modality', score='$\\\\log_2 K$'):\n \"\"\"pass\"\"\"\n ncols = 2\n nrows = len(assignments_df.groupby(modality_col).groups.keys())\n fig, axes = plt.subplots(nrows=nrows, ncols=ncols, figsize=(nrows * 4, ncols * 6))\n axes_iter = axes.flat\n fits = ('Highest', 'Lowest')\n for modality, df in assignments_df.groupby(modality_col):\n df = df.sort_values(score)\n color = MODALITY_TO_COLOR[modality]\n for fit in fits:\n if fit == 'Highest':\n ids = df['Feature ID'][-10:]\n else:\n ids = df['Feature ID'][:10]\n fit_psi = data[ids]\n tidy_fit_psi = fit_psi.stack().reset_index()\n tidy_fit_psi = tidy_fit_psi.rename(columns={'level_0': 'Sample ID', 'level_1': 'Feature ID', 0: '$\\\\Psi$'})\n if not tidy_fit_psi.empty:\n ax = six.next(axes_iter)\n violinplot(x='Feature ID', y='$\\\\Psi$', data=tidy_fit_psi, color=color, ax=ax)\n ax.set(title='{} {} {}'.format(fit, score, modality), xticks=[])\n sns.despine()\n fig.tight_layout()"} +{"i": 484, "s": 0, "got": "def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):\n \"\"\"pass\"\"\"\n if percentages:\n counts = (100 * counts.T / counts.T.sum()).T\n if ax is None:\n ax = plt.gca()\n full_width = 0.8\n width = full_width / counts.shape[0]\n for i, (group, series) in enumerate(counts.iterrows()):\n left = np.arange(len(self.modality_order)) + i * width\n height = [series[i] if i in group else 0 for i in self.modality_order]\n color = phenotype_to_color[group]\n ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')\n ylabel = 'Percentage of events' if percentages else 'Number of events'\n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()"} +{"i": 484, "s": 1, "got": "def bar(self, counts=None, phenotype_to_color=None, ax=True, percentages=True):\n \"\"\"pass\"\"\"\n if percentages:\n counts = (100 / counts.T.sum()).T\n if ax is None:\n ax = plt.gca()\n full_width = 0.8\n width = full_width / counts.shape[0]\n for i, (group, series) in enumerate(counts.iterrows()):\n left = np.arange(len(self.modality_order)) + i * width\n height = [series[i] if i in series else 0 for i in self.modality_order]\n color = phenotype_to_color[group]\n ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')\n ylabel = 'Percentage of events' if percentages else 'Number of events'\n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()"} +{"i": 484, "s": 2, "got": "def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):\n \"\"\"pass\"\"\"\n if percentages:\n counts = (100 * (counts.T / counts.T.sum()).T)\n if ax is None:\n ax = plt.gca()\n full_width = 0.8\n width = full_width / counts.shape[0]\n for i, (group, series) in enumerate(counts.iterrows()):\n left = np.arange(len(self.modality_order)) + i * width\n height = [series[i] if i in group else 0 for i in self.modality_order]\n color = phenotype_to_color[group]\n ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')\n ylabel = 'Percentage of events' if percentages else 'Number of events'\n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()"} +{"i": 484, "s": 3, "got": "def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):\n \"\"\"pass\"\"\"\n if percentages:\n counts = (100 * (counts.T / counts.T.sum()).T)\n if ax is None:\n ax = plt.gca()\n full_width = 0.8\n width = full_width / counts.shape[0]\n for i, (group, series) in enumerate(counts.iterrows()):\n left = np.arange(len(self.modality_order)) + i * width\n height = [series[i] if i in group else 0 for i in self.modality_order]\n color = phenotype_to_color[group]\n ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')\n ylabel = 'Percentage of events' if percentages else 'Number of events'\n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()"} +{"i": 484, "s": 4, "got": "def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):\n \"\"\"pass\"\"\"\n if percentages:\n counts = (100 * counts.T / counts.T.sum()).T\n if ax is None:\n ax = plt.gca()\n full_width = 0.8\n width = full_width / counts.shape[0]\n for i, (group, series) in enumerate(counts.iterrows()):\n left = np.arange(len(self.modality_order)) + i * width\n height = [series[i] if i in group else 0 for i in self.modality_order]\n color = phenotype_to_color[group]\n ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')\n ylabel = 'Percentage of events' if percentages else 'Number of events'\n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()"} +{"i": 484, "s": 5, "got": "def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):\n \"\"\"pass\"\"\"\n if percentages:\n counts = (100 / counts.T.sum()).T\n if ax is None:\n ax = plt.gca()\n full_width = 0.8\n width = full_width / counts.shape[0]\n for i, (group, series) in enumerate(counts.iterrows()):\n left = np.arange(len(self.modality_order)) + i * width\n height = [series[i] if i in series else 0 for i in self.modality_order]\n color = phenotype_to_color[group]\n ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')\n ylabel = 'Percentage of events' if percentages else 'Number of events'\n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()"} +{"i": 484, "s": 6, "got": "def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):\n \"\"\"pass\"\"\"\n if percentages:\n counts = (100 * counts.T / counts.T.sum()).T\n if ax is None:\n ax = plt.gca()\n full_width = 0.8\n width = full_width / counts.shape[0]\n for i, (group, series) in enumerate(counts.iterrows()):\n left = np.arange(len(self.modality_order)) + i * width\n height = [series[i] if i in series else 0 for i in self.modality_order]\n color = phenotype_to_color[group]\n ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')\n ylabel = 'Percentage of events' if percentages else 'Number of events'\n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()"} +{"i": 484, "s": 7, "got": "def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):\n \"\"\"pass\"\"\"\n if percentages:\n counts = 100 * (counts.T / counts.T.sum()).T\n if ax is None:\n ax = plt.gca()\n full_width = 0.8\n width = full_width / counts.shape[0]\n for i, (group, series) in enumerate(counts.iterrows()):\n left = np.arange(len(self.modality_order)) + i * width\n height = [series[i] if i in group else 0 for i in self.modality_order]\n color = phenotype_to_color[group]\n ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')\n ylabel = 'Percentage of events' if percentages else 'Number of events'\n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()"} +{"i": 484, "s": 8, "got": "def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):\n \"\"\"pass\"\"\"\n if percentages:\n counts = (100 * (counts.T / counts.T.sum()).T)\n if ax is None:\n ax = plt.gca()\n full_width = 0.8\n width = full_width / counts.shape[0]\n for i, (group, series) in enumerate(counts.iterrows()):\n left = np.arange(len(self.modality_order)) + i * width\n height = [series[i] if i in group else 0 for i in self.modality_order]\n color = phenotype_to_color[group]\n ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')\n ylabel = 'Percentage of events' if percentages else 'Number of events'\n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()"} +{"i": 484, "s": 9, "got": "def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):\n \"\"\"pass\"\"\"\n if percentages:\n counts = (100 * (counts.T / counts.T.sum()).T)\n if ax is None:\n ax = plt.gca()\n full_width = 0.8\n width = full_width / counts.shape[0]\n for i, (group, series) in enumerate(counts.iterrows()):\n left = np.arange(len(self.modality_order)) + i * width\n height = [series[i] if i in group else 0 for i in self.modality_order]\n color = phenotype_to_color[group]\n ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')\n ylabel = 'Percentage of events' if percentages else 'Number of events'\n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()"} +{"i": 484, "s": 10, "got": "def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):\n \"\"\"pass\"\"\"\n if percentages:\n counts = (100 * counts.T / counts.T.sum()).T\n if ax is None:\n ax = plt.gca()\n full_width = 0.8\n width = full_width / counts.shape[0]\n for i, (group, series) in enumerate(counts.iterrows()):\n left = np.arange(len(self.modality_order)) + i * width\n height = [series[i] if i in series else 0 for i in self.modality_order]\n color = phenotype_to_color[group]\n ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')\n ylabel = 'Percentage of events' if percentages else 'Number of events'\n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()"} +{"i": 484, "s": 11, "got": "def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):\n \"\"\"pass\"\"\"\n if percentages:\n counts = (100 * (counts.T / counts.T.sum()).T)\n if ax is None:\n ax = plt.gca()\n full_width = 0.8\n width = full_width / counts.shape[0]\n for i, (group, series) in enumerate(counts.iterrows()):\n left = np.arange(len(self.modality_order)) + i * width\n height = [series[i] if i in series else 0 for i in self.modality_order]\n color = phenotype_to_color[group]\n ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')\n ylabel = 'Percentage of events' if percentages else 'Number of events'\n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()"} +{"i": 488, "s": 0, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None or not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 1, "got": "def get_next_value(sequence_name, initial_value='default', reset_value=1, *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from ..models import Sequence\n if reset_value is not None:\n assert initial_value < reset_value\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None or nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 2, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from ..models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None or nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 3, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 4, "got": "def get_next_value(sequence_name, initial_value='default', reset_value=1, *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500:\n if reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 5, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if not reset_value or initial_value < reset_value:\n assert True\n else:\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 6, "got": "def get_next_value(sequence_name, initial_value='default', reset_value=1, *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and initial_value < reset_value:\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None or not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 7, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from ..models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None or not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 8, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert True\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500:\n if reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 9, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and initial_value < reset_value:\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None or not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 10, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last\n return None"} +{"i": 488, "s": 11, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500:\n if reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 12, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert True\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and reset_value is None:\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last\n return None"} +{"i": 488, "s": 13, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and initial_value < reset_value:\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None or nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 14, "got": "def get_next_value(sequence_name, initial_value='default', reset_value=1, *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 15, "got": "def get_next_value(sequence_name, initial_value='default', reset_value=1, *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and initial_value < reset_value:\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 16, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert True\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 17, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert True\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 18, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert True\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500:\n if reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 19, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert True\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None or not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 20, "got": "def get_next_value(sequence_name, initial_value='default', reset_value=1, *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from ..models import Sequence\n if reset_value is not None and (initial_value < reset_value):\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None or nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 21, "got": "def get_next_value(sequence_name, initial_value='default', reset_value=1, *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None:\n assert initial_value < reset_value\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None) and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 22, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None:\n assert initial_value < reset_value\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None or not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 23, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert True\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and reset_value is None:\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 24, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if not reset_value is None and (not initial_value < reset_value):\n assert True\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 25, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None or nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 26, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 27, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and initial_value < reset_value:\n assert True\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None or not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 28, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert True\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None) and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 29, "got": "def get_next_value(sequence_name, initial_value='default', reset_value=1, *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert True\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and (reset_value is None or not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 488, "s": 30, "got": "def get_next_value(sequence_name, initial_value='default', reset_value=1, *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and initial_value < reset_value:\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500:\n if reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 495, "s": 0, "got": "def mptt_before_insert(mapper, connection, instance):\n \"\"\"pass\"\"\"\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n table_pk = getattr(table.c, db_pk.name)\n if instance.parent_id is None:\n instance.left = 1\n instance.right = 2\n instance.level = instance.get_default_level()\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1])) or 1\n instance.tree_id = tree_id\n else:\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n connection.execute(table.update(and_(table.c.rgt >= parent_pos_right, table.c.tree_id == parent_tree_id)).values(lft=case([(table.c.lft > parent_pos_right, table.c.lft + 2)], else_=table.c.lft), rgt=case([(table.c.rgt >= parent_pos_right, table.c.rgt + 2)], else_=table.c.rgt)))\n instance.level = parent_level + 1\n instance.tree_id = parent_tree_id\n instance.left = parent_pos_right\n instance.right = parent_pos_right + 1"} +{"i": 496, "s": 0, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n select from nodes where node is not root\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n select from nodes where node is root\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n if left_sibling_tree_id is None:\n return\n if instance.parent_id is not None:\n '\\n update nodes where node is child\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None:\n if node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n update nodes where node is child\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n else:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=table.c.tree_id + 1))\n '\\n insert node\\n '\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n elif not left_sibling_tree_id and (not left_sibling_tree_id == 0):\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n '\\n update nodes where node is child\\n '\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 1, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n ':type: tuple'\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n :type: list'\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (left_sibling_tree_id is None):\n return\n if instance.parent_id is not None:\n ':type: tuple'\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None:\n if node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n :type: tuple'\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n if not left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 2, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n\\n \\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n\\n \\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n if left_sibling_tree_id is None:\n return\n if instance.parent_id is not None:\n '\\n\\n \\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n\\n \\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n elif left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=table.c.tree_id + 1))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 3, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n Get all nodes in the subtree\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n Get the position of node within its tree\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n if left_sibling_tree_id is None:\n return\n if instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n Delete nodes after the current one\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n if not left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=table.c.tree_id + 1))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 4, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n 'mptt move'\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n 'get the position of the node'\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n if left_sibling_tree_id is None:\n return\n if instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n pass\n tree_id, parent_id, parent_pos_right, parent_pos_left, parent_tree_id = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n elif left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=table.c.tree_id + 1))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 5, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n get subtrees\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n get the position of a node\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (left_sibling_tree_id is None):\n return\n if instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n update subtrees\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 6, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n if True:\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n if left_sibling:\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n if left_sibling_tree_id is None:\n return\n else:\n if instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n pass\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n elif not (left_sibling_tree_id or left_sibling_tree_id == 0):\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(tree_id > left_sibling_tree_id).values(tree_id=table.c.tree_id + 1))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 7, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n check if the node is a leaf\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n check if the node is a leaf\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n return\n if instance.parent_id is not None:\n '\\n get the parent data\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n update the node\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n if not left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 8, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n \\n \\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n \\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n if left_sibling_tree_id is None:\n return\n elif instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n \\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = left_sibling_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=table.c.tree_id + 1))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 9, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n Get the subtree starting from the current node\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n Find the position of a node in its tree\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n if left_sibling_tree_id is None:\n return\n if instance.parent_id is not None:\n '\\n This block of code deletes the child nodes from the parent node.\\n If this node has children that are not in the subtree, it will delete them and\\n move the parent node down.\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n This block of code moves the child nodes up to the current node.\\n If this node is the last one, it will move it down.\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = left_sibling_left - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(tree_id > table.c.tree_id).values(tree_id=tree_id + 1))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))\n return"} +{"i": 496, "s": 10, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n \\n \\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n \\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n if left_sibling_tree_id is None:\n return\n if instance.parent_id is not None:\n '\\n \\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n \\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n elif left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=table.c.tree_id + 1))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 11, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n :type: list'\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n :type: list'\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n if left_sibling_tree_id is None:\n pass\n return\n elif instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n else:\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n :type: list'\n subtree = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = subtree\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n elif left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(tree_id > table.c.tree_id).values(tree_id=tree_id + 1))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 12, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n Get all nodes in the subtree from the node up to default level\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft)\n subtree = [x[0] for x in subtree]\n '\\n Get the node's position and level\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (left_sibling_tree_id is None):\n return\n if instance.parent_id is not None:\n '\\n Get the parent node\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None:\n if node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n Remove the children of the node\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=table.c.tree_id + 1))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 13, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n tree traversal\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n tree traversal\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (left_sibling_tree_id is None):\n return\n if instance.parent_id is not None:\n '\\n update child node\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n delete child node\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n elif left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 14, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n 'subtree'\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n 'subtree'\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (left_sibling_tree_id is None):\n return\n elif instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n try:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = left_sibling_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n except:\n pass\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=node_pos_left - node_pos_right + 1, rgt=node_pos_left - node_pos_right + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))\n return"} +{"i": 496, "s": 15, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n Get subtree with nodes where `instance` is the root\\n \\n :param node_id: Node ID of the parent node\\n :return: List of all subtrees as lists'\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n Get node position with level and tree id\\n \\n :param node_id: Node ID of the node to search for\\n :return: (node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level)\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (left_sibling_tree_id is None):\n return\n if instance.parent_id is not None:\n '\\n Get the position of a specific node in its subtree\\n \\n :param parent_id: Parent ID of the node to search for\\n :return: (parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level)\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n Get the position of a specific node in its subtree\\n \\n :param parent_id: Parent ID of the node to search for\\n :return: (parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level)\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = left_sibling_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=table.c.tree_id + 1))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 16, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n get subtree from db\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n get node position from db\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (left_sibling_tree_id is None):\n return\n if instance.parent_id is not None:\n '\\n get parent info from db\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n delete subtree from db\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n elif (left_sibling_tree_id or left_sibling_tree_id == 0):\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 17, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n fetch tree\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n find tree node position\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (left_sibling_tree_id is None):\n return\n if instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n delete subtree\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n if not left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 18, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n :type: list\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft)\n subtree = [x[0] for x in subtree]\n '\\n :type: list\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (left_sibling_tree_id is None):\n return\n if instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n pass\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 19, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n find subtree to delete\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n delete node if it is the last one of its siblings\\n '\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n if left_sibling_tree_id is None:\n return\n elif instance.parent_id is not None:\n '\\n find node parent\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n delete subtree\\n '\n left_sibling_tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=table.c.tree_id + 1))\n elif left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 20, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n 'add/subtract m2m relationship'\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n 'get position of the node in the tree'\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (node_pos_left - node_pos_right + 1 is None):\n return\n if instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n 'delete sub-tree'\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n 'delete sub-tree'\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 21, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n Get tree data for all nodes to be updated\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n Get data of the node to be updated\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n if left_sibling_tree_id is None:\n return\n if instance.parent_id is not None:\n '\\n Update the position of children nodes in the tree\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n else:\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n Delete the node\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 22, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n subtree nodes:\\n [0] => node id\\n [1] => parent id\\n [2] => sibling ids\\n [3] => next level sibling id\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n Get node position:\\n node pos left => tree id\\n node pos right => level + default level\\n node pos level => subtree id (left sibling)\\n node pos parent => tree_id\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n if left_sibling_tree_id is None:\n return\n if instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n else:\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n subtree nodes:\\n [0] => node id\\n [1] => parent id\\n [2] => sibling ids\\n [3] => next level sibling id\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n return\n else:\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))\n return\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))"} +{"i": 496, "s": 23, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n This is the main function of this module\\n \\n :param connection: A SQLAlchemy database connection object\\n :param mapper: The class used to define the model schema\\n :param instance: The instance being modified\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):\n if left_sibling_tree_id is None:\n return\n elif instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n :param node_size: The number of nodes in the subtree minus 1\\n :param node_pos_right: The position of the right child in the subtree\\n :param parent_node_id: The current node id\\n :param left_sibling_tree_id: The tree id of the root node\\n :param tree_id: The new tree id for the current node\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n elif left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 24, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n get subtrees\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n get node position\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (left_sibling_tree_id is None):\n return\n if instance.parent_id is not None:\n '\\n get parent id\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n else:\n '\\n delete\\n '\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n pass\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 25, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n Get the subtree nodes.\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n Check the node position.\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (left_sibling_tree_id is None):\n return\n elif instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n Get the previous node position.\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n elif not left_sibling_tree_id and left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id + 1))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 26, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n if not hasattr(instance, \\'mptt_order_before\\') and not hasattr(instance, \\'mptt_order_after\\'):\n continue\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n if not hasattr(instance, \\'mptt_order_before\\') and not hasattr(instance, \\'mptt_order_after\\'):\n continue\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id):\n if mptt_move_inside:\n return\n if left_sibling_tree_id is None:\n pass\n else:\n pass\n if instance.parent_id is not None:\n '\\n if hasattr(instance, \\'mptt_order_before\\') and (hasattr(instance, \\'mptt_order_after\\')):\n continue\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n if hasattr(instance, \\'mptt_order_before\\') and (hasattr(instance, \\'mptt_order_after\\')):\\n continue\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n if not left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 27, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n Subtree nodes:\\n - [0] node id\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n Get tree node position:\\n - node_pos_left (left)\\n - node_pos_right (right)\\n - node_tree_id\\n - node_parent_id\\n - node_level\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id):\n if mptt_move_inside:\n return\n elif left_sibling_tree_id is None:\n return\n if instance.parent_id is not None:\n '\\n Get parent position:\\n - node_pos_left (left)\\n - node_pos_right (right)\\n - node_tree_id\\n - node_level\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None:\n if node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n Update tree node:\\n - table node position\\n - lft\\n - rgt\\n - level\\n - tree id\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=table.c.tree_id + 1))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 28, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n Get the subtree\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n Find the position of node and update tree if needed\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id):\n if mptt_move_inside:\n return\n elif instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n Delete the child nodes\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n elif left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 29, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n fetch subtree\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n check node position\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (left_sibling_tree_id is None):\n return\n if instance.parent_id is not None:\n pass\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n pass\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 496, "s": 30, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n 'delete subtree if node is at the end of the tree and it has no children'\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n 'update node position if it exists and belongs to the current tree'\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id):\n return\n if instance.parent_id is not None:\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n 'delete node if it has children'\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id + 1))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 501, "s": 0, "got": "def make_request(cls, url, method=None, params=None, basic_auth=(600,)):\n \"\"\"pass\"\"\"\n params = {} if params is None else params\n cls.request_id += 1\n params = {k: v for k, v in params.items() if v is not None}\n data = {'method': method, 'params': params, 'jsonrpc': '2.0', 'id': cls.request_id}\n headers = {'Content-Type': 'application/json-rpc', 'user-agent': 'LBRY python3-api'}\n request = requests.Request('POST', url, json=data, headers=headers, auth=basic_auth)\n prepared = request.prepare()\n try:\n sesh = requests.Session()\n response = sesh.send(prepared, timeout=timeout)\n response_json = response.json()\n if 'result' in response_json:\n return (response_json['result'], response)\n elif 'error' in response_json:\n raise LBRYUtils.LBRYException('POST Request made to LBRY received an error', response_json, response.status_code, prepared)\n except requests.HTTPError as HE:\n print(HE)\n return (None, None)\n except requests.RequestException as RE:\n print(RE)\n print('Printing Request Created:\\n')\n LBRYUtils.print_request(prepared)\n return (None, None)"} +{"i": 501, "s": 1, "got": "def make_request(cls, url, method, params=None, basic_auth=None, timeout=600):\n \"\"\"pass\"\"\"\n params = {} if params is None else params\n cls.request_id += 1\n params = {k: v for k, v in params.items() if v is not None}\n data = {'method': method, 'params': params, 'jsonrpc': '2.0', 'id': cls.request_id}\n headers = {'Content-Type': 'application/json-rpc', 'user-agent': 'LBRY python3-api'}\n request = requests.Request('POST', url, json=data, headers=headers, auth=basic_auth)\n prepared = request.prepare()\n try:\n sesh = requests.Session()\n response = sesh.send(prepared, timeout=timeout)\n response_json = response.json()\n if 'result' in response_json:\n return (response_json['result'], response)\n elif 'error' in response_json:\n raise LBRYUtils.LBRYException('POST Request made to LBRY received an error', response_json, response.status_code, prepared)\n except requests.HTTPError as HE:\n print(HE)\n pass\n except requests.RequestException as RE:\n print(RE)\n print('Printing Request Created:\\n')\n LBRYUtils.print_request(prepared)\n pass\n return None"} +{"i": 501, "s": 2, "got": "def make_request(cls, url, method=None, params=None, basic_auth=600, timeout=600):\n \"\"\"pass\"\"\"\n params = {} if params is None else params\n cls.request_id += 1\n params = {k: v for k, v in params.items() if v is not None}\n data = {'method': method, 'params': params, 'jsonrpc': '2.0', 'id': cls.request_id}\n headers = {'Content-Type': 'application/json-rpc', 'user-agent': 'LBRY python3-api'}\n request = requests.Request('POST', url, json=data, headers=headers, auth=basic_auth)\n prepared = request.prepare()\n try:\n sesh = requests.Session()\n response = sesh.send(prepared, timeout=timeout)\n response_json = response.json()\n if 'result' in response_json:\n return (response_json['result'], response)\n elif 'error' in response_json:\n raise LBRYUtils.LBRYException('POST Request made to LBRY received an error', response_json, response.status_code, prepared)\n except requests.HTTPError as HE:\n print(HE)\n return (None, None)\n except requests.RequestException as RE:\n print(RE)\n print('Printing Request Created:\\n')\n LBRYUtils.print_request(prepared)\n return (None, None)"} +{"i": 501, "s": 3, "got": "def make_request(cls, url, method=None, params=None, basic_auth=(600,), timeout=600):\n \"\"\"pass\"\"\"\n params = {} if params is None else params\n cls.request_id += 1\n params = {k: v for k, v in params.items() if v is not None}\n data = {'method': method, 'params': params, 'jsonrpc': '2.0', 'id': cls.request_id}\n headers = {'Content-Type': 'application/json-rpc', 'user-agent': 'LBRY python3-api'}\n request = requests.Request('POST', url, json=data, headers=headers, auth=basic_auth)\n prepared = request.prepare()\n try:\n sesh = requests.Session()\n response = sesh.send(prepared, timeout=timeout)\n response_json = response.json()\n if 'result' in response_json:\n return (response_json['result'], response)\n elif 'error' in response_json:\n raise LBRYUtils.LBRYException('POST Request made to LBRY received an error', response_json, response.status_code, prepared)\n except requests.HTTPError as HE:\n print(HE)\n return (None, None)\n except requests.RequestException as RE:\n print(RE)\n print('Printing Request Created:\\n')\n LBRYUtils.print_request(prepared)\n return (None, None)"} +{"i": 501, "s": 4, "got": "def make_request(cls, url, method, params=None, basic_auth=None, timeout=600):\n \"\"\"pass\"\"\"\n params = {} if params is None else params\n cls.request_id += 1\n params = {k: v for k, v in params.items() if v is not None}\n data = {'method': method, 'params': params, 'jsonrpc': '2.0', 'id': cls.request_id}\n headers = {'Content-Type': 'application/json-rpc', 'user-agent': 'LBRY python3-api'}\n request = requests.Request('POST', url, json=data, headers=headers, auth=basic_auth)\n prepared = request.prepare()\n try:\n sesh = requests.Session()\n response = sesh.send(prepared, timeout=timeout)\n response_json = response.json()\n if 'result' in response_json:\n return (response_json['result'], response)\n elif 'error' in response_json:\n raise LBRYUtils.LBRYException('POST Request made to LBRY received an error', response_json, response.status_code, prepared)\n except requests.HTTPError as HE:\n print(HE)\n except requests.RequestException as RE:\n print(RE)\n print('Printing Request Created:\\n')\n LBRYUtils.print_request(prepared)\n return (None, None)"} +{"i": 501, "s": 5, "got": "def make_request(cls, url, method=None, params=None, basic_auth=(60 * 60), timeout=600):\n \"\"\"pass\"\"\"\n params = {} if params is None else params\n cls.request_id += 1\n params = {k: v for k, v in params.items() if v is not None}\n data = {'method': method, 'params': params, 'jsonrpc': '2.0', 'id': cls.request_id}\n headers = {'Content-Type': 'application/json-rpc', 'user-agent': 'LBRY python3-api'}\n request = requests.Request('POST', url, json=data, headers=headers, auth=basic_auth)\n prepared = request.prepare()\n try:\n sesh = requests.Session()\n response = sesh.send(prepared, timeout=timeout)\n response_json = response.json()\n if 'result' in response_json:\n return (response_json['result'], response)\n if 'error' in response_json:\n raise LBRYUtils.LBRYException('POST Request made to LBRY received an error', response_json, response.status_code, prepared)\n except requests.HTTPError as HE:\n print(HE)\n except requests.RequestException as RE:\n print(RE)\n print('Printing Request Created:\\n')\n LBRYUtils.print_request(prepared)\n return (None, None)"} +{"i": 501, "s": 6, "got": "def make_request(cls, url, method, params=None, basic_auth=None, timeout=600):\n \"\"\"pass\"\"\"\n params = {} if params is None else params\n cls.request_id += 1\n params = {k: v for k, v in params.items() if v is not None}\n data = {'method': method, 'params': params, 'jsonrpc': '2.0', 'id': cls.request_id}\n headers = {'Content-Type': 'application/json-rpc', 'user-agent': 'LBRY python3-api'}\n request = requests.Request('POST', url, json=data, headers=headers, auth=basic_auth)\n prepared = request.prepare()\n try:\n sesh = requests.Session()\n response = sesh.send(prepared, timeout=timeout)\n response_json = response.json()\n if 'result' in response_json:\n return (response_json['result'], response)\n elif 'error' in response_json:\n raise LBRYUtils.LBRYException('POST Request made to LBRY received an error', response_json, response.status_code, prepared)\n except requests.HTTPError as HE:\n print(HE)\n return (None, None)\n except requests.RequestException as RE:\n print(RE)\n print('Printing Request Created:\\n')\n LBRYUtils.print_request(prepared)\n return (None, None)"} +{"i": 503, "s": 0, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 1, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = (await self.raw_cdc_data()) or None\n nearest = (await self.nearest_by_coordinates(latitude, longitude)) or None\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 2, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 3, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 4, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 5, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 6, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 7, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 8, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 9, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 10, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 11, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 12, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 13, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 14, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 15, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 16, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 17, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 18, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 19, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 20, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 21, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 22, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 23, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 24, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 25, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 26, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 27, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 28, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 29, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 503, "s": 30, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 504, "s": 0, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n else:\n return adjust_status(info)"} +{"i": 504, "s": 1, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = (await self.raw_cdc_data()) or {}\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n else:\n return adjust_status(info)"} +{"i": 504, "s": 2, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n else:\n return adjust_status(info)"} +{"i": 504, "s": 3, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n else:\n return adjust_status(info)"} +{"i": 504, "s": 4, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 5, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n else:\n return adjust_status(info)"} +{"i": 504, "s": 6, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 7, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 8, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 9, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 10, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 11, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 12, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n else:\n return adjust_status(info)"} +{"i": 504, "s": 13, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n else:\n return adjust_status(info)"} +{"i": 504, "s": 14, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 15, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 16, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 17, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n else:\n return adjust_status(info)"} +{"i": 504, "s": 18, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 19, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 20, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n else:\n return adjust_status(info)"} +{"i": 504, "s": 21, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 22, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n else:\n return adjust_status(info)"} +{"i": 504, "s": 23, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 24, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 25, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 26, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 27, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n else:\n return adjust_status(info)"} +{"i": 504, "s": 28, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 29, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 504, "s": 30, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 506, "s": 0, "got": "def update(self, **kwargs):\n \"\"\"pass\"\"\"\n if self.is_valid:\n if '_id' in self._document:\n to_update = self.find_one({'_id': self._id})\n if to_update:\n before = self.before_update(old=to_update)\n if before:\n return before\n try:\n self.replace_one({'_id': self._id}, self._document)\n self.after_update(old=to_update)\n return self._document\n except PyMongoException as exc:\n return PyMongoError(error_message=exc.details.get('errmsg', exc.details.get('err', 'PyMongoError.')), operation='update', collection=type(self).__name__, document=self._document)\n else:\n return DocumentNotFoundError(type(self).__name__, self._id)\n else:\n return UnidentifiedDocumentError(type(self).__name__, self._document)\n else:\n return self._errors"} +{"i": 507, "s": 0, "got": "def delete(self, **kwargs):\n \"\"\"pass\"\"\"\n if self.is_valid:\n if '_id' in self._document:\n to_delete = self.find_one({'_id': self._id})\n if to_delete:\n before = self.before_delete()\n if before:\n return before\n else:\n try:\n self.delete_one({'_id': self._id})\n self.after_delete()\n return self._document\n except PyMongoException as exc:\n return PyMongoError(exc.details.get('errmsg', exc.details.get('err', 'PyMongoError.')), error_message='delete', operation=type(self).__name__, collection=self._document)\n else:\n return DocumentNotFoundError(type(self).__name__, self._id)\n else:\n return UnidentifiedDocumentError(type(self).__name__, self._document)"} +{"i": 507, "s": 1, "got": "def delete(self, **kwargs):\n \"\"\"pass\"\"\"\n if self.is_valid and '_id' in self._document:\n to_delete = self.find_one({'_id': self._id})\n if to_delete:\n before = self.before_delete()\n if before:\n return before\n try:\n self.delete_one({'_id': self._id})\n self.after_delete()\n return self._document\n except PyMongoException as exc:\n return PyMongoError(exc.details.get('errmsg', exc.details.get('err', 'PyMongoError.')), error_message='delete', operation=type(self).__name__, collection=self._document)\n else:\n return DocumentNotFoundError(type(self).__name__, self._id)\n elif not self.is_valid:\n raise UnidentifiedDocumentError(type(self).__name__, self._document)"} +{"i": 507, "s": 2, "got": "def delete(self, **kwargs):\n \"\"\"pass\"\"\"\n if self.is_valid:\n if '_id' in self._document:\n to_delete = self.find_one({'_id': self._id})\n if to_delete:\n before = self.before_delete()\n if before:\n return before\n else:\n try:\n self.delete_one({'_id': self._id})\n self.after_delete()\n return self._document\n except PyMongoException as exc:\n return PyMongoError(error_message=exc.details.get('errmsg', exc.details.get('err', 'PyMongoError.')), operation='delete', collection=type(self).__name__, document=self._document)\n else:\n return DocumentNotFoundError(type(self).__name__, self._id)\n else:\n return UnidentifiedDocumentError(type(self).__name__, self._document)"} +{"i": 521, "s": 0, "got": "def sendFax(self, CorpNum, SenderNum=None, ReceiverNum=None, ReceiverName=None, FilePath=False, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n receivers = []\n receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))\n return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)"} +{"i": 521, "s": 1, "got": "def sendFax(self, CorpNum=None, SenderNum=None, ReceiverNum=None, ReceiverName=None, FilePath=False, ReserveDT=None, UserID=None, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n receivers = []\n receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))\n return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)"} +{"i": 521, "s": 2, "got": "def sendFax(self, CorpNum, SenderNum=None, ReceiverNum=None, ReceiverName=None, FilePath=False, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n receivers = []\n receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))\n return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)"} +{"i": 521, "s": 3, "got": "def sendFax(self, CorpNum, SenderNum=None, ReceiverNum=None, ReceiverName=None, FilePath=False, ReserveDT=None, UserID=None, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n receivers = []\n receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))\n return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)"} +{"i": 521, "s": 4, "got": "def sendFax(self, CorpNum=None, SenderNum=None, ReceiverNum=None, ReceiverName=False, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n receivers = []\n receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))\n return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)"} +{"i": 521, "s": 5, "got": "def sendFax(self, CorpNum, SenderNum=None, ReceiverNum=None, ReceiverName=None, FilePath=False, ReserveDT=None, UserID=None, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n receivers = []\n receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))\n return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)"} +{"i": 521, "s": 6, "got": "def sendFax(self, CorpNum=None, SenderNum=None, ReceiverNum=None, ReceiverName=False, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n receivers = []\n receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))\n return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)"} +{"i": 521, "s": 7, "got": "def sendFax(self, CorpNum, SenderNum, ReceiverNum=None, ReceiverName=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n receivers = []\n receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))\n return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)"} +{"i": 521, "s": 8, "got": "def sendFax(self, CorpNum, SenderNum, ReceiverNum, ReceiverName=None, FilePath=None, ReserveDT=None, UserID=False, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n receivers = []\n receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))\n return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)"} +{"i": 521, "s": 9, "got": "def sendFax(self, CorpNum, SenderNum, ReceiverNum, ReceiverName=None, FilePath=None, ReserveDT=None, UserID=False, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n receivers = []\n receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))\n return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)"} +{"i": 521, "s": 10, "got": "def sendFax(self, CorpNum, SenderNum, ReceiverNum, ReceiverName=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n receivers = []\n receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))\n return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)"} +{"i": 521, "s": 11, "got": "def sendFax(self, CorpNum, SenderNum, ReceiverNum, ReceiverName, FilePath, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n receivers = []\n receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))\n return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)"} +{"i": 522, "s": 0, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': len(FilePath) if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 1, "got": "def sendFax_multi(self, CorpNum=None, SenderNum=None, Receiver=None, FilePath=False, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if (SenderNum == None or SenderNum == '') or (Receiver == None) or ((not type(Receiver) is str) and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list)):\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list and ((len(FilePath) < 1) or (len(FilePath) > 20)):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': len(FilePath) if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 2, "got": "def sendFax_multi(self, CorpNum, SenderNum, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if (SenderNum == None or SenderNum == '') or (Receiver == None) or (not type(Receiver) is str and (type(Receiver) is FaxReceiver or type(Receiver) is list)):\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver or not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 3, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 4, "got": "def sendFax_multi(self, CorpNum=None, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list and (len(FilePath) < 1 or len(FilePath) > 20):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 5, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) or (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n elif FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n elif type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 6, "got": "def sendFax_multi(self, CorpNum=None, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(Receiver) is str or type(Receiver) is FaxReceiver or type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list and (len(FilePath) < 1 or len(FilePath) > 20):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 7, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n elif FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n elif type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 8, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list and (len(FilePath) < 1 or len(FilePath) > 20):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 9, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 10, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n elif FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n elif type(FilePath) is list and (len(FilePath) < 1 or len(FilePath) > 20):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 11, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n elif FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n elif type(FilePath) is list and (len(FilePath) < 1 or len(FilePath) > 20):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n else:\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': ''}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 12, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n elif FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n elif type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 13, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(Receiver) is str or type(Receiver) is FaxReceiver or type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 14, "got": "def sendFax_multi(self, CorpNum=None, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list and (len(FilePath) < 1 or len(FilePath) > 20):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 15, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n elif FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n elif type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': (1 if type(FilePath) is str else len(FilePath)), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 16, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(Receiver) is str or type(Receiver) is FaxReceiver or type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n elif FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n elif type(FilePath) is list and (len(FilePath) < 1 or len(FilePath) > 20):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 17, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 18, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(Receiver) is str or type(Receiver) is FaxReceiver or type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n elif FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 19, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list and ((len(FilePath) < 1) or (len(FilePath) > 20)):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 20, "got": "def sendFax_multi(self, CorpNum=None, SenderNum=None, Receiver=None, FilePath=False, ReserveDT=None, UserID=None, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(Receiver) is str or type(Receiver) is FaxReceiver or type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list and len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 21, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif not (type(Receiver) is str or type(Receiver) is FaxReceiver or type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n elif FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n elif type(FilePath) is list and (len(FilePath) < 1 or len(FilePath) > 20):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n else:\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n elif type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 22, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 23, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n elif type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': [1 if type(FilePath) is str else len(FilePath)], 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 24, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(Receiver) is str or type(Receiver) is FaxReceiver or type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list and (len(FilePath) < 1 or len(FilePath) > 20):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 25, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 26, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(Receiver) is str or type(Receiver) is FaxReceiver or type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n elif FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n elif type(FilePath) is list and (len(FilePath) < 1 or len(FilePath) > 20):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 27, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(Receiver) is str or type(Receiver) is FaxReceiver or type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list and (len(FilePath) < 1 or len(FilePath) > 20):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 28, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(Receiver) is str or type(Receiver) is FaxReceiver or type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n elif FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 29, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(Receiver) is str or type(Receiver) is FaxReceiver or type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n elif FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list and (len(FilePath) < 1 or len(FilePath) > 20):\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 522, "s": 30, "got": "def sendFax_multi(self, CorpNum=None, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(Receiver) is str or type(Receiver) is FaxReceiver or type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n if FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not (type(FilePath) is str or type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n if type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 524, "s": 0, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 1, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 2, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 3, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 4, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 5, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 6, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 7, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 8, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 9, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 10, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 11, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 12, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 13, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 14, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 15, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 16, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 17, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 18, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 19, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 20, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 21, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 22, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 23, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 24, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 25, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 26, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 27, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 28, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 29, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 524, "s": 30, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 525, "s": 0, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 1, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in await self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return (await self.status_by_coordinates(float(location['latitude']), float(location['longitude'])))"} +{"i": 525, "s": 2, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return (yield from self.status_by_coordinates(float(location['latitude']), float(location['longitude'])))"} +{"i": 525, "s": 3, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 4, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 5, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 6, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 7, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return (await self.status_by_coordinates(float(location['latitude']), float(location['longitude'])))"} +{"i": 525, "s": 8, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 9, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 10, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 11, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 12, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 13, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 14, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 15, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 16, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 17, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 18, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 19, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 20, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return (yield from self.status_by_coordinates(float(location['latitude']), float(location['longitude'])))"} +{"i": 525, "s": 21, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 22, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 23, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 24, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 25, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 26, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 27, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n else:\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 28, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 29, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 525, "s": 30, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 526, "s": 0, "got": "def print_request(request):\n \"\"\"pass\"\"\"\n print('{}\\n{}\\n{}\\n\\n{}'.format('-----------START-----------', request.method + ' ' + request.url, '\\n'.join(('{}: {}'.format(k, v) for k, v in request.headers.items())), request.body))"} +{"i": 527, "s": 0, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 1, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is None:\n continue\n elif len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body'):\n if request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 2, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body and request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 3, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 4, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 5, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body'):\n if request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 6, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params'):\n if data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 7, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body and request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 8, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 9, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 10, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 11, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 12, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 13, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 14, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 15, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 16, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 17, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 18, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 19, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 20, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body and request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 21, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body'):\n if request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params'):\n if data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 22, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 23, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 24, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body'):\n if request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 25, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 26, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 27, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 28, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 29, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body and request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 527, "s": 30, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 528, "s": 0, "got": "def filter_validate_response(get_response, params):\n \"\"\"pass\"\"\"\n schema = params.get('response_schema')\n\n async def decorated_filter(request, *args, **kwargs):\n response = await get_response(request, *args, **kwargs)\n if isinstance(response, HTTPResponse) and (not isinstance(response, Response)):\n return response\n elif not isinstance(response, Response):\n raise TypeError('response is not an instance of rafter.http.Response.')\n else:\n if schema:\n data = {'body': response.data, 'headers': response.headers}\n try:\n model = schema(data, strict=False, validate=False)\n model.validate()\n result = model.to_primitive()\n response.body = result.get('body', None)\n response.headers.update(result.get('headers', {}))\n except BaseError as e:\n log.exception(e)\n abort(500, 'Wrong data output')\n return response\n return decorated_filter"} +{"i": 532, "s": 0, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 1, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n async with ClientSession() as websession:\n pass\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 2, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 3, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 4, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 5, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 6, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 7, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp: typing.AsyncGenerator[FluNearYouError, None] = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp: typing.AsyncGenerator[FluNearYouError, None] = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp: typing.AsyncGenerator[FluNearYouError, None] = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 8, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 9, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 10, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 11, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 12, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 13, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 14, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 15, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 16, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 17, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 18, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 19, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 20, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 21, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 22, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 23, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 24, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 25, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 26, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 27, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 28, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 29, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp: typing.Awaitable[bool] = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp: typing.Awaitable[bool] = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp: typing.Awaitable[bool] = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 532, "s": 30, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 534, "s": 0, "got": "def concatenate(fname1, fname2=None, dfilter1=None, dfilter2=True, has_header1=True, has_header2=0, frow1=0, frow2=None, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n if iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols)):\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and len(obj1.cfilter) != len(obj2.cfilter))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 1, "got": "def concatenate(fname1=None, fname2=None, dfilter1=True, dfilter2=True, has_header1=0, has_header2=0, frow1=None, frow2=None, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None and (not has_header1):\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None and (has_header2):\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = [] if ocols is None else ocols\n iom((obj1.cfilter is not None) and len(obj1.cfilter) != len(ocols))\n data = (iro(_C(obj1.cfilter, obj2.cfilter)) and (len(obj1.cfilter) != len(obj2.cfilter))) + [ocols] + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 2, "got": "def concatenate(fname1, fname2=None, dfilter1=None, dfilter2=True, has_header1=True, has_header2=0, frow1=0, frow2=None, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 3, "got": "def concatenate(fname1, fname2=None, dfilter1=None, dfilter2=True, has_header1=True, has_header2=0, frow1=0, frow2=None, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n if iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols)):\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 4, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 5, "got": "def concatenate(fname1, fname2=None, dfilter1=None, dfilter2=True, has_header1=True, has_header2=0, frow1=0, frow2=None, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None and has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None and has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = [] if ocols is None else ocols\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 6, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1 and obj1.cfilter is None:\n ocols = [obj1.header()]\n elif not ocols:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n elif ocols is None:\n if has_header2 and obj2.cfilter is None:\n ocols = [obj2.header()] if not ocols else [obj2.cfilter]\n else:\n ocols = []\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 7, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n if iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols)):\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 8, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = []\n else:\n if iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols)):\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 9, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None and has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = [] if ocols is None else ocols\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n data = (iro(_C(obj1.cfilter, obj2.cfilter), len(obj1.cfilter) != len(obj2.cfilter))) + [ocols] + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(ofname=ofname, data=data, append=False)"} +{"i": 534, "s": 10, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n if iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols)):\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 11, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = []\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n data = (iro(_C(obj1.cfilter, obj2.cfilter) and len(obj1.cfilter) != len(obj2.cfilter)) + [ocols] + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 12, "got": "def concatenate(fname1, fname2=None, dfilter1=None, dfilter2=True, has_header1=True, has_header2=0, frow1=0, frow2=None, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n if not iom(obj1.cfilter is None and len(obj1.cfilter) != len(ocols)):\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 13, "got": "def concatenate(fname1, fname2=None, dfilter1=None, dfilter2=True, has_header1=True, has_header2=0, frow1=0, frow2=None, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1 and obj1.cfilter is None:\n ocols = [obj1.header()]\n elif not ocols:\n ocols = [obj2.header()] if obj2.cfilter is None else obj2.cfilter\n else:\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n ocols = [ocols]\n elif ocols is None:\n if has_header2 and obj2.cfilter is None:\n ocols = [obj2.header()] if obj2.cfilter is None else obj2.cfilter\n else:\n ocols = []\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 14, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n if iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols)):\n ocols = [ocols]\n ocols = []\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 15, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1 and obj1.cfilter is None:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None and has_header2 and (obj2.cfilter is None):\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n elif ocols is None:\n if has_header2 and obj2.cfilter is None:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = []\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n data = (iro(_C(obj1.cfilter, obj2.cfilter) and len(obj1.cfilter) != len(obj2.cfilter)) + [ocols] + obj2.data(filtered=True))\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 16, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = [] if ocols is None else ocols\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(ocols)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 17, "got": "def concatenate(fname1, fname2=None, dfilter1=None, dfilter2=True, has_header1=True, has_header2=0, frow1=0, frow2=None, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = []\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 18, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 19, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n if ocols is None:\n ocols = []\n iom((obj1.cfilter is not None) and (len(obj1.cfilter) != len(ocols)))\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 20, "got": "def concatenate(fname1, fname2=None, dfilter1=None, dfilter2=True, has_header1=True, has_header2=0, frow1=0, frow2=None, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1 and (obj1.cfilter is None or len(obj1.cfilter) != len(ocols)):\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2 and (obj2.cfilter is None or len(obj2.cfilter) != len(ocols)):\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = []\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 21, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = []\n else:\n if iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols)):\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 22, "got": "def concatenate(fname1, fname2=None, dfilter1=None, dfilter2=True, has_header1=True, has_header2=0, frow1=0, frow2=None, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1 and (obj1.cfilter is None or len(obj1.cfilter) != len(ocols)):\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2 and (obj2.cfilter is None or len(obj2.cfilter) != len(ocols)):\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = []\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 23, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n if not iom(obj1.cfilter is None and len(obj1.cfilter) != len(ocols)):\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 24, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None and has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None and has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = [] if ocols is None else ocols\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 25, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n if iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols)):\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 26, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = []\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 27, "got": "def concatenate(fname1, fname2=None, dfilter1=None, dfilter2=True, has_header1=True, has_header2=0, frow1=0, frow2=None, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None and has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = [] if ocols is None else ocols\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 28, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = [] if ocols is None else ocols\n iom((obj1.cfilter is not None and len(obj1.cfilter) != len(ocols)))\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 29, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None and has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = [] if ocols is None else ocols\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 534, "s": 30, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n ocols = []\n iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 541, "s": 0, "got": "def _run(passedArgs=None, stderr=None, stdout=None, exitFn=None):\n \"\"\"pass\"\"\"\n description = 'Finds the next available file-name in a sequence.\\n\\n This program will create a file of zero size and will output the path to it\\n on STDOUT. No files which exist will be altered in this operation and\\n concurrent invocations of this program will return separate files. In case\\n of conflict, this program will attempt to generate a new file name up to\\n \\'maxattempts\\' number of times before failing. (See --max-attempts)\\n\\n The sequence will start from the base argument (See --base, default: 0).\\n\\n This program will look for the next file in the sequence ignoring any gaps.\\n Hence, if the files \"a.0.txt\" and \"a.3.txt\" exist, then the next file\\n returned will be \"a.4.txt\" when called with prefix=\"a.\" and suffix=\".txt\".\\n\\n Returns:\\n Path of the file which follows the provided pattern and can be opened\\n for writing.\\n\\n Otherwise, it prints an error (wrong path, drive full, illegal\\n character in filename, etc.) to stderr and exits with a non-zero error\\n code.\\n \"\"\"\n argParser = _argparse.ArgumentParser(description=description, formatter_class=_argparse.RawTextHelpFormatter)\n argParser.add_argument('prefix', help='Prefix for the sequence of files.')\n argParser.add_argument('suffix', help='Suffix for the sequence of files.', nargs='?', default='')\n argParser.add_argument('folder', help='The folder where the file will be created.', nargs='?', default=_os.getcwd())\n argParser.add_argument('-m', '--max-attempts', help='Number of attempts to make before giving up.', default=10)\n argParser.add_argument('-b', '--base', help='From where to start counting (default: 0).', default=0)\n passedArgs = passedArgs if passedArgs is not None else _sys.argv[1:]\n args = argParser.parse_args(passedArgs)\n stdout = _sys.stdout if stdout is None else stdout\n stderr = _sys.stderr if stderr is None else stderr\n try:\n nextFile = findNextFile(args.folder, prefix=args.prefix, suffix=args.suffix, maxattempts=args.max_attempts, base=args.base)\n stdout.write(nextFile + '\\n')\n except OSError as e:\n stderr.write(_os.strerror(e.errno) + '\\n')\n _sys.exit(e.errno)"} +{"i": 541, "s": 1, "got": "def _run(passedArgs=None, stderr=None, stdout=None, exitFn=None):\n \"\"\"pass\"\"\"\n description = 'Finds the next available file-name in a sequence.\\n\\n This program will create a file of zero size and will output the path to it\\n on STDOUT. No files which exist will be altered in this operation and\\n concurrent invocations of this program will return separate files. In case\\n of conflict, this program will attempt to generate a new file name up to\\n ' + '\\'maxattempts\\'' + ' number of times before failing. (See --max-attempts)\\n\\n The sequence will start from the base argument (See --base, default: 0).\\n\\n This program will look for the next file in the sequence ignoring any gaps.\\n Hence, if the files \"a.0.txt\" and \"a.3.txt\" exist, then the next file\\n returned will be \"a.4.txt\" when called with prefix=\"a.\" and suffix=\".txt\".\\n\\n Returns:\\n Path of the file which follows the provided pattern and can be opened\\n for writing.\\n\\n Otherwise, it prints an error (wrong path, drive full, illegal\\n character in filename, etc.) to stderr and exits with a non-zero error\\n code.\\n '\n argParser = _argparse.ArgumentParser(description=description, formatter_class=_argparse.RawTextHelpFormatter)\n argParser.add_argument('prefix', help='Prefix for the sequence of files.')\n argParser.add_argument('suffix', help='Suffix for the sequence of files.', nargs='?', default='')\n argParser.add_argument('folder', help='The folder where the file will be created.', nargs='?', default=_os.getcwd())\n argParser.add_argument('-m', '--max-attempts', help='Number of attempts to make before giving up.', default=10)\n argParser.add_argument('-b', '--base', help='From where to start counting (default: 0).', default=0)\n passedArgs = passedArgs if passedArgs is not None else _sys.argv[1:]\n args = argParser.parse_args(passedArgs)\n stdout = _sys.stdout if stdout is None else stdout\n stderr = _sys.stderr if stderr is None else stderr\n try:\n nextFile = findNextFile(args.folder, prefix=args.prefix, suffix=args.suffix, maxattempts=args.max_attempts, base=args.base)\n stdout.write(nextFile + '\\n')\n except OSError as e:\n stderr.write(_os.strerror(e.errno) + '\\n')\n _sys.exit(e.errno)"} +{"i": 545, "s": 0, "got": "def _prevalidationCheck(value, blank, strip, allowlistRegexes, blocklistRegexes, excMsg=None):\n \"\"\"pass\"\"\"\n value = str(value)\n value = _getStrippedValue(value, strip)\n if not blank and value == '':\n _raiseValidationException(_('Blank values are not allowed.'), excMsg)\n elif blank and value == '':\n return (True, value)\n else:\n if allowlistRegexes is not None:\n for regex in allowlistRegexes:\n if isinstance(regex, re.Pattern):\n if regex.search(value, re.IGNORECASE) is not None:\n return (True, value)\n elif re.search(regex, value, re.IGNORECASE) is not None:\n return (True, value)\n else:\n if blocklistRegexes is not None:\n for blocklistRegexItem in blocklistRegexes:\n if isinstance(blocklistRegexItem, str):\n regex, response = (blocklistRegexItem, DEFAULT_BLOCKLIST_RESPONSE)\n else:\n regex, response = blocklistRegexItem\n if isinstance(regex, re.Pattern) and regex.search(value, re.IGNORECASE) is not None:\n _raiseValidationException(response, excMsg)\n elif re.search(regex, value, re.IGNORECASE) is not None:\n _raiseValidationException(response, excMsg)\n return (False, value)"} +{"i": 545, "s": 1, "got": "def _prevalidationCheck(value, blank, strip, allowlistRegexes, blocklistRegexes, excMsg=None):\n \"\"\"pass\"\"\"\n value = str(value)\n value = _getStrippedValue(value, strip)\n if not blank and value == '':\n _raiseValidationException(_('Blank values are not allowed.'), excMsg)\n elif blank:\n if value == '':\n return (True, value)\n if allowlistRegexes is not None:\n for regex in allowlistRegexes:\n if isinstance(regex, re.Pattern):\n if regex.search(value, re.IGNORECASE) is not None:\n return (True, value)\n elif re.search(regex, value, re.IGNORECASE) is not None:\n return (True, value)\n if blocklistRegexes is not None:\n for blocklistRegexItem in blocklistRegexes:\n if isinstance(blocklistRegexItem, str):\n regex, response = (blocklistRegexItem, DEFAULT_BLOCKLIST_RESPONSE)\n else:\n regex, response = blocklistRegexItem\n if isinstance(regex, re.Pattern) and regex.search(value, re.IGNORECASE) is not None:\n _raiseValidationException(response, excMsg)\n elif re.search(regex, value, re.IGNORECASE) is not None:\n _raiseValidationException(response, excMsg)\n return (False, value)"} +{"i": 552, "s": 0, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {before}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 1, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, n=rev_id, ids=page_id, added={radius + 1, 'sha1', 'timestamp', 'ids'}, rvprop=rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, n=rev_id + 1, timestamp=page_id, rvprop=radius, added={before, 'sha1', 'timestamp', 'ids'}, rvprop=rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 2, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, n=radius + 1, rvprop={'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, timestamp=before, rvprop={'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 3, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {before}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 4, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {before: set() | {'sha1', 'timestamp', 'ids'} | rvprop}))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 5, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError(u'Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {before: set(), 'sha1': 'timestamp', 'ids': 'sha1' | rvprop}))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 6, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, n=rev_id, page_id=page_id, radius=radius + 1, extra={'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, n=rev_id + 1, timestamp=page_id, rvprop=radius, extra={'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 7, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {before}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 8, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, n=rev_id + 1, timestamp=page_id, rvprop=radius, set={'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 9, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, n=rev_id + 1, timestamp=page_id, rvprop=radius, before={before, 'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 10, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 11, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, before, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 12, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {before} | {'sha1', 'timestamp', 'ids'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 13, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, n=rev_id + 1, timestamp=page_id, rvprop=radius, set={'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 14, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {before, 'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 15, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, before, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 16, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 17, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {before} | {'sha1', 'timestamp', 'ids'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 18, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {before} | {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 19, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {before: set()} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 20, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, n=radius + 1, rvprop={'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, n=before, rvprop={'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 21, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError(u'Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 22, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, n=rev_id + 1, timestamp=page_id, rvprop=radius, before={before, 'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 23, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {before} | {'sha1', 'timestamp', 'ids'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 24, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError(u'Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, n=rev_id + 1, timestamp=page_id, rvprop=radius, before=before, rvprop={'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 25, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 26, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 27, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, n=radius + 1, rvprop={'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, timestamp=before, rvprop={'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 28, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {before} | {'sha1', 'timestamp', 'ids'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 29, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, before, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 552, "s": 30, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, n=rev_id + 1, timestamp=page_id, rvprop=radius, timestamp_before=before, rvprop=frozenset({'sha1', 'timestamp', 'ids'}) | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 0, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 1, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if timestamp is None or title is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, {before, 'sha1', 'timestamp', 'ids'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 2, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if timestamp is None or title is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 3, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 4, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, {before, 'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 5, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before=before, rvprop={'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 6, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError(u'Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, {before}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 7, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'ids', 'sha1', 'timestamp'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'ids', 'timestamp'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 8, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 9, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 10, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 11, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, n=rev_id + 1, before=title, rvprop=timestamp, radius=radius, nbefore=before, rsvprop=frozenset({'sha1', 'timestamp', 'ids'}) | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 12, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 13, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, {before} | {'sha1', 'timestamp', 'ids'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 14, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 15, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, {before}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 16, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, {before, 'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 17, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, {before, 'sha1', 'timestamp', 'ids'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 18, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 19, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before=before, rvprop={'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 20, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if timestamp is None or title is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 21, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, n=rev_id + 1, title=title, timestamp=timestamp, radius=radius, before=before, rvprop={'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 22, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 23, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 24, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 25, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 26, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, {before}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 27, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, n=rev_id + 1, title=title, timestamp=timestamp, radius=radius, before=before, rvprop={'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 28, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, n=before, before=frozenset({'sha1', 'timestamp', 'ids'}) | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 29, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'ids', 'sha1', 'timestamp'}, rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, n=rev_id + 1, before=title, rvprop=timestamp, radius=radius, before=before, rvprop={'ids', 'sha1', 'timestamp'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "s": 30, "got": "def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, n=rev_id + 1, before=title, rvprop=timestamp, radius=radius, before={before: {'sha1', 'timestamp', 'ids'}} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 560, "s": 0, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, list, str) and (not isinstance(dfilter, int) or (not isinstance(dfilter, bool))):\n if None is not isinstance(dfilter, list):\n dfilter = (dfilter, )\n else:\n dfilter = ([dfilter], )\n elif isinstance(dfilter[0], dict) or (dfilter[0] is None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 1, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or (dfilter == (None, None)) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not (isinstance(dfilter, list, str) or (isinstance(dfilter, int) and (not isinstance(dfilter, bool)))):\n if not (isinstance(dfilter[0], dict) or ((dfilter[0] is None or isinstance(dfilter[1], dict)))):\n pass\n else:\n return dfilter\n dfilter = ([dfilter[1]], dfilter[0])\n elif isinstance(dfilter[0], dict):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 2, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif isinstance(dfilter, (list, str)) and (not isinstance(dfilter, bool) or not isinstance(dfilter, int)):\n if None and (isinstance(dfilter, list) or (not isinstance(dfilter, list))):\n dfilter = (dfilter,)\n else:\n dfilter = ([], dfilter)\n elif isinstance(dfilter[0], dict) or (dfilter[0] is None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = (filter(df.filter, dfilter[0]), dfilter[0])\n return dfilter"} +{"i": 560, "s": 3, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, list, str) and (not isinstance(dfilter, int) or (isinstance(dfilter, bool))):\n if isinstance(dfilter, 0) and (isinstance(dfilter[1], dict) or dfilter[0] is None):\n pass\n else:\n dfilter = ([dfilter[1]], dfilter[0])\n elif not isinstance(dfilter[0], dict) and (not dfilter[0] is None or isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 4, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, list, str) and (not isinstance(dfilter, int) and (not isinstance(dfilter, bool))):\n if isinstance(dfilter[0], dict) or (dfilter[0] is None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = [dfilter]\n elif isinstance(dfilter[0], dict):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 5, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not ((isinstance(dfilter, (list, str)) and isinstance(dfilter, bool)) or (not (isinstance(dfilter, int) and isinstance(dfilter, bool)))) and (not (isinstance(dfilter[0], dict) or (dfilter[0] is None and isinstance(dfilter[1], dict)))Bridge\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 6, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not (isinstance(dfilter, list, str) and (not (isinstance(dfilter, bool) and isinstance(dfilter, int)))):\n if isinstance(dfilter[0], dict) or (filter is None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = ([dfilter[1]], dfilter[0])\n elif isinstance(dfilter[0], dict):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 7, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif isinstance(dfilter, (list, str)) and (not isinstance(dfilter, bool) and not isinstance(dfilter, int)):\n if isinstance(dfilter[0], dict) or (filter is not None and isinstance(filter[1], dict)):\n pass\n else:\n dfilter = [dfilter]\n elif isinstance(dfilter[0], dict):\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 8, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, list, str) and (not (isinstance(dfilter, int) and isinstance(dfilter, bool))):\n if None in (isinstance(dfilter, list), dfilter):\n dfilter = (filter, dfilter)\n else:\n dfilter = ([], dfilter)\n elif isinstance(dfilter[0], dict) or (dfilter[0] is None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = (filter, dfilter[1])\n return dfilter"} +{"i": 560, "s": 9, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not (isinstance(dfilter, (list, str)) or (isinstance(dfilter, int) and (not isinstance(dfilter, bool)))):\n if isinstance(dfilter, 0) or (filter[0] is None and (isinstance(filter[1], dict))):\n pass\n else:\n dfilter = [dfilter[1], dfilter[0]]\n elif isinstance(dfilter[0], dict):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 10, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, list, str) and (not (isinstance(dfilter, int) and isinstance(dfilter, bool))):\n if isinstance(dfilter[0], dict) or (filter is None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = [dfilter]\n elif isinstance(dfilter[0], dict):\n pass\n else:\n dfilter = (filter[1], filter[0])\n return dfilter"} +{"i": 560, "s": 11, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, list, str) and (not (isinstance(dfilter, int) and (not isinstance(dfilter, bool)))):\n if None and (isinstance(dfilter, list)):\n dfilter = (dfilter,)\n else:\n dfilter = ([dfilter],)\n elif isinstance(dfilter[0], dict):\n if dfilter[0] is None or isinstance(dfilter[1], dict):\n pass\n else:\n pass\n else:\n dfilter = (filter, dfilter[0])\n return dfilter"} +{"i": 560, "s": 12, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, list, str) and (not isinstance(dfilter, int) and (not isinstance(dfilter, bool))):\n if isinstance(dfilter, 0) and (filter[0] is None or isinstance(filter[1], dict)):\n pass\n else:\n dfilter = (dfilter, 1)\n elif isinstance(dfilter[0], dict):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 13, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not (isinstance(dfilter, list, str) or (isinstance(dfilter, int) and (not isinstance(dfilter, bool)))):\n if isinstance(dfilter, 0) and (filter[0] is not None or isinstance(filter[1], dict)):\n pass\n else:\n dfilter = ([dfilter[1]], dfilter)\n elif isinstance(dfilter[0], dict):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 14, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not (isinstance(dfilter, (list, str)) and (not (isinstance(dfilter, bool) and isinstance(dfilter, int)))) and (not (isinstance(dfilter[0], dict) or dfilter[0] is None or not isinstance(dfilter[1], dict))):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 15, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, (list, str)) and (not (isinstance(dfilter, int) and isinstance(dfilter, bool))):\n if isinstance(dfilter[0], dict) or (dfilter[0] is not None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = ([dfilter[1]], dfilter[0])\n elif isinstance(dfilter[0], dict):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 16, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not (isinstance(dfilter, list, str) and (not isinstance(dfilter, bool))):\n if isinstance(dfilter[0], dict) or (filter is None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = [dfilter]\n elif isinstance(dfilter[0], dict):\n if filter is None or (filter is not None and isinstance(filter[0], str)):\n return dfilter\n else:\n dfilter = (filter[1], filter[0])\n else:\n dfilter = (filter[1], filter[0])\n return dfilter"} +{"i": 560, "s": 17, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, list, str) and (not isinstance(dfilter, int) and (not isinstance(dfilter, bool))):\n if isinstance(dfilter[0], dict) or (dfilter[0] is None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = [dfilter[1], dfilter[0]]\n elif isinstance(dfilter[0], dict):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 18, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, list, str) and (not isinstance(dfilter, int) and isinstance(dfilter, bool)):\n if isinstance(dfilter[0], dict) or (filter is None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = [dfilter]\n elif not isinstance(dfilter[0], dict) and (filter[0] is None or (isinstance(filter[1], dict))):\n pass\n else:\n dfilter = (dfilter[1], filter[0])\n return dfilter"} +{"i": 560, "s": 19, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not (isinstance(dfilter, list, str) and (not (isinstance(dfilter, bool) or isinstance(dfilter, int)))) or (isinstance(dfilter[0], dict) and (filter(0) is None or isinstance(filter(1), dict))):\n pass\n else:\n dfilter = dfilter[1]\n if dfilter[0] is not None or isinstance(dfilter[1], dict):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 20, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif isinstance(dfilter, (list, str)) or (isinstance(dfilter, int) and (not isinstance(dfilter, bool))):\n if isinstance(dfilter, list):\n dfilter = (dfilter,)\n else:\n dfilter = ([dfilter],)\n elif isinstance(dfilter[0], dict) or (filter is None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = (filter[1], filter[0])\n return dfilter"} +{"i": 560, "s": 21, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, (list, str)) and (not (isinstance(dfilter, int) and isinstance(dfilter, bool))):\n if None is not isinstance(dfilter, list):\n dfilter = (dfilter,)\n else:\n dfilter = ([dfilter],)\n elif isinstance(dfilter[0], dict) or (dfilter[0] is None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 22, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, (list, str)) or (isinstance(dfilter, int) and (not isinstance(dfilter, bool))):\n if isinstance(dfilter, list):\n dfilter = (dfilter,)\n else:\n dfilter = ([], dfilter)\n elif isinstance(dfilter[0], dict) or (dfilter[0] is None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 23, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, list, str) and (not isinstance(dfilter, int) and (not isinstance(dfilter, bool))):\n if isinstance(dfilter, 0) and (filter[0] is None or isinstance(filter[1], dict)):\n pass\n else:\n dfilter = ([dfilter],)\n elif isinstance(dfilter[0], dict):\n pass\n else:\n dfilter = (filter[1], filter[0])\n return dfilter"} +{"i": 560, "s": 24, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not ((isinstance(dfilter, (list, str)) and (not isinstance(dfilter, bool))) or (isinstance(dfilter, int) and (not isinstance(dfilter, bool))):\n if isinstance(dfilter[0], dict) or (filter is not None and isinstance(filter[1], dict)):\n pass\n else:\n dfilter = ([dfilter[1]], dfilter)\n elif filter == 0:\n while True:\n if filter == 0:\n break\n filter = filter[1]\n else:\n dfilter = (filter[1], filter[0])\n return dfilter"} +{"i": 560, "s": 25, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not (isinstance(dfilter, (list, str)) and (not (isinstance(dfilter, bool) or isinstance(dfilter, int))) or (None if isinstance(dfilter, list) else [dfilter])):\n dfilter = (dfilter, dfilter[0])\n elif isinstance(dfilter[0], dict):\n if dfilter[0] is None or (not isinstance(dfilter[1], dict)):\n pass\n else:\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 26, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not (isinstance(dfilter, (list, str)) and (not isinstance(dfilter, bool))):\n if isinstance(dfilter, 0) or (dfilter[0] is None and isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = ([dfilter[1]], dfilter[0])\n elif isinstance(dfilter[0], dict):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 27, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not (isinstance(dfilter, (list, str)) or (isinstance(dfilter, int) and (not isinstance(dfilter, bool)))):\n if isinstance(dfilter, list):\n dfilter = (dfilter,)\n else:\n dfilter = ([dfilter],)\n elif isinstance(dfilter[0], dict):\n if dfilter[0] is None or (isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = (filter, 0)\n else:\n dfilter = (filter[1], filter[0])\n return dfilter"} +{"i": 560, "s": 28, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not (isinstance(dfilter, (list, str)) and (not isinstance(dfilter, bool))):\n if isinstance(dfilter, 0) and (dfilter[0] is None or isinstance(dfilter[1], dict)):\n pass\n else:\n dfilter = ([dfilter[1]], dfilter[0])\n elif not isinstance(dfilter[0], dict):\n if dfilter[0] is None or isinstance(dfilter[1], dict):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 29, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif isinstance(dfilter, (list, str)) and (not (isinstance(dfilter, bool) and isinstance(dfilter, int))):\n if not (isinstance(dfilter[0], dict) or (dfilter[0] is None and isinstance(dfilter[1], dict))):\n pass\n else:\n return dfilter\n elif isinstance(dfilter[0], dict):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 560, "s": 30, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not isinstance(dfilter, (list, str)) and (not (isinstance(dfilter, int) and isinstance(dfilter, bool))):\n if isinstance(dfilter, 0) or ((filter is None or filter is not None) and isinstance(filter[1], dict)):\n pass\n else:\n dfilter = [(dfilter[1],)]\n elif isinstance(dfilter[0], dict) or (filter is None and isinstance(filter[1], dict)):\n pass\n else:\n dfilter = (filter[1], dfilter[0])\n return dfilter"} +{"i": 579, "s": 0, "got": "def get_lbry_api_function_docs(url=LBRY_API_RAW_JSON_URL):\n \"\"\"pass\"\"\"\n try:\n docs_page = urlopen(url)\n contents = docs_page.read().decode('utf-8')\n return loads(contents)\n except URLError as UE:\n print(UE)\n return []\n except Exception as E:\n print(E)\n return []"} +{"i": 579, "s": 1, "got": "def get_lbry_api_function_docs(url=LBRY_API_RAW_JSON_URL):\n \"\"\"pass\"\"\"\n try:\n docs_page = urlopen(url)\n contents = docs_page.read().decode('utf-8')\n return loads(contents)\n except URLError as UE:\n print(UE)\n except Exception as E:\n print(E)\n return []"} +{"i": 580, "s": 0, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += ('\\n' if param['is_required'] else ' (Optional)\\n')\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n num_params, params_indent = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 1, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '''\"\"\"'' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index and func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (i + 1 < num_params and indent or '') + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 2, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + ' is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 3, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n num_params, params_indent = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent if i + 1 < num_params else ''\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 4, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'], open_index, close_index + 1)\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n num_params, params_indent = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 5, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += ('\\n' if param['is_required'] else ' (Optional)\\n')\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'], open_index, close_index + 1)\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent = len(params_map) + len(params_required) + len(params_optional)\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (i + 1 < num_params and i + 2 or '')\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 6, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', max(open_index, -1) if open_index > -1 else 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n num_params, params_indent = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 7, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * (indent + 2)\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * (indent + 2)\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - indent + 2):\n method_definition += return_string[i:i + 80 - indent + 2] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + ' is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent + 'return self.make_request(SERVER_ADDRESS, \\'' + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 8, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += ('\\n' if param['is_required'] else ' (Optional)\\n')\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - indent + 2] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent + \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 9, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1) if open_index is not None else 0\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index and func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'], open_index, close_index + 1)\n else:\n method_definition += '\\n' + ' ' * (indent + 2)\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - indent + 2):\n method_definition += return_string[i:i + 80 - indent + 2] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + ' is not None else None'\n method_definition += ',\\n' + (' ' * (indent + 1) + ' ' * params_indent) if i + 1 < num_params else ''\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 10, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += ('\\n' if param['is_required'] else ' (Optional)\\n')\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent = len(params_map) + len(params_required) + len(params_optional)\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + ' is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 11, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += ('\\n' if param['is_required'] else ' (Optional)\\n')\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index and func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"'\n params_map = '__params_map = {'\n num_params, params_indent = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 12, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1 - 80, indent + 2):\n method_definition += return_string[i:i + 80 - indent + 2] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n num_params = len(params_map) + (len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 13, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 14, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - indent + 2):\n method_definition += return_string[i:i + 80 - indent + 2] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n num_params, params_indent = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + ' is not None else None'\n method_definition += ',\\n' + ' ' * (i + 1 < num_params and indent or '')\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 15, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += ('\\n' if param['is_required'] else ' (Optional)\\n')\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1 - 80, indent + 2):\n method_definition += return_string[i:i + 80 - indent + 2] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + ' is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 16, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n num_params, params_indent = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 17, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += ('\\n' if param['is_required'] else ' (Optional)\\n')\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent + \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 18, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += ('\\n' if param['is_required'] else ' (Optional)\\n')\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - indent + 2):\n method_definition += return_string[i:i + 80 - indent + 2] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}'\n\n method_definition += '\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 19, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'], open_index, close_index + 1)\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + params_indent if i < 1 + num_params else ''\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 20, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1) if open_index > -1 else 0\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string), 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'%s': '%s' \" % (param['name'], param['name'])\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 21, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += ('\\n' if param['is_required'] else ' (Optional)\\n')\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index and func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n num_params, params_indent = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (i + 1) if i < num_params else ''\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 22, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += ('\\n' if param['is_required'] else ' (Optional)\\n')\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + ' is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ('' if i + 1 < num_params else '\\n') + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 23, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1 - 80 + indent + 2):\n method_definition += return_string[i:i + 80 - indent + 2] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + ' is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent if i < 1 + num_params else ''\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 24, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += ('\\n' if param['is_required'] else ' (Optional)\\n')\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}'\n method_definition += '\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 25, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n else:\n method_definition += ',\\n' + ' ' * (indent + 2) + ' '\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string), 80 - indent):\n method_definition += return_string[i:i + 80 - indent] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + ' is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 2) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 26, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n num_params, params_indent = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 27, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index and func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n num_params, params_indent = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) if i < num_params else ''\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 28, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (i + 1 < num_params and indent or '') + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent + \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 29, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index and func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n num_params, params_indent = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 580, "s": 30, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index and func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - indent + 2):\n method_definition += return_string[i:i + 80 - indent + 2] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + ' is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}'\n return_string = func['returns'] + \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + \", timeout=self.timeout)\\n\\n\"\n return method_definition"} diff --git a/generations/gen_base_csn600.jsonl b/generations/gen_base_csn600.jsonl new file mode 100644 index 0000000000000000000000000000000000000000..a72f6b0f3ee31a7634e3b1d7d8d2e28352a68780 --- /dev/null +++ b/generations/gen_base_csn600.jsonl @@ -0,0 +1,600 @@ +{"i": 0, "got": "```python\nimport scipy.ndimage.filters as filters\nimport numpy as np\nfrom scipy import ndimage, morphology\nimport logger\nimport sed3\nimport time\n\nclass MyClass:\n def __msgc_step3_discontinuity_localization(self):\n pass\n\n def __init__(self, start_time, segmentation, stats, boundary_dilatation_distance, keep_temp_properties, debug_images):\n self._start_time = start_time\n self.segmentation = segmentation\n self.stats = stats\n self.boundary_dilatation_distance = boundary_dilatation_distance\n self.keep_temp_properties = keep_temp_properties\n self.debug_images = debug_images\n\n def show(self, pd):\n pass\n\n def time(self):\n return time.time() - self._start_time\n```"} +{"i": 1, "got": "```python\ndef __multiscale_gc_lo2hi_run(self):\n \"\"\"pass\"\"\"\n self._msgc_lo2hi_resize_init()\n self.__msgc_step0_init()\n self.__msgc_step12_low_resolution_segmentation()\n hard_constraints = self.__msgc_step3_discontinuity_localization()\n seg = self.time()\n self.stats['t3.1'] = seg\n graph = self.generate_base_grid()\n self.stats['t3.2'] = seg\n self.split_voxels()\n self.stats['t3.3'] = seg\n self.stats['update'](graph)\n self.stats['t4'] = seg\n mul_mask, mul_val, area_weight = self.__msgc_tlinks_area_weight_from_low_segmentation(seg)\n unariesalt = self.__create_tlinks(self.img, self.voxelsize, self.seeds, area_weight, hard_constraints)\n self.stats['t5'] = seg\n np.unique(graph.msinds, return_index=True)\n un, ind = np.unique(graph.edges, return_index=True)\n self.stats['t6'] = seg\n self.stats['t7'] = seg\n unariesalt2_lo2hi = np.hstack((unariesalt, un))\n nlinks_lo2hi = np.vstack((nlinks_lo2hi, unariesalt2_lo2hi))\n self.debug_images and (self.sed3.unariesalt[0][0] == 0) and self.sed3.show()\n self.sed3.unariesalt[1][0] == 0) and self.sed3.show()\n self.__msgc_step9_finish_perform_gc_and_reshape(nlinks_lo2hi, unariesalt2_lo2hi, graph.msinds)\n self._msgc_lo2hi_resize_clean_finish()\n```"} +{"i": 2, "got": "```python\ndef __multiscale_gc_hi2lo_run(self):\n \"\"\"pass\"\"\"\n self.__msgc_step0_init()\n self.__msgc_step12_low_resolution_segmentation()\n hard_constraints = self.__msgc_step3_discontinuity_localization()\n seg = self.__msgc_step45678_hi2lo_construct_graph(hard_constraints, seg)\n nlinks, unariesalt2, msinds = unpack_sequence(3, hard_constraints, seg)\n self.__msgc_step9_finish_perform_gc_and_reshape(nlinks, unariesalt2, msinds)\n```"} +{"i": 3, "got": "```python\nclass __ordered_values_by_indexes:\n def __init__(self, data, inds):\n self.values = np.max(data[inds])\n self.linear_inds = np.ravel(inds)\n self.linear_data = np.ravel(data)\n\n def __call__(self, data, inds):\n values = np.max(data[inds])\n linear_inds = np.ravel(inds)\n linear_data = np.ravel(data)\n return np.asarray(values), linear_inds, linear_data\n```"} +{"i": 4, "got": "```python\nclass __hi2lo_multiscale_indexes:\n def __init__(self, mask, orig_shape):\n self.mask = mask\n self.orig_shape = orig_shape\n\n def zoom_to_shape(self, inds_small, orig_shape):\n # Implementation of zoom_to_shape method\n pass\n\n def arange(self, x):\n # Implementation of arange method\n return x\n\n def prod(self, x):\n # Implementation of prod method\n return x\n\n def reshape(self, x, shape):\n # Implementation of reshape method\n return x\n\n def max(self, x):\n # Implementation of max method\n return x\n\n def relabel_squeeze(self, inds):\n # Implementation of relabel_squeeze method\n pass\n\n def debug(self, message):\n # Implementation of debug method\n print(message)\n\n def describe(self, data, axis=None):\n # Implementation of describe method\n import scipy.stats\n return scipy.stats.describe(data, axis=axis)\n```"} +{"i": 5, "got": "```python\ndef interactivity(self, min_val, max_val, qt_app):\n \"\"\"\n pass\n \"\"\"\n window_c = (max_val - min_val) / 2\n window_w = max_val - min_val\n\n if min_val is not None:\n min_val = np.min(self.img)\n if max_val is not None:\n max_val = np.max(self.img)\n\n pyed = self.changeC(window_c)\n pyed = self.changeW(window_w)\n qt_app.exec_()\n```"} +{"i": 6, "got": "```python\nclass Module:\n def __init__(self):\n self.logger = None\n self._pattern = None\n self._variables = {}\n\n def expand(self, expression):\n \"\"\"pass\"\"\"\n self.logger.debug(f'expand : expression {expression}')\n result = self._pattern.sub(self.expand_lambda, expression)\n self.logger.debug(f'expand : {result} - result : {self.strip(result)}')\n if isinstance(result, int):\n self.logger.debug(' expand is integer !!!')\n return int(result)\n elif isinstance(result, float):\n self.logger.debug(' expand is float !!!')\n return float(result)\n else:\n return result\n\n def strip(self, text):\n # Implementation of strip method\n pass\n\n @staticmethod\n def is_string(value):\n # Implementation of is_string method\n pass\n\n @staticmethod\n def is_number(value):\n # Implementation of is_number method\n pass\n\n @staticmethod\n def isdigit(value):\n # Implementation of isdigit method\n pass\n\n def expand_lambda(self, match):\n \"\"\"Copy free variables and resume execution\"\"\"\n self.copy_free_vars()\n return self.expand(match.group(1))\n```"} +{"i": 7, "got": "```python\ndef get_gutter_client(alias, cache, **kwargs):\n \"\"\"\n pass\n \"\"\"\n if alias in cache:\n return None\n else:\n Manager = gutter.client.models.Manager()\n kwargs.update(cache)\n result = Manager(**kwargs)\n cache[alias] = result\n return result\n```"} +{"i": 8, "got": "```python\ndef _modulo(self, decimal_argument):\n \"\"\"pass\"\"\"\n context = self._context\n times, remainder = divmod(decimal_argument, 100)\n return times, remainder\n```"} +{"i": 9, "got": "```python\nclass enabled_for:\n def __init__(self, inpt):\n self.inpt = inpt\n\n @staticmethod\n def enabled_for(self, inpt):\n signals.switch_checked = True\n signal_decorated = partial(NULL + call, self)\n state = self.state\n states = self.states\n conditions_dict = ConditionsDict.from_conditions_list(self.conditions)\n conditions = conditions_dict.get_by_input(inpt)\n if conditions:\n if conditions[0]:\n return True\n else:\n return False\n else:\n return None\n\n @staticmethod\n def enabled_for..(.0):\n for cond in .0:\n if cond.argument applies(inpt):\n yield cond.call(inpt)\n```"} +{"i": 10, "got": "```python\nclass Manager:\n NONE_INPUT = None\n NULL|self + argument = 'argument'\n __apply = '__apply'\n negative = False\n\ndef call(self, inpt):\n if not self.NONE_INPUT:\n return False\n argument_instance = getattr(self, self.NULL|self + argument)\n if not argument_instance.applies(inpt):\n return False\n application = getattr(self, self.NULL|self + __apply)(inpt)\n if self.negative:\n application = not application\n return application\n```"} +{"i": 11, "got": "```python\nclass switches:\n def __init__(self, self):\n self.storage = None\n\n def __iteritems(self):\n return iter(self.__joined_namespace)\n\n def startswith(self, name, switch):\n # Implementation of startswith method\n pass\n\n def __joined_namespace(self):\n # Implementation of joined_namespace method\n pass\n\n def __call__(self, self):\n results = []\n for name, switch in self.__iteritems():\n if name.startswith(self, switch):\n results.append(switch)\n return results\n```"} +{"i": 12, "got": "```python\nclass Switch:\n def __init__(self, name):\n self.storage = None\n self.manager = None\n\n def switch(self, name):\n if name in self.namespace:\n return self.storage[name]\n elif name == 'autocreate':\n return self.autocreate(name)\n else:\n raise KeyError(f\"No switch named '{name}' registered in '{self.namespace}'\")\n\n def autocreate(self, name):\n # Implement the logic for creating a new switch\n pass\n\n @property\n def namespace(self):\n # Implement the logic to get the namespace of switches\n return {}\n```"} +{"i": 13, "got": "```python\ndef when(obj, strict):\n \"\"\"pass\"\"\"\n strict = False\n theMock = None\n\n def When():\n \"\"\"when..When\"\"\"\n __name__ = 'when..When'\n __module__ = 'when..When'\n __qualname__ = 'when..When'\n\n def __getattr__(self, method_name):\n invocation = StubbedInvocation()\n theMock(method_name, strict)\n return invocation\n\n return When\n```"} +{"i": 14, "got": "```python\ndef when2(fn, *args, **kwargs):\n \"\"\"\n pass\n \"\"\"\n obj = get_obj_attr_tuple(fn)\n name = fn.__name__\n theMock = _get_mock(obj, strict=True)\n invocation = StubbedInvocation(theMock, name)\n return invocation(*args, **kwargs)\n```"} +{"i": 15, "got": "```python\ndef patch(fn, attr_or_replacement, replacement):\n \"\"\"\n pass\n \"\"\"\n if replacement is not None:\n replacement = replacement\n else:\n replacement = attr_or_replacement\n\n theMock = _get_mock(obj, strict=True)\n invocation = StubbedInvocation(theMock, name, False)\n\n return thenAnswer(replacement)\n```"} +{"i": 16, "got": "```python\ndef expect(obj, strict=True, times=None, atleast=None, atmost=None, between=None):\n \"\"\"\n pass\n \"\"\"\n strict = True if strict is None else strict\n theMock = _get_mock(obj)\n verification_fn = _get_wanted_verification(times, atleast, atmost, between)\n\n class Expect:\n def __init__(self):\n self.__name__ = \"expect..Expect\"\n self.__module__ = \"expect..Expect\"\n self.__qualname__ = \"expect..Expect\"\n\n def __getattr__(self, method_name):\n invocation = StubbedInvocation()\n return invocation\n\n return Expect()\n\nclass StubbedInvocation:\n pass\n```"} +{"i": 17, "got": "```python\ndef unstub(*objs):\n \"\"\"pass\"\"\"\n for obj in objs:\n mock_registry[self.unstub](obj)\n mock_registry[self.unstub_all]()\n\nclass MockRegistry:\n def __init__(self):\n self.unstub = lambda x: print(f\"Stubbing {x}\")\n self.unstub_all = lambda: print(\"Stubbing all objects\")\n\nmock_registry = MockRegistry()\nunstub(1, 2, 3)\n```"} +{"i": 18, "got": "```python\ndef verifyZeroInteractions(*objs):\n \"\"\"\n pass\n \"\"\"\n for obj in objs:\n theMock = _get_mock_or_raise(obj)\n if len(theMock.invocations) > 0:\n raise VerificationError(f\"Unwanted interaction: {theMock}\")\n```"} +{"i": 19, "got": "```python\ndef get_templates(model):\n \"\"\"pass\"\"\"\n yield from templates.items()\n```\n\nThe bytecode disassembly provided is a simple generator function that yields the items of a dictionary `templates`. The function does not perform any operations other than yielding the items."} +{"i": 20, "got": "```python\ndef attach(*layouts, **kwargs):\n \"\"\"pass\"\"\"\n layouts = cell(layouts)\n _model_admin_wrapper = closure(_model_admin_wrapper)\n return _model_admin_wrapper(layout_class)\n\ndef _model_admin_wrapper(layout_class):\n register = NULL + register\n layout_class[0] = layout_class[0][0]\n return layout_class\n```"} +{"i": 21, "got": "```python\ndef get_api_envs(self):\n \"\"\"pass\"\"\"\n client_id = os.environ.get('CLIENT_ID')\n user_id = os.environ.get('USER_ID')\n\n if not client_id:\n raise ValueError('API keys are not found in the environment')\n\n return (client_id, user_id)\n```"} +{"i": 22, "got": "```python\ndef api_call(method, end_point, params, client_id, access_token):\n \"\"\"\n pass\n \"\"\"\n if not (client_id or access_token):\n raise ValueError('Either client_id or access_token')\n \n url = f'https://api.quizlet.com/2.0/{end_point}'\n headers = {}\n \n if client_id:\n headers['client_id'] = client_id\n \n if access_token:\n headers['Authorization'] = f'Bearer {access_token}'\n \n response = requests.request(method, url, params=params, headers=headers)\n \n if response.status_code == 100:\n error_title = ''\n else:\n try:\n error_title = response.json().get('error_title', '')\n except json.JSONDecodeError:\n error_title = None\n \n if error_title:\n raise ValueError(f'{url} returned {response.status_code}{error_title}')\n \n return response.json()\n```"} +{"i": 23, "got": "```python\nimport threading\n\nclass exclusive:\n def __init__(self, via):\n self.via = via\n self.make_exclusive = self._make_exclusive\n\n def _make_exclusive(self, fnc):\n via = threading.Lock()\n make_exclusive = self._make_exclusive_local(fnc)\n exclusive_call = self._exclusive_call_local(fnc)\n\n def exclusive_call(*args, **kwargs):\n with via:\n return exclusive_call_local(*args, **kwargs)\n\n return exclusive_call\n\n @staticmethod\n def _make_exclusive_local(fnc):\n def make_exclusive_local(*args, **kwargs):\n fnc_guard = threading.Lock()\n functools.wraps(fnc)(fnc_guard.acquire)\n functools.wraps(fnc)(fnc_guard.release)\n return exclusive_call_local(*args, **kwargs)\n\n return make_exclusive_local\n\n @staticmethod\n def _exclusive_call_local(fnc):\n def exclusive_call_local(*args, **kwargs):\n fnc_guard = threading.Lock()\n if not fnc_guard.acquire(blocking=False):\n raise RuntimeError('exclusive call to %s violated' % fnc.__name__)\n try:\n return fnc(*args, **kwargs)\n finally:\n fnc_guard.release()\n\n return exclusive_call_local\n```"} +{"i": 24, "got": "```python\ndef service(flavour):\n \"\"\"pass\"\"\"\n def service_unit_decorator(raw_cls):\n \"\"\"Service entry point\"\"\"\n def __new__(cls, *args, **kwargs):\n if cls.__new__ is object.__new__:\n return super().__new__(cls)\n self = cls.__new__(cls)\n self.run()\n self.__doc__ = raw_cls.run() or 'Service entry point'\n return self\n __new__.__name__ = '__new_service__'\n service_unit_decorator.__closure__ = (raw_cls.__new__, flavour)\n return service_unit_decorator\n\n def __init__(self, *args, **kwargs):\n super().__init__(*args, **kwargs)\n\n class ServiceUnit:\n pass\n```"} +{"i": 25, "got": "```python\nclass ModuleType:\n def __init__(self, name, bases):\n self.name = name\n self.bases = bases\n\ndef execute(self, payload, *args, flavour, **kwargs):\n import functools\n partial = functools.partial(payload, *args)\n partial(args)\n partial(kwargs)\n self._meta_runner.run_payload(payload, flavour)\n\nclass _meta_runner:\n def run_payload(self, payload, flavour):\n pass\n```"} +{"i": 26, "got": "```python\ndef adopt(self, payload, *args, flavour=None, **kwargs):\n \"\"\"\n pass\n \"\"\"\n if args:\n payload = (payload,) + args\n elif kwargs:\n payload = (payload,) + tuple(kwargs.items())\n self._meta_runner.register_payload(payload, flavour)\n```\n\nThis Python function `adopt` takes a `payload`, optional positional arguments `args`, and optional keyword arguments `kwargs`. It first checks if there are any positional arguments. If so, it prepends the `payload` to these arguments. Then, it checks for keyword arguments. If there are any, it converts them into a tuple and appends this tuple to the `payload`. After that, it retrieves the `_meta_runner` attribute from the instance and calls its `register_payload` method with the modified `payload` and the provided `flavour`."} +{"i": 27, "got": "```python\nclass Module:\n def __init__(self):\n self._meta_runner = None\n self._must_shutdown = False\n self._logger = None\n\n def accept(self):\n \"\"\"pass\"\"\"\n if not self._meta_runner:\n raise RuntimeError('payloads scheduled for %s before being started' % self)\n gc.collect()\n self._adopt_services()\n self.adopt()\n self._accept_services()\n trio.run(self._meta_runner.run())\n```"} +{"i": 28, "got": "```python\nclass Module:\n def shutdown(self):\n \"\"\"pass\"\"\"\n self._must_shutdown = True\n self._is_shutdown = False\n self.wait()\n self._meta_runner.stop()\n\ndef shutdown(self):\n \"\"\"pass\"\"\"\n self._must_shutdown = True\n self._is_shutdown = False\n self.wait()\n self._meta_runner.stop()\n```"} +{"i": 29, "got": "```python\ndef milestones(ctx, list, close):\n \"\"\"\n pass\n \"\"\"\n repos = get_repos(ctx.parent.agile.get('labels'))\n if list:\n _list_milestones(repos)\n if close:\n click.echo(f\"Closing milestones '{close}'\")\n _close_milestone(repos, close)\n click.echo(ctx.parent.get_help())\n```"} +{"i": 30, "got": "```python\ndef start_console(local_vars):\n \"\"\"\n pass\n \"\"\"\n transforms.console_active = True\n transforms.null_or_self.remove_not_allowed_in_console()\n prompt.sys.ps1 = transforms.experimental_interactive_console(local_vars)\n transforms.console.interact(banner=transforms.banner)\n```\n\nThis Python function `start_console` is defined to handle the execution of a console-like interface. It sets up various attributes and calls methods from the `transforms` module to interact with the user."} +{"i": 31, "got": "```python\nclass push:\n def __init__(self, line):\n self.line = line\n self.transforms = None\n self.add_pass = False\n self.buffer = []\n self.source = ''\n self.filename = ''\n\n def runsource(self):\n transforms = getattr(self, 'transforms', None)\n if transforms is not None:\n for match in transforms.null | self.match:\n self.append('\\n')\n for line in transforms.add_transformers:\n self.append(line)\n self.buffer.append(f'\\n{self.rstrip()}:{self.endswith(\"pass\")}')\n self.source = ''.join(self.buffer)\n self.transform(self.source)\n self.buffer.pop()\n if self.endswith('pass'):\n self.buffer.append('\\n')\n else:\n self.buffer.append(f'\\n{self.rstrip()}:{self.endswith(\"pass\")}')\n self.source = ''.join(self.buffer)\n self.transform(self.source)\n self.buffer.pop()\n\n def transform(self, source):\n # Placeholder for the actual transformation logic\n pass\n\n def resetbuffer(self):\n self.buffer.clear()\n```"} +{"i": 32, "got": "```python\ndef license_loader(lic_dir):\n \"\"\"pass\"\"\"\n lics = []\n import os\n for ln in os.listdir(lic_dir):\n lp = os.path.join(lic_dir, ln)\n with open(lp) as lf:\n txt = lf.read()\n lic = License(txt)\n lics.append(lic)\n return lics\n\nclass License:\n def __init__(self, text):\n self.text = text\n```"} +{"i": 33, "got": "```python\nclass MyClass:\n def __init__(self, meta):\n self.meta = meta\n\n def get_vector(self, max_choice):\n vec = {}\n for dim in range(len(max_choice)):\n if max_choice[dim] is None:\n continue\n dim_vec = list(map(lambda x: (x, max_choice[dim]), self.meta[dim]))\n vec[dim] = dict(zip(dim_vec))\n return vec\n\n def get_vector_lambda(self, x):\n return (x, self.meta[x])\n```"} +{"i": 34, "got": "```python\ndef runcommand(cosmology):\n Mi = [100000000.0, 1000000000.0, 10000000000.0]\n zi = 0\n output = None\n\n commah = self.run(cosmology, zi, Mi)\n flatten = self.flatten\n\n print(f\"Concentrations for haloes of mass {Mi} at z={zi}:\")\n print(output)\n\n cosmology = self.run(cosmology, zi, Mi)\n output = None\n print(f\"Concentrations for haloes of mass {Mi} at z={zi}:\")\n print(output)\n\n cosmology = self.run(cosmology, zi, Mi, retcosmo=True)\n unpack_sequence = self.unpack_sequence\n output, cosmo = unpack_sequence(cosmology, zi, Mi, z)\n print(f\"Concentrations for haloes of mass {Mi} at z={zi}:\")\n print(output)\n\n Mi = [2000000000000.0]\n z = [0, 0.5, 1, 1.5, 2, 2.5]\n output = None\n cosmology = self.run(cosmology, zi, Mi, z)\n output = None\n print(f\"Concentrations for haloes of mass {Mi} at z={zi}:\")\n print(output)\n\n Mi = [6]\n zi = 0\n M = [100000000.0, 1000000000.0, 10000000000.0]\n z = [0, 0.5, 1, 1.5, 2, 2.5]\n output = None\n cosmology = self.run(cosmology, zi, Mi, z)\n output = None\n print(f\"Concentrations for haloes of mass {Mi} at z={zi}:\")\n print(output)\n\n Mval = [100000000.0]\n output = None\n cosmology = self.run(cosmology, Mval, zi, Mi)\n output = None\n print(f\"dM/dt for halo of mass {Mval} at z={zi} across redshift {z}:\")\n print(output)\n\n M = [100000000.0]\n z = [0, 0.5, 1, 1.5, 2, 2.5]\n output = None\n cosmology = self.run(cosmology, zi, Mi, z)\n output = None\n print(f\"Halo Mass History for z=0 mass of {M} across z={z}:\")\n print(output)\n\n Mval = [100000000.0]\n output = None\n cosmology = self.run(cosmology, zi, Mi, z)\n output = None\n print(f\"Formation Redshifts for haloes of mass {M} at z={zi}:\")\n print(output)\n\n return 'Done'\n```"} +{"i": 35, "got": "```python\ndef plotcommand(cosmology, plotname):\n \"\"\"\n pass\n \"\"\"\n xarray = np.arange(10) ** 2\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'C'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n ax.ylim(2, 30)\n colors = np.linspace(0, 1, len(zarray))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology, zi=zval, Mi=xarray)\n yarray = output.flatten()\n ax.plot(xarray, yarray, label=f'z={zval}', color=colors[zind])\n leg = ax.legend(loc='upper left')\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n leg.get_texts()[0].set_fontsize('small')\n for line in leg.get_lines():\n line.set_linewidth(4)\n plt.tight_layout(pad=0.2)\n print(f\"Plotting to '{plotname}_CM_relation.png'\")\n fig.savefig(plotname + '_CM_relation.png', dpi=5)\n plt.show()\n xarray = np.arange(10) ** 3\n yval = 'c'\n zarray = np.arange(6, 14, 2)\n xtitle = 'C'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n ax.ylim(2, 30)\n colors = np.linspace(0, 1, len(zarray))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology, zi=zval, Mi=xarray)\n yarray = output.flatten()\n ax.plot(xarray, yarray, label=f'z={zval}', color=colors[zind])\n leg = ax.legend(loc='upper left')\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n leg.get_texts()[0].set_fontsize('small')\n for line in leg.get_lines():\n line.set_linewidth(4)\n plt.tight_layout(pad=0.2)\n print(f\"Plotting to '{plotname}_Cz_relation.png'\")\n fig.savefig(plotname + '_Cz_relation.png', dpi=5)\n plt.show()\n xarray = np.arange(10) ** 3\n yval = 'c'\n zarray = np.arange(6, 14, 2)\n xtitle = 'C'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n ax.ylim(2, 30)\n colors = np.linspace(0, 1, len(zarray))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology, zi=zval, Mi=xarray)\n yarray = output.flatten()\n ax.plot(xarray, yarray, label=f'z={zval}', color=colors[zind])\n leg = ax.legend(loc='upper left')\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n leg.get_texts()[0].set_fontsize('small')\n for line in leg.get_lines():\n line.set_linewidth(4)\n plt.tight_layout(pad=0.2)\n print(f\"Plotting to '{plotname}_zfz_relation.png'\")\n fig.savefig(plotname + '_zfz_relation.png', dpi=5)\n plt.show()\n xarray = np.arange(10) ** 3\n yval = 'c'\n zarray = np.arange(6, 14, 2)\n xtitle = 'C'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n ax.ylim(2, 30)\n colors = np.linspace(0, 1, len(zarray))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology, zi=zval, Mi=xarray)\n yarray = output.flatten()\n ax.plot(xarray, yarray, label=f'z={zval}', color=colors[zind])\n leg = ax.legend(loc='upper left')\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n leg.get_texts()[0].set_fontsize('small')\n for line in leg.get_lines():\n line.set_linewidth(4)\n plt.tight_layout(pad=0.2)\n print(f\"Plotting to '{plotname}_specificMAH_M_relation.png'\")\n fig.savefig(plotname + '_specificMAH_M_relation.png', dpi=5)\n plt.show()\n xarray = np.arange(10) ** 3\n yval = 'c'\n zarray = np.arange(6, 14, 2)\n xtitle = 'C'\n ytitle = 'M(z) (M$_{sol}$)'\n linelabel = 'log$_{10}$ M$_0$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n ax.ylim(2, 30)\n colors = np.linspace(0, 1, len(zarray))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology, zi=zval, Mi=xarray)\n yarray = output.flatten()\n ax.plot(xarray, yarray, label=f'z={zval}', color=colors[zind])\n leg = ax.legend(loc='upper left')\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n leg.get_texts()[0].set_fontsize('small')\n for line in leg.get_lines():\n line.set_linewidth(4)\n plt.tight_layout(pad=0.2)\n print(f\"Plotting to '{plotname}_Mzz_relation.png'\")\n fig.savefig(plotname + '_Mzz_relation.png', dpi=5)\n plt.show()\n xarray = np.arange(10) ** 3\n yval = 'c'\n zarray = np.arange(6, 14, 2)\n xtitle = 'C'\n ytitle = 'log$_{10}$ M(z)/M$_{0}$'\n linelabel = 'log$_{10}$ M$_0$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n ax.ylim(2, 30)\n colors = np.linspace(0, 1, len(zarray))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology, zi=zval, Mi=xarray)\n yarray = output.flatten()\n ax.plot(xarray, yarray, label=f'z={zval}', color=colors[zind])\n leg = ax.legend(loc='upper left')\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n leg.get_texts()[0].set_fontsize('small')\n for line in leg.get_lines():\n line.set_linewidth(4)\n plt.tight_layout(pad=0.2)\n print(f\"Plotting to '{plotname}_MzM0z_relation.png'\")\n fig.savefig(plotname + '_MzM0z_relation.png', dpi=5)\n plt.show()\n xarray = np.arange(10) ** 3\n yval = 'c'\n zarray = np.arange(6, 14, 2)\n xtitle = 'C'\n ytitle = 'log$_{10}$ M(z)/M$_{0}$'\n linelabel = 'log$_{10}$ M$_0$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n ax.ylim(2, 30)\n colors = np.linspace(0, 1, len(zarray))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology, zi=zval, Mi=xarray)\n yarray = output.flatten()\n ax.plot(xarray, yarray, label=f'z={zval}', color=colors[zind])\n leg = ax.legend(loc='upper left')\n leg.get"} +{"i": 36, "got": "```python\ndef add_transformers(line):\n \"\"\"pass\"\"\"\n from experimental import match, sub, split, replace\n if not from_experimental.match(line):\n raise AssertionError()\n line = sub(' ', line)\n line = split('#')[0]\n line = replace(' ', '')\n for trans in import_transformer(trans):\n pass\n```"} +{"i": 37, "got": "```python\nimport sys\n\ndef import_transformer(name):\n \"\"\"pass\"\"\"\n if name in transformers:\n return transformers[name]\n else:\n raise ImportError(f\"Import Error in add_transformers: {name} not found\")\n\nclass NullTransformer:\n def __call__(self, *args, **kwargs):\n pass\n```"} +{"i": 38, "got": "```python\ndef extract_transformers_from_source(source):\n \"\"\"pass\"\"\"\n lines = source.split('\\n')\n linenumbers = list(enumerate(lines))\n from experimental import match\n add_transformers(line)\n linenumbers.insert(0, (0, ''))\n join_lines = '\\n'.join(lines)\n return join_lines\n```"} +{"i": 39, "got": "```python\ndef remove_not_allowed_in_console():\n \"\"\"pass\"\"\"\n not_allowed_in_console = []\n if CONSOLE_ACTIVE:\n transformers = import_transformer()\n for name in transformers:\n tr_module = hasattr(transformers, 'NO_CONSOLE')\n if not tr_module:\n not_allowed_in_console.append((name, tr_module))\n for name, tr_module in not_allowed_in_console:\n print(tr_module)\n NullTransformer().transform(name, tr_module)\n transformers[name] = NullTransformer()\n```"} +{"i": 40, "got": "```python\ndef _match(self, request, response):\n \"\"\"pass\"\"\"\n is_html = 'text/html' in response.get('Content-Type', '')\n if is_html:\n rendered_content = getattr(response, 'rendered_content', None)\n if rendered_content:\n path_matcher = PATH_MATCHER.match(request.path)\n correct_path = path_matcher.group(1) if path_matcher else None\n include_flag = self.include_flag\n not_included = response.rendered_content not in include_flag\n if correct_path and not_included:\n return True\n return False\n```"} +{"i": 41, "got": "```python\nclass _chosen_css:\n def __init__(self, self):\n self.css_template = None\n self.chosen_sprites = None\n\n def render_to_string(self):\n css = {}\n for sprite in self.chosen_sprites:\n css[sprite] = settings.STATIC_URL + 'img/' + sprite\n return render_to_string(css_template, context={'css': css})\n```"} +{"i": 42, "got": "```python\nclass _embed:\n def __init__(self, self, request, response):\n self._match = None\n self._chosen_css = None\n self._chosen_js = None\n\n @staticmethod\n def render_to_string(template_name, context):\n # Implementation of render_to_string function\n pass\n\n def replace(self, old, new):\n # Implementation of replace method\n pass\n\n def __call__(self, request, response):\n head = {}\n body = {}\n content = self.render_to_string('chosenadmin/_head_css.html', {'self': self})\n content += self.render_to_string('chosenadmin/_script.html', {'self': self})\n content = content.replace('', '')\n content = content.replace('', '')\n response.content = content\n```"} +{"i": 43, "got": "```python\nclass CleanUp:\n def __init__(self, log, address):\n self.log = log\n self.address = address\n\n def clean_up(self):\n self.log.close(self.address)\n self.bus.close()\n```\n\nThis Python code defines a class `CleanUp` with an initializer that takes a `log` object and an `address`. The `clean_up` method logs the closing of the I2C bus for the specified address and then closes the bus."} +{"i": 44, "got": "```python\nclass MyClass:\n def __init__(self, bus=None, address=None):\n self.bus = bus\n self.address = address\n\n def debug(self, message):\n print(message)\n\n def write_quick(self):\n if self.bus is not None and self.address is not None:\n self.bus.write(self.address)\n self.debug(f\"write_quick: Sent the read / write bit\")\n```"} +{"i": 45, "got": "```python\nclass MyClass:\n def __init__(self, bus, address):\n self.bus = bus\n self.address = address\n\n def write_byte(self, cmd, value):\n # pass\n self.bus.write_byte(self.address, cmd, value)\n self.log.debug(f\"write_byte: Wrote 0x{value:02X} to command register 0x{cmd:02X}\")\n```"} +{"i": 46, "got": "```python\nclass Module:\n def write_word(self, cmd, value):\n \"\"\"pass\"\"\"\n self.bus.NULL|self.write_word_data(value)\n self.log.debug('write_word: Wrote 0x%04X to command register 0x%02X', value, cmd)\n```\n\nThis Python code defines a class `Module` with a method `write_word`. The method takes two parameters, `cmd` and `value`, and performs some operations on the `bus` attribute. It also logs a debug message using the `log` attribute."} +{"i": 47, "got": "```python\nclass MyClass:\n def __init__(self, bus, address):\n self.bus = bus\n self.address = address\n\n def write_raw_byte(self, value):\n # pass\n self.bus.write_byte(self.address, value)\n self.log.debug('write_raw_byte: Wrote 0x%02X', value)\n```"} +{"i": 48, "got": "```python\nclass MyClass:\n def __init__(self, bus, address, log):\n self.bus = bus\n self.address = address\n self.log = log\n\n def write_block_data(self, cmd, block):\n # pass\n self.bus.write_i2c_block_data(self.address, cmd, block)\n self.log.debug('write_block_data: Wrote [%s] to command register 0x%02X', ', '.join(map(hex, block)), cmd)\n```"} +{"i": 49, "got": "```python\nclass FormSet:\n def get_formset(self, request, obj, **kwargs):\n \"\"\"\n pass\n \"\"\"\n data = None\n if obj is not None:\n user_id = request.user.id\n form = obj.form\n base_fields = form.base_fields\n initial = base_fields['user']\n data = {'user': user_id}\n return data\n```"} +{"i": 50, "got": "```python\ndef process_actions(action_ids):\n \"\"\"pass\"\"\"\n actions_taken = 0\n PublishAction.objects.prefetch_related('content_object')\n timezone.now()\n action_list = PublishAction.objects.filter(scheduled_time__lte=timezone.now()).filter(id__in=action_ids)\n for action in action_list:\n process_action(action)\n delete(action)\n actions_taken += 1\n return actions_taken\n```"} +{"i": 51, "got": "```python\ndef celery_enabled():\n \"\"\"pass\"\"\"\n enabled = getattr(settings, 'GLITTER_PUBLISHER_CELERY', None)\n if enabled is not None:\n return True\n else:\n try:\n import celery\n return True\n except ImportError:\n return False\n```\n\nThis Python function `celery_enabled` checks if Celery is enabled by looking for the setting 'GLITTER_PUBLISHER_CELERY' in Django's settings. If it exists, it returns `True`; otherwise, it attempts to import Celery and returns `True` if successful, or `False` if not."} +{"i": 52, "got": "```python\ndef do_command_line(infile):\n lines = infile.readlines()\n tree = ast.parse(''.join(lines))\n checker = Checker(tree, lines, infile.name)\n checker.load()\n errors = []\n for func in checker.all_funcs(skip_noqa=True):\n errors.extend(checker.check_all(func))\n print(func.__str__(), errors)\n return len(errors)\n\nclass ValidationError(Exception):\n pass\n\ndef to_aaa(self):\n return [self]\n```"} +{"i": 53, "got": "```python\ndef _izip(*iterables):\n \"\"\"pass\"\"\"\n iterators = list(map(iter, iterables))\n while True:\n yield tuple(next(it) for it in iterators)\n```"} +{"i": 54, "got": "```python\nimport numpy as np\n\ndef _checkinput(zi, Mi, z, verbose):\n \"\"\"\n pass\n \"\"\"\n if zi.size == 1 and Mi.size == 1:\n return -1\n \n if zi.size != Mi.size:\n print('Error ambiguous request')\n print('Need individual redshifts for all haloes provided ')\n print('Or have all haloes at same redshift ')\n return -1\n \n if verbose:\n print('Assume zi is the same for all Mi halo masses provided')\n \n zi = np.ones_like(Mi) * zi[0]\n \n if verbose:\n print('Assume Mi halo masses are the same for all zi provided')\n \n Mi = np.ones_like(zi) * Mi[0]\n \n if verbose:\n print('A single Mi and zi provided')\n \n lenzout = z.size\n \n return (zi, Mi, z, lenzout)\n```"} +{"i": 55, "got": "```python\ndef getcosmo(cosmology):\n \"\"\"\n pass\n \"\"\"\n cg = None # Assuming cg is a global variable or object\n defaultcosmologies = {\n 'dragons': 'wmap1',\n 'wmap1': 'wmap3',\n 'wmap3': 'wmap5',\n 'wmap5': 'wmap7',\n 'wmap7': 'wmap9',\n 'wmap9': 'wmap1_2dF_mean',\n 'wmap1_2dF_mean': 'wmap3_mean',\n 'wmap3_mean': 'wmap5_ml',\n 'wmap5_ml': 'wmap5_lss',\n 'wmap5_lss': 'wmap7_lss',\n 'planck13': 'Planck_2013',\n 'planck15': 'Planck_2015'\n }\n \n if isinstance(cosmology, dict):\n cosmo = cosmology\n elif cosmology in defaultcosmologies:\n cosmo = defaultcosmologies[cosmology]\n \n A_scaling = getAscaling(cosmo)\n cosmo.update({'A_scaling': A_scaling})\n \n if 'lower' in cosmology:\n lower = cosmology['lower']\n if lower in defaultcosmologies:\n cosmo = defaultcosmologies[lower]\n else:\n print(\"You haven't passed a dict of cosmological parameters OR a recognised cosmology, you gave %s\" % cosmology)\n \n cp.distance.set_omega_k_0(cosmo)\n return cosmo\n```"} +{"i": 56, "got": "```python\ndef _getcosmoheader(cosmo):\n \"\"\"\n pass\n \"\"\"\n return f\"Cosmology (flat) Om:{cosmo.omega_M_0:.3f}, Ol:{cosmo.omega_lambda_0:.3f}, h:{cosmo.h:.2f}, sigma8:{cosmo.sigma_8:.3f}, ns:{cosmo.n:.2f}\"\n```"} +{"i": 57, "got": "```python\nclass tag:\n def __init__(self, tag):\n self.tag = tag\n\n def __call__(self, tag):\n url = f'/tags/{tag}'\n response = self.http.get(url, auth=self.auth)\n response.raise_for_status()\n return response.json()\n```"} +{"i": 58, "got": "```python\nclass Module:\n def __init__(self):\n self.as_id = None\n self.get_list = None\n\n def release_assets(self, release):\n pass\n```\n\nThis Python code defines a class `Module` with two methods: `__init__` and `release_assets`. The `__init__` method initializes the `as_id` and `get_list` attributes. The `release_assets` method takes a `release` parameter and performs some operations on it, such as loading attributes from the instance, calling functions, and building strings."} +{"i": 59, "got": "```python\nclass Upload:\n def __init__(self, self):\n pass\n\n def upload(self, release, filename, content_type):\n \"\"\"pass\"\"\"\n self.release = release\n name = os.path.basename(filename)\n if content_type not in mimetypes.types_map:\n raise ValueError('content_type not known')\n inputs = {'name': name}\n url = f\"{self.uploads_url}{self.api_url}/{release}/assets/{filename}\"\n info = os.stat(filename)\n size = info.st_size\n response = requests.post(url, data={'content-type': content_type, 'content-length': str(size)}, auth=self.inputs.get('auth'), params=None, headers={'data': 'content-type', 'content-length': str(size)})\n response.raise_for_status()\n return response.json()\n```"} +{"i": 60, "got": "```python\ndef validate_tag(self, tag_name, prefix):\n \"\"\"\n pass\n \"\"\"\n new_version = semantic_version(tag_name)\n self.latest = latest()\n current = getattr(self, 'latest', None)\n if current is not None:\n tag_name = current[tag_name]\n if len(prefix) > 0:\n tag_name = tag_name[prefix:]\n if semantic_version(tag_name) >= new_version:\n what = 'equal to'\n else:\n what = 'older than'\n raise GithubException(f'Your local version \"{new_version}\" is {what} the current github version \"{tag_name}\".\\nBump the local version to continue.')\n return current\n```"} +{"i": 61, "got": "```python\ndef is_related_to(item, app_id, app_ver):\n \"\"\"pass\"\"\"\n versionRange = item.get('versionRange')\n if not versionRange:\n return True\n\n for vR in versionRange:\n targetApplication = vR.get('targetApplication')\n if targetApplication == 'self':\n related_targetApplication = get_related_target_application(vR, app_id, app_ver)\n if related_targetApplication is not None:\n return True\n return False\n```"} +{"i": 62, "got": "```python\ndef get_related_targetApplication(vR, app_id, app_ver):\n \"\"\"\n pass\n \"\"\"\n targetApplication = vR.get('targetApplication')\n if targetApplication is not None:\n guid = targetApplication['guid']\n if guid == app_id:\n return targetApplication\n app_version = version_int(app_ver)\n if app_version >= between(maxVersion, '*'):\n return targetApplication\n return None\n```"} +{"i": 63, "got": "```python\ndef write_addons_items(xml_tree, records, app_id, api_ver, app_ver):\n \"\"\"pass\"\"\"\n for item in records:\n if not is_related_to(item, app_id, app_ver):\n continue\n emItems = etree.SubElement(xml_tree, 'emItems')\n groupby = {}\n for record in records:\n if record['guid'] in groupby:\n groupby[record['guid']].append(record)\n else:\n groupby[record['guid']] = [record]\n \n for item in groupby.values():\n emItem = etree.SubElement(emItems, 'emItem')\n blockID = int(item[0]['blockID'])\n current_blockID = None\n previous_blockID = None\n \n if blockID > 0:\n current_blockID = blockID\n previous_blockID = blockID - 1\n else:\n current_blockID = 0\n previous_blockID = 0\n \n emItem['blockID'] = str(current_blockID)\n \n for field in ['guid', 'id']:\n if field in item[0]:\n emItem[field] = item[0][field]\n \n prefs = etree.SubElement(emItem, 'prefs')\n for pref in item:\n if 'pref' in pref:\n pref_element = etree.SubElement(prefs, 'pref')\n pref_element.text = pref['pref']\n \n build_version_range(emItem, item, app_id)\n \n emItems.set('id', str(item[0]['guid']))\n```\n\nThis Python function `write_addons_items` takes an XML tree and a list of records as input. It processes each record to create an 'emItem' element in the XML tree based on certain conditions. The function uses recursion to handle nested structures within the records."} +{"i": 64, "got": "```python\ndef write_plugin_items(xml_tree, records, app_id, api_ver, app_ver):\n \"\"\"\n pass\n \"\"\"\n for item in records:\n pluginItems = etree.SubElement(xml_tree, 'pluginItems')\n versionRange = get(item, 'versionRange', [])\n for versionRange in versionRange:\n targetApplication = get(versionRange, 'targetApplication', None)\n if targetApplication is not None:\n add_plugin_item(pluginItems, item, versionRange, app_id, api_ver, app_ver)\n```"} +{"i": 65, "got": "```python\ndef write_gfx_items(xml_tree, records, app_id, api_ver):\n \"\"\"pass\"\"\"\n for item in records:\n if 'guid' not in item:\n continue\n is_record_related = item['guid'] == app_id\n if not is_record_related:\n continue\n entry = etree.SubElement(gfxItems, 'gfxBlacklistEntry')\n entry.set('blockID', item['id'])\n fields = ['os', 'vendor', 'feature', 'featureStatus', 'driverVersion', 'driverVersionComparator']\n for field in fields:\n node = etree.SubElement(entry, field)\n node.text = item[field]\n devices = item.get('devices')\n if devices:\n for d in devices:\n device = etree.SubElement(entry, 'device')\n device.text = d\n versionRange = item.get('versionRange')\n if versionRange:\n minVersion, maxVersion = versionRange.split('-')\n entry.set('minVersion', minVersion)\n entry.set('maxVersion', maxVersion)\n```"} +{"i": 66, "got": "```python\ndef write_cert_items(xml_tree, records, api_ver, app_id, app_ver):\n \"\"\"pass\"\"\"\n if records:\n should_include_certs = should_include_certs(app_id, app_ver)\n certItems = etree.SubElement(xml_tree, 'certItems')\n for item in records:\n subject = item.get('subject')\n pubKeyHash = item.get('pubKeyHash')\n certItem = etree.SubElement(certItems, 'certItem')\n certItem.set('subject', subject)\n certItem.set('pubKeyHash', pubKeyHash)\n issuerName = item.get('issuerName')\n serialNumber = item.get('serialNumber')\n certItem.set('issuerName', issuerName)\n certItem.text = serialNumber\n```\n\nThis Python function `write_cert_items` takes in several parameters and performs operations on an XML tree based on the provided records. It uses the `etree` library to create and manipulate XML elements. The function checks if there are any records, determines whether to include certificates based on certain conditions, and then iterates through each record to create corresponding XML elements for 'certItem' within 'certItems'."} +{"i": 67, "got": "```python\ndef label(self, name, color, update):\n \"\"\"pass\"\"\"\n url = \"%s/labels\" % self.url\n data = dict(name=name, color=color)\n response = self.http.post(url, json=data, auth=self.auth, headers=self.headers)\n if response.status_code == 201:\n return True\n elif response.status_code == 422 and update:\n url = \"%s/%s\" % (self.url, name)\n response = self.http.patch(url, json=data, auth=self.auth, headers=self.headers)\n if response.raise_for_status():\n return False\n return False\n```"} +{"i": 68, "got": "```python\nclass ReminderManager:\n def __init__(self, timezone, reminders_choices):\n self.timezone = timezone\n self.reminders_choices = reminders_choices\n\n def get_interval_timedelta(self):\n now_datetime = self.timezone.now()\n current_month_days = monthrange(now_datetime.year, now_datetime.month)[1]\n interval_timedelta = None\n\n if self.interval == ReminderManager.INTERVAL_2_WEEKS:\n interval_timedelta = datetime.timedelta(days=14)\n elif self.interval == ReminderManager.INTERVAL_ONE_MONTH:\n interval_timedelta = datetime.timedelta(days=current_month_days)\n elif self.interval == ReminderManager.INTERVAL_THREE_MONTHS:\n three_months = relativedelta(months=3)\n interval_timedelta = three_months + now_datetime\n elif self.interval == ReminderManager.INTERVAL_SIX_MONTHS:\n six_months = relativedelta(months=6)\n interval_timedelta = six_months + now_datetime\n elif self.interval == ReminderManager.INTERVAL_ONE_YEAR:\n one_year = relativedelta(years=1)\n interval_timedelta = one_year + now_datetime\n\n return interval_timedelta\n```"} +{"i": 69, "got": "```python\nclass classes:\n def __init__(self):\n self.parents_to_children = {}\n self.children_to_parents = {}\n self.visited_classes = set()\n self.class_stack = []\n\n def _build_mappings(self, classes):\n parents_to_children = {}\n children_to_parents = {}\n visited_classes = set()\n class_stack = []\n\n while class_stack:\n class_ = class_stack.pop()\n if class_ in visited_classes:\n continue\n visited_classes.add(class_)\n for base in class_.__bases__:\n if base not in visited_classes:\n class_stack.append(base)\n parents_to_children[class_] = set()\n children_to_parents[class_] = set()\n\n sorted_parents_to_children = collections.OrderedDict(sorted(parents_to_children.items(), key=lambda x: x[0].__name__))\n sorted_children_to_parents = collections.OrderedDict(sorted(children_to_parents.items(), key=lambda x: x[0].__name__))\n\n return sorted_parents_to_children, sorted_children_to_parents\n\n def __build_mappings_lambda(x):\n return (x.__module__, x.__name__)\n\n _build_mappings.. = lambda x: (x.__module__, x.__name__)\n```"} +{"i": 70, "got": "```python\ndef _collect_classes(self, package_paths, recurse_subpackages):\n \"\"\"pass\"\"\"\n initial_source_paths = set()\n classes = []\n uqbar = importlib.import_module('uqbar.apis')\n initial_source_paths.update(importlib.import_module(path).__path__)\n for path in package_paths:\n module = importlib.import_module(path)\n if hasattr(module, '__path__'):\n initial_source_paths.update(importlib.import_module(path).__path__)\n initial_source_paths.add(module.__file__)\n uqbar.apis.collect_source_paths(initial_source_paths, recurse_subpackages)\n\ndef _collect_classes..(x):\n return (x.__module__, x.__name__)\n```"} +{"i": 71, "got": "```python\ndef paths():\n return Optional[Path] / Union[str, Path]\n\ndef find_common_prefix(paths):\n counter = Counter()\n for path in paths:\n pathlib.Path(path).resolve().parents.update(counter)\n valid_paths = sorted([path for path, count in counter.items() if count >= len(paths)])\n return valid_paths\n\n@lru_cache(maxsize=None)\ndef find_common_prefix(x):\n return len(x.parts)\n```"} +{"i": 72, "got": "```python\nimport os\n\ndef find_executable(name, flags):\n result = []\n extensions = os.environ.get('PATHEXT', '').split(os.pathsep)\n path = os.environ.get('PATH', '').split(os.pathsep)\n\n for x in path:\n for extension in extensions:\n path_extension = os.path.join(x, name + extension)\n if os.access(path_extension, flags):\n result.append(path_extension)\n return result\n```"} +{"i": 73, "got": "```python\ndef relative_to(source_path, target_path):\n \"\"\"pass\"\"\"\n pathlib = __import__('pathlib')\n common_prefix = pathlib.Path(source_path).resolve().commonpath(pathlib.Path(target_path).resolve())\n if not common_prefix:\n raise ValueError('No common prefix')\n source_path = pathlib.Path(source_path).resolve()\n target_path = pathlib.Path(target_path).resolve()\n result = pathlib.Path(source_path).resolve().relative_to(common_prefix)\n return result\n```"} +{"i": 74, "got": "```python\ndef walk(root_path, top_down):\n \"\"\"pass\"\"\"\n file_paths = []\n directory_paths = []\n\n def is_dir(path):\n return path.is_dir()\n\n def append(path):\n if top_down:\n directory_paths.append(path)\n else:\n file_paths.append(path)\n\n for path in pathlib.Path(root_path).iterdir():\n if is_dir(path):\n directory_paths.append(path)\n else:\n file_paths.append(path)\n\n if top_down:\n yield from (path for path in directory_paths)\n else:\n yield from (path for path in file_paths)\n\n while True:\n try:\n directory_path = next(directory_paths)\n yield from walk(directory_path, top_down)\n except StopIteration:\n break\n```"} +{"i": 75, "got": "```python\ndef run(self):\n \"\"\"pass\"\"\"\n yield from self.check_all()\n```\n\nThis Python function `run` is defined to return a generator. It iterates over all functions in the object, checks if they pass certain conditions, and yields errors if any are found. The function uses the `check_all` method to perform these checks."} +{"i": 76, "got": "```python\nimport asyncio\n\ndef make_driver(loop):\n \"\"\"pass\"\"\"\n loop = loop\n stop = loop.stop()\n driver = Component(sink).subscribe(stop)\n return driver\n\nclass Component:\n def __init__(self, sink):\n self.sink = sink\n\n def subscribe(self, stop):\n # Implementation of subscribe method\n pass\n\nclass Sink:\n def control(self):\n # Implementation of control method\n pass\n\ndef get_event_loop():\n # Implementation of get_event_loop function\n return None\n```"} +{"i": 77, "got": "```python\ndef _stdin_(p):\n \"\"\"pass\"\"\"\n import sys\n version = sys.version\n v = version[0]\n if v == '3':\n return input(p)\n else:\n return raw_input(p)\n```"} +{"i": 78, "got": "```python\nimport os\n\ndef survey_loader(sur_dir, sur_file):\n \"\"\"pass\"\"\"\n survey_path = os.path.join(sur_dir, sur_file)\n survey = Survey(survey_path).read()\n return survey\n```\n\nIn this Python 3.12 bytecode disassembly, the original source code is provided in the docstring of the `survey_loader` function."} +{"i": 79, "got": "```python\nclass FormatChoices:\n def __init__(self, choices):\n self.choices = choices\n\n @staticmethod\n def format_choices(self):\n ce = enumerate(self.choices)\n toks = []\n for i, c in ce:\n toks.append('%s (%d)' % (c, i))\n return ' '.join(toks)\n\n @staticmethod\n def format_choices_lambda(i, c):\n return '%s (%d)' % (c, i)\n```"} +{"i": 80, "got": "```python\nclass is_answer_valid:\n def __init__(self, choices):\n self.choices = choices\n\n def is_answer_valid(self, ans):\n for i in range(len(self.choices)):\n if str(i + 1) == ans:\n return True\n return False\n```\n\nThis Python code defines a class `is_answer_valid` with an instance method `is_answer_valid`. The method checks if the given answer (`ans`) is present in the list of choices. If it is, the method returns `True`; otherwise, it returns `False`."} +{"i": 81, "got": "```python\nclass Span:\n def __init__(self, span, line_type):\n self.span = span\n self.line_type = line_type\n\n @staticmethod\n def update(self, span, line_type):\n first_block_line, last_block_line = span\n for i in range(first_block_line, last_block_line + 1):\n self[self.i] = line_type\n```\n\nThis Python code defines a `Span` class with an initializer and a static method `update`. The `update` method takes a `span` tuple containing two integers representing the first and last block lines, and a `line_type` string. It then iterates over the range of these lines and updates the corresponding elements in the object using the `__setitem__` method."} +{"i": 82, "got": "```python\ndef check_arrange_act_spacing(self):\n \"\"\"pass\"\"\"\n yield from self.check_block_spacing(LineType.arrange, LineType.act)\n```\n\nThis Python function `check_arrange_act_spacing` is defined to handle the logic described in the bytecode disassembly. It uses a generator expression to iterate over the block spacing and act blocks, applying the specified formatting rules."} +{"i": 83, "got": "```python\ndef check_act_assert_spacing(self):\n \"\"\"pass\"\"\"\n yield from self.check_block_spacing(LineType.act, LineType._assert)\n```\n\nThe bytecode disassembly provided is a Python function `check_act_assert_spacing` that uses a generator to iterate over lines in a block and checks for the presence of a specific number of blank lines before an assertion. The function returns a generator that yields the number of blank lines found."} +{"i": 84, "got": "```python\nclass AAAError(Exception):\n pass\n\ndef check_block_spacing(self, first_block_type, second_block_type, error_message):\n numbered_lines = list(enumerate(self.numbered_lines))\n first_block_lines = filter(lambda l: l[1] == first_block_type, numbered_lines)\n second_block_lines = filter(lambda l: l[1] == second_block_type, numbered_lines)\n\n blank_lines = []\n for line in first_block_lines:\n if not line[0].blank_line:\n blank_lines.append(line[0])\n for line in second_block_lines:\n if not line[0].blank_line:\n blank_lines.append(line[0])\n\n if len(blank_lines) == 1:\n raise AAAError(self.fn_offset + blank_lines[0].line_number, blank_lines[0].offset, error_message)\n elif len(blank_lines) > 1:\n raise AAAError(self.fn_offset + blank_lines[0].line_number, blank_lines[0].offset, error_message)\n\n yield 1\n\ndef check_block_spacing..(l):\n return l[1] == first_block_type\n```"} +{"i": 85, "got": "```python\nclass MyClass:\n def __init__(self, client_id, client_secret):\n self._client_id = client_id\n self._client_secret = client_secret\n\n @property\n def _token(self):\n return None\n\n def fetch_token(self, code):\n raise MissingTokenError(\"Token issues: %s\" % error)\n\n def get_access_token(self, code):\n try:\n token = super().fetch_token(code)\n self._token = token\n return token\n except MissingTokenError as e:\n _LOGGER.debug('Token issues: %s', e)\n return None\n```"} +{"i": 86, "got": "```python\nclass GET:\n def __init__(self, url, request_type, **params):\n self.url = url\n self.request_type = request_type\n self.params = params\n\n def _request(self, url, request_type, **params):\n import logging\n logger = logging.getLogger(__name__)\n debug = logger.debug if hasattr(logger, 'debug') else lambda *args: None\n timeout = 10 # Example timeout value\n response = self.request(request_type, url, params, timeout=timeout)\n if response.status_code != 200:\n raise OSError(f\"Error: {response.status_code} - {response.text}\")\n return response.json()\n\n def json(self):\n import json\n return json.loads(self.response.content)\n\n def __getattr__(self, name):\n try:\n return getattr(self.response, name)\n except AttributeError:\n raise AttributeError(f\"'{name}' not found in response\")\n\n def __repr__(self):\n return f\"GET(url={self.url}, request_type={self.request_type}, params={self.params})\"\n```"} +{"i": 87, "got": "```python\nclass MyClass:\n def __init__(self):\n self._request = None\n self.get = None\n\n def _request_devices(self, url, _type):\n pass\n\n def get(self, _type):\n return {}\n```"} +{"i": 88, "got": "```python\nclass MyClass:\n def __init__(self):\n self.MINUT_DEVICES_URL = None\n self._request = None\n\n def read_sensor(self, device_id, sensor_uri):\n \"\"\"\n pass\n \"\"\"\n url = f\"{self.MINUT_DEVICES_URL}/{device_id}/{sensor_uri}\"\n res = self._request(url, \"GET\", {\"limit\": 1})\n if \"values\" in res:\n return res[\"values\"]\n else:\n return None\n\n def get(self, key):\n # Implementation of the get method\n pass\n```"} +{"i": 89, "got": "```python\nclass WebhookManager:\n def __init__(self):\n self._request = None\n\n @staticmethod\n def _register_webhook(self, webhook_url, events):\n \"\"\"\n pass\n \"\"\"\n response = self._request(MINUT_WEBHOOKS_URL, 'POST', webhook_url, events, ('url', 'events'), request_type='request_type', json=True)\n return response\n```"} +{"i": 90, "got": "```python\nclass MyClass:\n def remove_webhook(self):\n \"\"\"pass\"\"\"\n self._webhook = get('hook_id')\n if self._webhook is not None:\n self._request(f\"{MINUT_WEBHOOKS_URL}/{self._webhook}\", method='DELETE', request_type='request_type')\n```"} +{"i": 91, "got": "```python\nimport subprocess\n\nclass HostIPDeterminer:\n def __init__(self):\n self.cmd_netstat = ['netstat', '-nr']\n self.cmd_grep = ['grep', '^0\\\\.0\\\\.0\\\\.0']\n self.cmd_awk = ['awk', '{ print $2 }']\n\n def debug(self, message):\n print(message)\n\n def read(self, file_obj):\n return file_obj.read()\n\n def determine_host_ip(self):\n p1 = subprocess.Popen(self.cmd_netstat, stdout=subprocess.PIPE)\n p2 = subprocess.Popen(self.cmd_grep, stdin=p1.stdout, stdout=subprocess.PIPE)\n p3 = subprocess.Popen(self.cmd_awk, stdin=p2.stdout, stdout=subprocess.PIPE)\n\n galaxy_ip = self.read(p3.stdout)\n self.debug(f'Host IP determined to be {galaxy_ip}')\n return galaxy_ip\n```"} +{"i": 92, "got": "```python\ndef get_galaxy_connection(history_id, obj):\n \"\"\"pass\"\"\"\n history_id = history_id\n key = os.environ['API_KEY']\n galaxy_ip = NULL + _get_ip()\n url = NULL + Template(os.environ['GALAXY_URL']).safe_substitute({'DOCKER_HOST': galaxy_ip})\n gi = None\n if gi is not None:\n return gi\n else:\n url = os.environ['GALAXY_URL'] + '/' + os.environ['GALAXY_WEB_PORT']\n built_galaxy_url = url.rstrip('/')\n url = http://galaxy_ip.strip() + ':' + galaxy_port.strip() + '/' + app_path.rstrip('/') + '/'\n if url in _test_url(url, key, history_id, obj):\n gi = None\n else:\n msg = 'Could not connect to a galaxy instance. Please contact your SysAdmin for help with this error'\n raise Exception(msg)\n```"} +{"i": 93, "got": "```python\ndef put(filenames, file_type, history_id):\n \"\"\"pass\"\"\"\n history_id = history_id\n os.environ['HISTORY_ID'] = history_id\n gi = get_galaxy_connection(history_id)\n for filename in filenames:\n log.debug('Uploading gx=%s history=%s localpath=%s ft=%s', gi, history_id, filename, file_type)\n history = get_history(history_id)\n upload_dataset(filename, file_type, history)\n```"} +{"i": 94, "got": "```python\ndef get(datasets_identifiers, identifier_type, history_id):\n \"\"\"pass\"\"\"\n history_id = history_id\n gi = NULL + get_galaxy_connection(history_id, False)\n datasets_identifiers = datasets_identifiers\n for dataset_identifier in datasets_identifiers:\n file_path = '/import/%s' % dataset_identifier\n log.debug('Downloading gx=%s history=%s dataset=%s', gi, history_id, dataset_identifier)\n os.path.exists(file_path)\n if not os.path.exists(file_path):\n hc = NULL + HistoryClient(gi)\n dc = NULL + DatasetClient(gi)\n hc.show_history(history_id, contents=True)\n history = hc.show_history(history_id, contents=True)\n for ds in history:\n ds[identifier_type] = ds['id']\n datasets = datasets\n ds = dataset_identifier\n if identifier_type == 'hid':\n dataset_identifier = int(dataset_identifier)\n dc.download_dataset(datasets, dataset_identifier, file_path=False, use_default_filename=False)\n log.debug('Cached, not re-downloading')\n```"} +{"i": 95, "got": "```python\ndef get_user_history(history_id):\n \"\"\"\n pass\n \"\"\"\n history_id = history_id\n os.environ['HISTORY_ID'] = history_id\n gi = NULL + get_galaxy_connection(history_id, False)\n hc = NULL + HistoryClient(gi)\n history = hc.show_history(history_id, True, True)\n return history\n```"} +{"i": 96, "got": "```python\ndef get_user_sets(client_id, user_id):\n \"\"\"\n pass\n \"\"\"\n api_call = None\n data = None\n wordset = None\n\n def format(self, *args):\n return self.format(*args)\n\n class WordSet:\n @classmethod\n def from_dict(cls, dict_):\n return cls(dict_)\n\n while True:\n try:\n api_call('get', 'users/{}/sets'.format(user_id))\n data = api_call(client_id)\n wordset = WordSet.from_dict(data)\n break\n except Exception as e:\n wordset = None\n\n return wordset\n```"} +{"i": 97, "got": "```python\ndef print_user_sets(wordsets, print_terms):\n \"\"\"\n pass\n \"\"\"\n if not wordsets:\n print('No sets found')\n else:\n print(f'Found sets: {len(wordsets)}')\n for wordset in wordsets:\n print(f' {wordset}')\n for term in wordset.terms:\n print(f' {term}')\n```"} +{"i": 98, "got": "```python\ndef get_common_terms(*api_envs):\n \"\"\"pass\"\"\"\n common_terms = []\n wordsets = get_user_sets(api_envs)\n combinations = combinations(wordsets, 2)\n for wordset1, wordset2 in combinations:\n if has_common(wordset1, wordset2):\n common_terms.append((wordset1.title(), wordset2.title(), common))\n return common_terms\n```"} +{"i": 99, "got": "```python\ndef print_common_terms(common_terms):\n \"\"\"pass\"\"\"\n for set_pair in common_terms:\n set1, set2 = set_pair\n print(f\"{set1} and {set2} have in common:\")\n for term in set1 & set2:\n print(f\" {term}\")\n```"} +{"i": 100, "got": "```python\ndef run(entry_point, drivers, loop):\n \"\"\"\n pass\n \"\"\"\n setup()\n program = entry_point(drivers)\n program.run()\n dispose()\n if loop is not None:\n asyncio.get_event_loop().run_forever(loop)\n return None\n```"} +{"i": 101, "got": "```python\ndef compare_schemas(one, two):\n \"\"\"pass\"\"\"\n one = _normalize_string_type(one)\n two = _normalize_string_type(two)\n _assert_same_types(one, two)\n if isinstance(one, list):\n return _compare_lists(one, two)\n elif isinstance(one, dict):\n return _compare_dicts(one, two)\n elif isinstance(one, SCALAR_TYPES):\n return one == two\n else:\n raise RuntimeError(f\"Not allowed type \\\"{type(one)}\\\"\")\n```"} +{"i": 102, "got": "```python\ndef is_ecma_regex(regex):\n \"\"\"\n pass\n \"\"\"\n parts = regex.split('/')\n if len(parts) != 2:\n raise ValueError(\"Given regex isn't ECMA regex nor Python regex.\")\n raw_regex = '/'.join(parts)\n if not raw_regex.startswith('/') or not raw_regex.endswith('/'):\n return False\n return True\n```"} +{"i": 103, "got": "```python\ndef convert_ecma_regex_to_python(value):\n \"\"\"pass\"\"\"\n if not is_ecma_regex(value):\n return PythonRegex(value).split('/')\n parts = value.split('/')\n flags = 0\n while parts:\n flags |= ECMA_TO_PYTHON_FLAGS[parts.pop()]\n result_flags = []\n for f in flags:\n result_flags.append(PythonRegex(f).join(parts, 1))\n return ''.join(result_flags)\n```"} +{"i": 104, "got": "```python\ndef convert_python_regex_to_ecma(value, flags):\n \"\"\"\n pass\n \"\"\"\n if is_ecma_regex(value):\n return value\n\n result_flags = []\n for f in value:\n result_flags.append(PYTHON_TO_ECMA_FLAGS[f])\n\n return '/{}/{}'.format(value, ''.join(result_flags))\n```"} +{"i": 105, "got": "```python\nclass MyClass:\n def populate(self, **values):\n pass\n\n def iterate_with_name(self):\n # Implementation of iterate_with_name method\n pass\n\n def __set__(self, instance, value):\n # Implementation of __set__ method\n pass\n\n def pop(self, name):\n # Implementation of pop method\n pass\n```"} +{"i": 106, "got": "```python\nclass FieldNotFound(Exception):\n pass\n\ndef get_field(self, field_name):\n for attr_name, field in self.__dict__.items():\n if field_name == attr_name:\n return field\n raise FieldNotFound(f'Field not found: {field_name}')\n```"} +{"i": 107, "got": "```python\nclass WrittenRow:\n pass\n\ndef __init__(self, row):\n self.row = row\n\ndef __convert_row(self, row):\n # Convert the row to a dictionary\n return dict(zip(row.field_names, row))\n\ndef __check_existing(self, keyed_row):\n # Check if the row already exists in the buffer\n pass\n\ndef __insert(self, row):\n # Insert the row into the buffer\n self.buffer.append(row)\n\ndef __update(self, row):\n # Update the row in the buffer\n pass\n\nclass Database:\n def __init__(self, schema):\n self.schema = schema\n self.field_names = schema.field_names\n self.__buffer = []\n self.__autoincrement = True\n\n def write(self, rows, keyed):\n for row in rows:\n keyed_row = self.__convert_row(row)\n if not self.__check_existing(keyed_row):\n self.__insert(row)\n if self.__autoincrement:\n self.__update(row)\n\n def __buffer_append(self, row):\n # Append the row to the buffer\n pass\n\n def __len__(self):\n # Return the length of the buffer\n return len(self.buffer)\n\n def append(self, row):\n # Append the row to the buffer\n self.__buffer.append(row)\n```"} +{"i": 108, "got": "```python\nclass BloomFilter:\n def __prepare_bloom(self):\n pass\n\n def __init__(self, *args, **kwargs):\n self.__bloom = pybloom_live.ScalableBloomFilter(*args, **kwargs)\n self.__update_keys = None\n\n def select(self, columns):\n return select(columns)\n\n def execute(self, keys):\n for key in keys:\n self.__bloom.add(tuple(key))\n```"} +{"i": 109, "got": "```python\nclass __insert:\n def __init__(self, self):\n pass\n\n def __call__(self, self):\n yield None\n```\n\nThis Python code defines a class `__insert` with an `__init__` method that takes `self` as an argument and an `__call__` method that also takes `self` as an argument. The `__call__` method uses the `yield` keyword to produce a generator, which is then returned by the function."} +{"i": 110, "got": "```python\nclass MyClass:\n def __init__(self, table):\n self.__table = table\n\n def update(self, row):\n pass\n\n def __update_keys(self):\n return []\n\n def __autoincrement(self):\n return False\n\n def __returning(self):\n return None\n\n def execute(self):\n return 0\n```"} +{"i": 111, "got": "```python\nclass Module:\n def __init__(self):\n self.__update_keys = None\n self.__bloom = None\n\n def __check_existing(self, row):\n # pass\n closure = lambda key: (key, self.__bloom.add(key))\n return any(closure(key) for key in self.__update_keys)\n\n @staticmethod\n def __check_existing_gen(row):\n for key in row:\n yield key\n\n def __bloom(self):\n # implementation of bloom filter\n pass\n\n def __update_keys(self, keys):\n # update the list of keys\n pass\n```"} +{"i": 112, "got": "```python\nclass buckets:\n def __init__(self):\n self.buckets = []\n self.__mapper = None\n\n def __metadata__(self):\n return {'sorted_tables': []}\n\n def restore_bucket(self, table):\n # Implementation of restore_bucket method\n pass\n\n def append(self, bucket):\n # Implementation of append method\n pass\n```"} +{"i": 113, "got": "```python\nclass OpenHierarchy:\n def __init__(self, path, relative_to_object_id, object_id, create_file_type):\n self.process = None\n\n def process(self, path, relative_to_object_id, object_id, create_file_type):\n try:\n with open(path, 'w') as file:\n file.write('')\n except Exception as e:\n print(e)\n print('Could not Open Hierarchy')\n```"} +{"i": 114, "got": "```python\nclass CreateNewPage:\n def __init__(self, section_id, new_page_style):\n self.process(section_id, '', new_page_style)\n\n @staticmethod\n def create_new_page(self, section_id, new_page_style):\n try:\n self.process(section_id, '', new_page_style)\n except Exception as e:\n print(e)\n print('Unable to create the page')\n```"} +{"i": 115, "got": "```python\nclass PageContent:\n def __init__(self, page_id, page_info):\n self.page_id = page_id\n self.page_info = page_info\n\n def process(self):\n # Placeholder for processing logic\n pass\n\n def get_page_content(self, page_id, page_info):\n try:\n result = self.process()\n return result\n except Exception as e:\n print(f\"Could not get Page Content: {e}\")\n return None\n```"} +{"i": 116, "got": "```python\ndef publish(self, hierarchy_id, target_file_path, publish_format, clsid_of_exporter):\n pass\n```"} +{"i": 117, "got": "```python\nclass Module:\n def __init__(self):\n self.process = None\n\n def get_special_location(self, special_location):\n try:\n return self.process.get_special_location(special_location)\n except Exception as e:\n print(e)\n print('Could not retreive special location')\n finally:\n del e\n```\n\nThis Python code snippet defines a class `Module` with an instance variable `process`. The method `get_special_location` attempts to call the `get_special_location` method of the `process` attribute. If an exception occurs, it prints an error message and then re-raises the exception."} +{"i": 118, "got": "```python\ndef memory():\n \"\"\"\n pass\n \"\"\"\n mem_info = dict(psutil.virtual_memory())\n for k, v in mem_info.items():\n int(v)\n mem_info[k] = int(mem_info[k])\n return mem_info\n```"} +{"i": 119, "got": "```python\ndef get_chunk_size(N, n):\n \"\"\"\n pass\n \"\"\"\n mem_free = memory()\n if mem_free < 60000000:\n chunk_size = int(mem_free - 10000000) * 1000 * 4 * n * N / (mem_free - 7000000)\n elif mem_free < 40000000:\n chunk_size = int(mem_free - 7000000) * 1000 * 4 * n * N / (mem_free - 2000000)\n elif mem_free < 14000000:\n chunk_size = int(mem_free - 2000000) * 1000 * 4 * n * N / (mem_free - 1400000)\n elif mem_free < 8000000:\n chunk_size = int(mem_free - 1400000) * 1000 * 4 * n * N / (mem_free - 2000000)\n elif mem_free < 2000000:\n chunk_size = int(mem_free - 2000000) * 1000 * 4 * n * N / (mem_free - 900000)\n elif mem_free < 1000000:\n chunk_size = int(mem_free - 900000) * 1000 * 4 * n * N / (mem_free - 400000)\n else:\n chunk_size = int(mem_free - 400000) * 1000 * 4 * n * N / (mem_free - 2000000)\n\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n```"} +{"i": 120, "got": "```python\ndef get_compression_filter(byte_counts):\n \"\"\"pass\"\"\"\n if isinstance(byte_counts, numbers.Integral):\n if byte_counts > 0:\n memory = tables.filters['blosc']\n filters = memory.free * 1000\n return filters\n else:\n raise AssertionError(\"byte_counts must be a positive integer\")\n else:\n raise AssertionError(\"byte_counts must be an instance of numbers.Integral\")\n```"} +{"i": 121, "got": "```python\ndef build_hypergraph_adjacency(cluster_runs):\n \"\"\"\n pass\n \"\"\"\n N_runs = cluster_runs.shape[0]\n hypergraph_adjacency = create_membership_matrix(cluster_runs, 0)\n for i in range(N_runs):\n hypergraph_adjacency = scipy.sparse.vstack([hypergraph_adjacency, create_membership_matrix(cluster_runs, i)], format='csr')\n return hypergraph_adjacency\n```"} +{"i": 122, "got": "```python\ndef store_hypergraph_adjacency(hypergraph_adjacency, hdf5_file_name):\n \"\"\"\n pass\n \"\"\"\n byte_counts = hypergraph_adjacency.data.nbytes + hypergraph_adjacency.indices.nbytes + hypergraph_adjacency.indptr.nbytes\n filters = get_compression_filter(byte_counts)\n fileh = tables.open_file(hdf5_file_name, 'r+')\n for par in hypergraph_adjacency.consensus_group:\n n = len(par)\n _f_remove(fileh.root.consensus_group, par)\n array = np.array(hypergraph_adjacency, dtype=hypergraph_adjacency.dtype)\n atom = tables.Atom.from_dtype(array.dtype)\n ds = fileh.create_carray(fileh.root.consensus_group, 'data', atom, array.shape, filters=filters)\n ds[...] = array\n```"} +{"i": 123, "got": "```python\ndef load_hypergraph_adjacency(hdf5_file_name):\n \"\"\"\n pass\n \"\"\"\n tables = None\n fileh = None\n pars = []\n with open(hdf5_file_name, 'r+') as fileh:\n for par in ('data', 'indices', 'indptr', 'shape'):\n pars.append(par)\n csr_matrix = scipy.sparse.csr_matrix(tuple(pars[3:]), shape=pars[:3])\n hypergraph_adjacency = csr_matrix\n return hypergraph_adjacency\n```"} +{"i": 124, "got": "```python\ndef obfuscate(p, action):\n key = 'ru7sll3uQrGtDPcIW3okutpFLo6YYtd5bWSpbZJIopYQ0Du0a1WlhvJOaZEH'\n s = list()\n if PY2:\n for i in range(len(p)):\n kc = ord(key[i % len(key)]) % (ord(p[i]) + 256)\n ec = chr(ord(p[i]) + kc) % 256\n dc = chr(ord(ec) - kc) % 256\n s.append(ec)\n else:\n for i in range(len(p)):\n kc = ord(key[i % len(key)]) % (ord(p[i]) + 256)\n ec = chr(ord(p[i]) + kc).encode('utf-8')\n dc = chr(ord(ec) - kc).encode('utf-8')\n s.append(dc.decode('utf-8'))\n e = base64.urlsafe_b64encode(b''.join(s))\n if PY2:\n return e\n else:\n return e.decode('utf-8')\n```"} +{"i": 125, "got": "```python\nimport os\nimport json\n\nclass ConfigBootstrap:\n def __init__(self, self):\n pass\n\n @staticmethod\n def _config_bootstrap(self):\n CONFIG_PATH = 'path/to/config'\n CONFIG_FILE = 'config.json'\n\n if not os.path.exists(CONFIG_PATH):\n os.makedirs(CONFIG_PATH)\n\n if not os.path.exists(CONFIG_FILE):\n with open(CONFIG_FILE, 'w') as f:\n json.dump({}, f, indent=4, separators=(',', ': '))\n \n config = {}\n self._email = None\n self._password = None\n\n if self._email is not None and self._password is not None:\n config['email'] = self._email\n config['password'] = self._password\n \n with open(CONFIG_FILE, 'w') as f:\n json.dump(config, f, indent=4, separators=(',', ': '))\n \n if os.path.exists(CONFIG_FILE):\n config = json.load(open(CONFIG_FILE))\n self._email = config.get('email')\n self._password = config.get('password')\n\n self._log.debug('Caching authentication in config file')\n with open(CONFIG_FILE, 'w') as f:\n json.dump(config, f, indent=4, separators=(',', ': '))\n \n if os.path.exists(CONFIG_FILE):\n config = json.load(open(CONFIG_FILE))\n self._email = config.get('email')\n self._password = config.get('password')\n\n self._log.debug('Loaded authentication from config file')\n return None\n```"} +{"i": 126, "got": "```python\nimport os\nimport requests\nimport pickle\n\nclass SessionManager:\n def __init__(self, session_file):\n self.session_file = session_file\n self._log = None # Placeholder for logging\n self._is_authenticated = False\n self._session = None\n\n def _session_check(self):\n if not os.path.exists(self.session_file):\n self._log.debug('Session file does not exist')\n return False\n cookies = pickle.load(open(self.session_file, 'rb'))\n self._session.cookies = cookies\n self._log.debug('Loaded cookies from session file')\n return True\n\n def _process_state(self):\n # Placeholder for state processing logic\n pass\n\n @property\n def TEST_URL(self):\n return 'https://example.com'\n\n @property\n def HEADERS(self):\n return {'User-Agent': 'Mozilla/5.0'}\n\n @property\n def TEST_KEY(self):\n return 'test_key'\n\n def get(self, url, headers=None):\n response = requests.get(url, headers=headers)\n if b'test_key' in response.content:\n self._is_authenticated = True\n self._process_state()\n return response\n\n# Example usage\nsession_manager = SessionManager('session.pkl')\nresponse = session_manager.get(session_manager.TEST_URL, headers=session_manager.HEADERS)\nprint(response.text)\n```"} +{"i": 127, "got": "```python\nimport logging\nimport sys\n\nclass Logger:\n def __init__(self, name, log_level=logging.INFO):\n self.logger = logging.getLogger(name)\n self.logger.setLevel(log_level)\n shandler = logging.StreamHandler(sys.stdout)\n fmt = '%(levelname)-5s %(module)s:%(funcName)s():'\n shandler.setFormatter(fmt)\n self.logger.addHandler(shandler)\n\n def __call__(self, message):\n self.logger.info(message)\n```"} +{"i": 128, "got": "```python\ndef set_log_level(self, level):\n \"\"\"\n pass\n \"\"\"\n if level == 'info':\n self._log.setLevel(logging.INFO)\n elif level == 'debug':\n self._log.setLevel(logging.DEBUG)\n elif level == 'error':\n self._log.setLevel(logging.ERROR)\n else:\n raise ValueError(\"Invalid log level\")\n```"} +{"i": 129, "got": "```python\nclass Module:\n def __init__(self):\n self._log = None\n self._session = None\n self.ALERTS_URL = None\n self.HEADERS = None\n\n def _process_state(self):\n pass\n\n def get(self, url, headers=None):\n response = self._session.get(url, headers=headers)\n soup = BeautifulSoup(response.content, 'html.parser')\n state = json.loads(soup.find('script', text='window.STATE').text[15:-1])\n if state != '':\n self._state = state\n self._log.debug(f'State value set: {self._state}')\n```"} +{"i": 130, "got": "```python\ndef search_packages_info(query):\n installed = {}\n pkg_resources.working_set\n for p in pkg_resources.working_set:\n canonicalize_name(p.project_name)\n installed[canonicalize_name(p.project_name)] = True\n\n query_names = set()\n name = None\n while query:\n query_names.add(canonicalize_name(query))\n query = next(iter(query), None)\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for pkg in pkg_resources.working_set:\n project_name = pkg.project_name\n version = pkg.version\n location = pkg.location\n requires = pkg.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for pkg in pkg_resources.working_set:\n project_name = pkg.project_name\n version = pkg.version\n location = pkg.location\n requires = pkg.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project_name = dist.project_name\n version = dist.version\n location = dist.location\n requires = dist.requires()\n\n if canonicalize_name(project_name) in installed:\n package = {'name': project_name, 'version': version, 'location': location, 'requires': requires}\n yield package\n\n for dist in pkg_resources.working_set:\n project"} +{"i": 131, "got": "```python\ndef process_view(self, request, view_func, view_args, view_kwargs):\n \"\"\"pass\"\"\"\n view_keys = list(view_method_data.keys())\n for key in view_keys:\n del view_method_data[key]\n self.view_data = build_map()\n self.cbv = None\n if cbv is not None:\n self.view_data['cbv'] = 'cbv'\n self.view_class.__bases__ = [base for base in inspect.getmro(self.view_class) if base != self.view_class]\n patched_methods = inspect.getmembers(self.view_func, lambda x: hasattr(x, '__call__'))\n for member in patched_methods:\n if member[0] == 'cbv':\n continue\n if member[0] == 'bases':\n continue\n if member[0] == 'patched_methods':\n continue\n self.cbv = decorate_method(self.view_class, member[1], 0)\n self.patched_methods.append(member[1])\n return None\n```"} +{"i": 132, "got": "```python\nclass ProcessResponse:\n def process_response(self, request, response):\n \"\"\"pass\"\"\"\n settings = getattr(request, 'settings', None)\n if not settings or not settings.DEBUG:\n return response\n\n content_encoding = getattr(response, 'content_encoding', '')\n content_type = getattr(response, 'content_type', '')\n\n if any(content_type.lower().endswith(ext) for ext in _HTML_TYPES):\n content = force_text(response.content, settings.DEFAULT_CHARSET)\n content = re.escape('')\n bits = re.split(pattern, content, flags=re.IGNORECASE)\n debug_payload(request, response, self, view_data=bits[1])\n content = ''.join(bits)\n response.content = content\n response['Content-Length'] = len(content)\n\n return response\n```"} +{"i": 133, "got": "```python\ndef get_job_class(klass_str):\n \"\"\"pass\"\"\"\n mod_name, klass_name = klass_str.rsplit('.', 1)\n importlib.import_module(mod_name)\n klass = getattr(importlib.import_module(mod_name), klass_name)\n return klass\n```"} +{"i": 134, "got": "```python\nclass MyClass:\n def __init__(self):\n self.prepare_args = lambda: None\n self.prepare_kwargs = lambda: ()\n self.key = lambda: None\n self.cache = lambda: None\n self.should_missing_item_be_fetched_synchronously = lambda: False\n self.refresh = lambda: None\n self.empty = lambda: None\n self.store = lambda: None\n self.timeout = 0\n self.async_refresh = lambda: None\n self.process_result = lambda result, call, cache_status, sync_fetch: None\n\n def get(self, *raw_args, **raw_kwargs):\n args = self.prepare_args(*raw_args)\n kwargs = self.prepare_kwargs(raw_kwargs)\n key = self.key()\n item = self.cache.get(key)\n if item is not None:\n return item\n logger.debug(f\"Job {self.class_path} with key '{key}' - cache MISS - running synchronous refresh\")\n result = self.refresh(args, kwargs)\n self.process_result(result, call, 'MISS', True)\n return result\n\n def should_stale_item_be_fetched_synchronously(self, delta):\n return delta > 0\n\n def refresh(self, args, kwargs):\n return None\n\n def empty(self):\n return None\n\n def store(self, key, data, timeout):\n pass\n\n def async_refresh(self, args, kwargs):\n pass\n\n def process_result(self, result, call, cache_status, sync_fetch):\n if cache_status == 'MISS':\n if self.should_missing_item_be_fetched_synchronously:\n logger.debug(f\"Job {self.class_path} with key '{key}' - cache MISS - running synchronous refresh\")\n result = self.refresh(args, kwargs)\n self.process_result(result, call, 'MISS', True)\n else:\n logger.debug(f\"Job {self.class_path} with key '{key}' - cache MISS - triggering async refresh and returning empty result\")\n result = self.empty()\n elif cache_status == 'STALE':\n if self.should_stale_item_be_fetched_synchronously:\n logger.debug(f\"Job {self.class_path} with key '{key}' - STALE cache hit - running synchronous refresh\")\n result = self.refresh(args, kwargs)\n self.process_result(result, call, 'STALE', True)\n else:\n logger.debug(f\"Job {self.class_path} with key '{key}' - STALE cache hit - triggering async refresh and returning stale result\")\n timeout = self.timeout\n result = self.empty()\n elif cache_status == 'HIT':\n logger.debug(f\"Job {self.class_path} with key '{key}' - cache HIT\")\n return result\n\n def debug(self, message):\n pass\n```"} +{"i": 135, "got": "```python\nclass Cache:\n def invalidate(self, *raw_args, **raw_kwargs):\n \"\"\"pass\"\"\"\n args = self.prepare_args(raw_args)\n kwargs = self.prepare_kwargs(raw_kwargs)\n key = self.key(args, kwargs)\n item = self.cache.get(key)\n if item is not None:\n expiry, data = item\n if expiry > time.time():\n return data\n self.store(key, data, args, kwargs)\n self.async_refresh(key, args, kwargs)\n return data\n\n def prepare_args(self, raw_args):\n # Implementation of prepare_args method\n pass\n\n def prepare_kwargs(self, raw_kwargs):\n # Implementation of prepare_kwargs method\n pass\n\n def key(self, args, kwargs):\n # Implementation of key method\n pass\n\n def cache(self):\n # Implementation of cache method\n pass\n\n def store(self, key, data, args, kwargs):\n # Implementation of store method\n pass\n\n def async_refresh(self, key, args, kwargs):\n # Implementation of async_refresh method\n pass\n```"} +{"i": 136, "got": "```python\ndef delete(self, *raw_args, **raw_kwargs):\n \"\"\"pass\"\"\"\n args = self.prepare_args(raw_args)\n kwargs = self.prepare_kwargs(raw_kwargs)\n key = self.key(args, kwargs)\n item = self.cache.get(key)\n if item is not None:\n return item\n else:\n self.delete(key)\n return None\n```"} +{"i": 137, "got": "```python\nclass MyClass:\n def __init__(self):\n self.prepare_args = lambda x: x\n self.prepare_kwargs = lambda x: {}\n self.key = None\n self.cache = {}\n\n def raw_get(self, *raw_args, **raw_kwargs):\n args = self.prepare_args(raw_args)\n kwargs = self.prepare_kwargs(raw_kwargs)\n key = self.key\n value = self.cache.get(key, None)\n if value is not None:\n return value\n result = self.cache[key] = self.get(key, args, kwargs)\n return result\n\n def get(self, key, args, kwargs):\n # Placeholder for the actual implementation of the get method\n pass\n```"} +{"i": 138, "got": "```python\nclass Cache:\n def __init__(self, class_path):\n self.class_path = class_path\n\n def set_data_kwarg(self, raw_kwargs):\n return raw_kwargs.get('data')\n\n def prepare_args(self, raw_args):\n return raw_args\n\n def prepare_kwargs(self, raw_kwargs):\n return {}\n\n def key(self, args, kwargs):\n return args + tuple(sorted(kwargs.items()))\n\n def expiry(self, args, kwargs):\n return None\n\n def debug(self, message, *args):\n print(message % args)\n\n def store(self, key, expiry, data):\n pass\n```"} +{"i": 139, "got": "```python\ndef angle(v1, v2):\n \"\"\"\n pass\n \"\"\"\n v1_u = unit_vector(v1)\n v2_u = unit_vector(v2)\n return np.arccos(np.clip(np.dot(v1_u, v2_u), -1.0, 1.0))\n```"} +{"i": 140, "got": "```python\ndef keep_high_angle(vertices, min_angle_deg):\n \"\"\"\n pass\n \"\"\"\n accepted = []\n for v in vertices:\n v1 = v[0] - v[1]\n v2 = v[0] - v[2]\n diff_angle = np.abs(np.angle(v1, v2)) * 180 / np.pi\n if diff_angle > min_angle_deg:\n accepted.append((v[0], v[1]))\n return np.array(accepted)\n```"} +{"i": 141, "got": "```python\ndef set_contourf_properties(stroke_width, fcolor, fill_opacity, contour_levels, contourf_idx, unit):\n \"\"\"\n pass\n \"\"\"\n return '%.2f %s %s %s %s %s' % (fcolor, stroke_width, fcolor, fill_opacity, contour_levels[contourf_idx], unit)\n```"} +{"i": 142, "got": "```python\ndef contour_to_geojson(contour, geojson_filepath, min_angle_deg, ndigits, unit, stroke_width, geojson_properties, strdump, serialize):\n \"\"\"pass\"\"\"\n collections = []\n contour_index = 0\n line_features = []\n\n for collection in contour:\n color = get_edgecolor(collection)\n paths = get_paths(collection)\n for path in paths:\n v = path.vertices\n coordinates = keep_high_angle(v, min_angle_deg)\n if ndigits is not None:\n coordinates = around(coordinates, ndigits)\n line = LineString(coordinates)\n stroke_hex = rgb2hex(color)\n level_value = contour.levels[contour_index]\n level_index = contour_index\n properties = {\n 'stroke-width': stroke_width,\n 'stroke': stroke_hex,\n 'title': f'Level {level_value}',\n 'level-value': f'{level_value:.6f}',\n 'level-index': level_index\n }\n feature = Feature(line, properties)\n line_features.append(feature)\n contour_index += 1\n\n feature_collection = FeatureCollection(line_features)\n _render_feature_collection(feature_collection, geojson_filepath, strdump, serialize)\n```"} +{"i": 143, "got": "```python\ndef contourf_to_geojson_overlap(contourf, geojson_filepath, min_angle_deg, ndigits, unit, stroke_width, fill_opacity, geojson_properties, strdump, serialize):\n polygon_features = []\n contourf_idx = 0\n\n for collection in contourf.collections:\n color = collection.get_facecolor()\n paths = collection.get_paths()\n\n for path in paths:\n polygons = to_polygons(path)\n for coord in polygons:\n if min_angle_deg > 0 and keep_high_angle(coord, min_angle_deg):\n coord = around(coord, ndigits)\n\n polygon = Polygon([coord.tolist()])\n fcolor = rgb2hex(color[0])\n properties = set_contourf_properties(stroke_width, fcolor, fill_opacity, contourf.levels, contourf_idx, unit)\n feature = Feature(polygon=polygon, properties=properties)\n polygon_features.append(feature)\n\n contourf_idx += 1\n\n feature_collection = FeatureCollection(polygon_features)\n _render_feature_collection(feature_collection, geojson_filepath, strdump, serialize)\n```"} +{"i": 144, "got": "```python\ndef contourf_to_geojson(contourf, geojson_filepath, min_angle_deg=0, ndigits=2, unit='m', stroke_width=1, fill_opacity=0.9, geojson_properties=None, strdump=False, serialize=True):\n polygon_features = []\n mps = []\n contourf_idx = 0\n\n for coll in contourf.collections:\n color = coll.get_facecolor()\n paths = coll.get_paths()\n\n for path in paths:\n polygons = to_polygons(path)\n for coord in polygons:\n if min_angle_deg > 0 and keep_high_angle(coord, min_angle_deg):\n continue\n ndigits = ndigits if ndigits else len(str(color[0]))\n op = rgb2hex(color[0])\n mps.append((coord, op))\n\n contourf_idx += 1\n\n for i, k in enumerate(mps):\n if k[1] not in mps:\n add_coords(k[0], tolist(k[1]), mps)\n else:\n muli = next(enumerate(mps))\n add_coords(multi[1][0], tolist(multi[1][1]) + tolist(k[1]), mps)\n\n for i in range(contourf_idx):\n append(polygon, properties=mpoly(i), fcolor=color[i])\n\n feature_collection = FeatureCollection([Feature(polygon, properties) for polygon, properties in zip(polygon_features, mps)])\n _render_feature_collection(feature_collection, geojson_filepath, strdump, serialize)\n```"} +{"i": 145, "got": "```python\ndef get_authorize_callback(endpoint, provider_id):\n \"\"\"\n pass\n \"\"\"\n endpoint_prefix = config_value('BLUEPRINT_NAME')\n url = url_for(endpoint_prefix + '.' + endpoint + '.' + provider_id, provider_id=provider_id)\n return request.url_root[:-1] + url\n```"} +{"i": 146, "got": "```python\nclass ConnectionManager:\n def __init__(self):\n pass\n\n def find_connection(self, **kwargs):\n return None\n\n def delete_connection(self, self, conn=None, **kwargs):\n if conn is not None:\n delattr(self, 'conn')\n else:\n self.conn = None\n```"} +{"i": 147, "got": "```python\nclass MyClass:\n def delete_connections(self, **kwargs):\n \"\"\"pass\"\"\"\n rv = False\n self.find_connections()\n kwargs.update({})\n for c in self.delete:\n rv = True\n return rv\n```"} +{"i": 148, "got": "```python\ndef login(provider_id):\n \"\"\"\n pass\n \"\"\"\n provider = get_provider_or_404(provider_id)\n callback_url = get_authorize_callback('login', provider_id)\n request.form['next'] = get_post_login_redirect()\n session[config_value('POST_OAUTH_LOGIN_SESSION_KEY')] = provider.authorize(callback_url)\n```"} +{"i": 149, "got": "```python\ndef connect(provider_id):\n \"\"\"\n pass\n \"\"\"\n provider = get_provider_or_404(provider_id)\n callback_url = get_authorize_callback('connect', provider_id)\n allow_view = config_value('CONNECT_ALLOW_VIEW')\n pc = request.form.get('next', allow_view)\n session[config_value('POST_OAUTH_CONNECT_SESSION_KEY')] = pc\n provider.authorize(callback_url)\n```"} +{"i": 150, "got": "```python\ndef remove_all_connections(provider_id):\n \"\"\"\n pass\n \"\"\"\n provider = get_provider_or_404(provider_id)\n ctx = dict(provider=provider, user=current_user)\n _datastore.delete_connections(current_user.get_id(), provider_id)\n deleted = _datastore.delete_connections(current_user.get_id(), provider_id)\n if deleted:\n after_this_request(_commit)\n msg = 'All connections to %s removed' % provider.name\n connection_removed.send(current_app._get_current_object(), current_user, provider_id)\n else:\n msg = 'Unable to remove connection to %(provider)s'\n do_flash(msg % ctx)\n redirect(request.referrer)\n```"} +{"i": 151, "got": "```python\ndef guess(filename, fallback):\n \"\"\"pass\"\"\"\n mimetype = mimetypes.guess_type(filename, strict=False)\n guessed, encoding = mimetype\n if guessed is not None:\n return (guessed, encoding)\n else:\n return (fallback, encoding)\n```"} +{"i": 152, "got": "```python\ndef format_addresses(addrs):\n \"\"\"pass\"\"\"\n for item in addrs:\n if isinstance(item, tuple):\n print(formataddr(item))\n```\n\nThe Python source code that corresponds to the given bytecode disassembly is:\n\n```python\ndef format_addresses(addrs):\n \"\"\"pass\"\"\"\n for item in addrs:\n if isinstance(item, tuple):\n print(formataddr(item))\n```"} +{"i": 153, "got": "```python\ndef stringify_address(addr, encoding):\n if isinstance(addr, bytes_type):\n return addr.decode('ascii')\n else:\n localpart, domain = addr.split('@')\n encoded_localpart = localpart.encode(encoding)\n encoded_domain = domain.encode('idna')\n return b'@'.join([encoded_localpart, encoded_domain])\n```"} +{"i": 154, "got": "```python\ndef email(sender, receivers, cc, bcc, subject, content, encoding, attachments):\n \"\"\"pass\"\"\"\n html = HTML(content, encoding)\n enclosure = [html]\n for attachment in attachments:\n enclosure.append(Attachment(attachment))\n headers = {\n 'Subject': subject,\n 'From': sender,\n 'To': receivers,\n 'Cc': cc,\n 'Bcc': bcc,\n 'Date': datetime.now(),\n 'Message-ID': uuid.uuid4().hex\n }\n return Collection(headers, enclosure)\n```"} +{"i": 155, "got": "```python\ndef postman(host, port, auth, force_tls, options):\n \"\"\"\n pass\n \"\"\"\n Postman = None\n middleware = None\n tls = None\n return None\n```"} +{"i": 156, "got": "```python\nclass Mime:\n def __init__(self, mime_object):\n self.mime = mime_object\n\n @property\n def headers(self):\n return self.prepare(self.mime)\n\n def prepare(self, mime):\n # Implementation of the prepare method\n pass\n```\n\nIn this Python 3.12 bytecode disassembly, we have a class `Mime` with an initializer that takes a `mime_object`. The `headers` property calls the `prepare` method on the `mime` object. The `prepare` method is not implemented in the provided code snippet, so it remains as a placeholder."} +{"i": 157, "got": "```python\ndef get_existing_model(model_name):\n \"\"\"\n pass\n \"\"\"\n engine = None # Assuming engine is defined elsewhere\n log = None # Assuming log is defined elsewhere\n\n try:\n model_cls = getattr(engine, 'get_document_cls')(model_name)\n log.debug(f'Model `{model_name}` already exists. Using existing one')\n return model_cls\n except ValueError as e:\n log.debug(f'Model `{model_name}` does not exist')\n return None\n```"} +{"i": 158, "got": "```python\ndef prepare_relationship(config, model_name, raml_resource):\n \"\"\"\n pass\n \"\"\"\n existing_model = get_existing_model(model_name)\n plural_route = '/' + pluralize(model_name.lower())\n route = '/' + model_name.lower()\n if raml_resource.root.resources:\n for res in raml_resource.root.resources:\n method = res.method.upper()\n if method == 'POST':\n continue\n path = res.path\n if path.endswith(plural_route):\n continue\n if path.endswith(route):\n continue\n setup_data_model(config, res, model_name)\n```"} +{"i": 159, "got": "```python\ndef generate_model_cls(config, schema, model_name, raml_resource, es_based):\n \"\"\"pass\"\"\"\n if es_based:\n base_cls = engine.ESBaseDocument\n else:\n base_cls = engine.BaseDocument\n\n auth_model = schema.get('_auth_model', False)\n bases = [AuthModelMethodsMixin]\n if auth_model:\n bases.append(AuthModelMethodsMixin)\n\n if auth_model:\n bases.append(DocumentACLMixin)\n\n model_name = model_name.lower()\n properties = schema.get('properties', {})\n db_settings = None\n field_kwargs = {}\n type_fields = {\n 'string': type_fields['string']\n }\n\n nesting_depth = schema.get('_nesting_depth', 0)\n if nesting_depth:\n attrs[nesting_depth] = nesting_depth\n\n for field_name, props in properties.items():\n db_settings = props.get('_db_settings')\n if db_settings is not None:\n field_kwargs['default'] = resolve_to_callable(db_settings)\n field_kwargs['required'] = bool(props.get('required', False))\n\n type_name = props.get('type', 'string').lower()\n field_cls = type_fields[type_name]\n attrs[field_name] = field_cls\n\n if auth_model:\n attrs[model_name] = model_name\n attrs['_public_fields'] = properties.get('_public_fields', [])\n attrs['_auth_fields'] = properties.get('_auth_fields', [])\n attrs['_hidden_fields'] = properties.get('_hidden_fields', [])\n attrs['_nested_relationships'] = properties.get('_nested_relationships', [])\n\n setup_model_event_subscribers(config, model_cls)\n setup_fields_processors(config, model_cls)\n\n return model_cls\n```"} +{"i": 160, "got": "```python\ndef setup_data_model(config, raml_resource, model_name):\n \"\"\"\n pass\n \"\"\"\n model_cls = get_existing_model(model_name)\n if schema:\n return generate_model_cls(config, schema, model_name, raml_resource)\n\n log.info('Generating model class `{}`'.format(model_name))\n return generate_model_cls(config, schema, model_name, raml_resource)\n```"} +{"i": 161, "got": "```python\ndef handle_model_generation(config, raml_resource):\n \"\"\"pass\"\"\"\n model_name = generate_model_name(raml_resource)\n setup_data_model(config, raml_resource, model_name)\n\ndef generate_model_name(raml_resource):\n pass\n\ndef setup_data_model(config, raml_resource, model_name):\n pass\n```"} +{"i": 162, "got": "```python\ndef setup_model_event_subscribers(config, model_cls, schema):\n \"\"\"\n pass\n \"\"\"\n events_map = get_events_map()\n model_events = get(schema)._event_handlers\n event_kwargs = {model: {} for model in model_events}\n for event_tag, subscribers in model_events.items():\n type_, action = event_tag.split('_')\n event_objects = [resolve_to_callable(sub_name) for sub_name in subscribers]\n if not isinstance(event_objects, list):\n event_objects = [event_objects]\n config.subscribe_to_events(resolve_to_callable(sub_func), event_objects, event_kwargs)\n```"} +{"i": 163, "got": "```python\ndef setup(app):\n \"\"\"\n pass\n \"\"\"\n import sphinxcontrib_django.docstrings\n import sphinxcontrib_django.roles\n\n sphinxcontrib_django.docstrings.NULL|self + setup(app)\n sphinxcontrib_django.roles.NULL|self + setup(app)\n\n return None\n```"} +{"i": 164, "got": "```python\ndef patch_django_for_autodoc():\n pass\n\ndef patch_django_for_autodoc_lambda(self, *args, **kwargs):\n return self.manager\n\ndef patch_django_for_autodoc_lambda(self):\n return self.__class__.__name__\n```"} +{"i": 165, "got": "```python\ndef setup(app):\n \"\"\"\n pass\n \"\"\"\n patch_django_for_autodoc = patches.patch_django_for_autodoc()\n app.connect('autodoc-process-docstring', improve_model_docstring)\n app.connect('autodoc-skip-member', autodoc_skip)\n```\n\nThis Python code snippet defines a function `setup` that takes an `app` object as input. It imports the necessary modules and functions, connects to specific signals on the `app` object, and performs some operations related to documentation processing."} +{"i": 166, "got": "```python\ndef autodoc_skip(app, what, name, obj, skip, options):\n \"\"\"pass\"\"\"\n if name in config.EXCLUDE_MEMBERS:\n return True\n elif name in config.INCLUDE_MEMBERS:\n return False\n else:\n return skip\n```"} +{"i": 167, "got": "```python\ndef improve_model_docstring(app, what, name, obj, options, lines):\n \"\"\"pass\"\"\"\n if what == 'class':\n _improve_class_docs(app, obj, lines)\n elif what == 'attribute':\n _improve_attribute_docs(obj, name, lines)\n elif what == 'method':\n _improve_method_docs(obj, name, lines)\n\ndef _improve_class_docs(app, obj, lines):\n # Implementation of improving class documentation\n pass\n\ndef _improve_attribute_docs(obj, name, lines):\n # Implementation of improving attribute documentation\n pass\n\ndef _improve_method_docs(obj, name, lines):\n # Implementation of improving method documentation\n pass\n```"} +{"i": 168, "got": "```python\ndef _improve_class_docs(app, cls, lines):\n \"\"\"pass\"\"\"\n if issubclass(cls, models.Model):\n _add_model_fields_as_params(app, cls, lines)\n elif issubclass(cls, forms.Form):\n _add_form_fields(app, cls, lines)\n return None\n\ndef _add_model_fields_as_params(app, cls, lines):\n pass\n\ndef _add_form_fields(app, cls, lines):\n pass\n```"} +{"i": 169, "got": "```python\ndef attr_names(cls):\n pass\n\ndef return():\n return 'return'\n```"} +{"i": 170, "got": "```python\ndef elliptic_fourier_descriptors(contour, order, normalize):\n import numpy as np\n\n def diff(x):\n return x[1:] - x[:-1]\n\n def sqrt(x):\n return np.sqrt(x)\n\n def sum(x, axis=None):\n return np.sum(x, axis=axis)\n\n def concatenate(x, axis=0):\n return np.concatenate(x, axis=axis)\n\n def cumsum(x, axis=0):\n return np.cumsum(x, axis=axis)\n\n def pi():\n return np.pi\n\n def zeros(order, dtype=float):\n return np.zeros(order, dtype=dtype)\n\n def _range(start, stop, step=1):\n return np.arange(start, stop, step)\n\n t = np.linspace(0, 2 * pi, order + 1)\n T = 2 * pi\n phi = pi / T\n\n coeffs = zeros(order + 4, dtype=float)\n dxy = diff(contour)\n dt = sqrt(dxy**2 + dxy[1:]**2)\n\n for n in range(1, order + 1):\n const = np.pi * n**2\n phi_n = phi * n\n d_cos_phi_n = np.cos(phi_n)\n d_sin_phi_n = np.sin(phi_n)\n a_n = sum(dxy * d_cos_phi_n, axis=0) / dt\n b_n = sum(dxy * d_sin_phi_n, axis=0) / dt\n c_n = sum(dxy**2, axis=0) / dt\n d_n = sum(dxy * (d_cos_phi_n + d_sin_phi_n), axis=0) / dt\n\n coeffs[4*n:4*n+4] = a_n - b_n * np.cos(phi_n) - c_n * np.sin(phi_n) - d_n * np.sin(2*phi_n)\n\n if normalize:\n coeffs = normalize_efd(coeffs)\n\n return coeffs\n```"} +{"i": 171, "got": "```python\ndef normalize_efd(coeffs, size_invariant):\n \"\"\"\n pass\n \"\"\"\n theta_1 = np.arctan2(0.5 * (coeffs[0] ** 2 + coeffs[1] ** 2 + coeffs[2] ** 2 + coeffs[3] ** 2), coeffs[0] * coeffs[2] - coeffs[1] * coeffs[3])\n psi_1 = np.arctan2(0.5 * (coeffs[0] ** 2 + coeffs[1] ** 2 + coeffs[2] ** 2 + coeffs[3] ** 2), coeffs[0] * coeffs[2] - coeffs[1] * coeffs[3])\n psi_rotation_matrix = np.array([[np.cos(psi_1), -np.sin(psi_1)], [np.sin(psi_1), np.cos(psi_1)]])\n \n for n in range(coeffs.shape[0]):\n theta_1[n] = np.arctan2(0.5 * (coeffs[n, 0] ** 2 + coeffs[n, 1] ** 2 + coeffs[n, 2] ** 2 + coeffs[n, 3] ** 2), coeffs[n, 0] * coeffs[n, 2] - coeffs[n, 1] * coeffs[n, 3])\n psi_1[n] = np.arctan2(0.5 * (coeffs[n, 0] ** 2 + coeffs[n, 1] ** 2 + coeffs[n, 2] ** 2 + coeffs[n, 3] ** 2), coeffs[n, 0] * coeffs[n, 2] - coeffs[n, 1] * coeffs[n, 3])\n psi_rotation_matrix[n] = np.array([[np.cos(psi_1[n]), -np.sin(psi_1[n])], [np.sin(psi_1[n]), np.cos(psi_1[n])]])\n \n if size_invariant:\n coeffs /= np.abs(coeffs[:, 0])\n \n return coeffs\n```"} +{"i": 172, "got": "```python\nimport numpy as np\n\ndef calculate_dc_coefficients(contour):\n \"\"\"\n pass\n \"\"\"\n dxy = np.diff(contour, axis=1)\n dt = np.sqrt(np.sum(dxy**2, axis=1))\n t = np.cumsum(dt)\n T = np.cumsum(dxy[:, 0])\n xi = (T - T[0]) / dt\n A0 = np.cumsum(dxy[:, 1], axis=1) * dt\n delta = np.cumsum(dxy[:, 0], axis=1) * dt\n C0 = A0 + delta * dt**2\n return (xi, A0, C0)\n```"} +{"i": 173, "got": "```python\nimport matplotlib.pyplot as plt\nimport numpy as np\n\ndef plot_efd(coeffs, locus, image, contour, n):\n \"\"\"\n pass\n \"\"\"\n N = coeffs.shape[0]\n N_half = int(np.ceil(N / 2))\n n_rows = int(np.floor(N / 2))\n t = np.linspace(0, 1.0, n)\n xt = np.ones(n) * locus[0]\n yt = np.ones(n) * locus[1]\n\n for n in range(N):\n xt[n] += coeffs[n][0] * np.cos(2 * np.pi * n / N) * t\n yt[n] += coeffs[n][1] * np.sin(2 * np.pi * n / N) * t\n\n ax = plt.subplot2grid(n_rows, N_half, (n_rows - 1, N_half - int(N / 2)))\n ax.set_title(f'n={n}')\n if contour is not None:\n ax.plot(contour[:, :, 0], contour[:, :, 1], 'c--', linewidth=2)\n ax.plot(yt, xt, 'r', linewidth=2)\n\n image = np.random.rand(10, 10) # Example image\n if image is not None:\n plt.imshow(image, cmap='gray')\n\n plt.show()\n```"} +{"i": 174, "got": "```python\ndef _errcheck(result, func, arguments):\n \"\"\"\n pass\n \"\"\"\n if result != 0:\n raise XdoException(f\"Function {func.__name__} returned error code {result}\")\n return None\n```"} +{"i": 175, "got": "```python\ndef _gen_input_mask(mask):\n \"\"\"\n pass\n \"\"\"\n shift = bool(input_mask & MOD_Shift)\n lock = bool(input_mask & MOD_Lock)\n control = bool(input_mask & MOD_Control)\n mod1 = bool(input_mask & MOD_Mod1)\n mod2 = bool(input_mask & MOD_Mod2)\n mod3 = bool(input_mask & MOD_Mod3)\n mod4 = bool(input_mask & MOD_Mod4)\n mod5 = bool(input_mask & MOD_Mod5)\n\n return shift, lock, control, mod1, mod2, mod3, mod4, mod5\n```"} +{"i": 176, "got": "```python\nclass Module:\n def __init__(self):\n self.move_mouse = self.move_mouse\n\n def move_mouse(self, x, y, screen):\n import ctypes\n _libxdo = ctypes.CDLL(None)\n _libxdo.xdo_move_mouse.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_int]\n _libxdo.xdo_move_mouse.restype = None\n\n self._xdo = _libxdo\n self._xdo.xdo_move_mouse(self, x, y, screen)\n```"} +{"i": 177, "got": "```python\ndef move_mouse_relative_to_window(self, window, x, y):\n \"\"\"\n pass\n \"\"\"\n _libxdo = ctypes.CDLL(None)\n _libxdo.xdo_move_mouse_relative_to_window.argtypes = [ctypes.c_ulong, ctypes.c_long, ctypes.c_long]\n _libxdo.xdo_move_mouse_relative_to_window.restype = None\n\n self._xdo.xdo_move_mouse_relative_to_window(window, x, y)\n```"} +{"i": 178, "got": "```python\ndef move_mouse_relative(self, x, y):\n \"\"\"\n pass\n \"\"\"\n _libxdo.xdo_move_mouse_relative(self._xdo, x, y)\n```"} +{"i": 179, "got": "```python\ndef mouse_down(self, window, button):\n \"\"\"\n pass\n \"\"\"\n _libxdo.xdo_mouse_down(ctypes.c_ulong(window), ctypes.c_int(button))\n```"} +{"i": 180, "got": "```python\ndef strip_punctuation_space(value):\n \"\"\"pass\"\"\"\n def strip_punctuation(string):\n \"\"\"strip punctuation from a string\"\"\"\n replacement_list = ((' .', '.'), (' :', ':'), ('( ', '('), (' )', ')'))\n for match, replacement in replacement_list:\n string = string.replace(match, replacement)\n return string\n```"} +{"i": 181, "got": "```python\ndef join_sentences(string1, string2, glue):\n if not string1:\n return string2\n elif not string2:\n return string1\n else:\n new_string = string1.rstrip()\n if new_string.endswith(glue):\n new_string += glue\n new_string += string2.lstrip() + ' '\n return new_string\n```"} +{"i": 182, "got": "```python\ndef coerce_to_int(val, default):\n \"\"\"pass\"\"\"\n if isinstance(val, int):\n return val\n elif isinstance(val, str) and val.isdigit():\n return int(val)\n else:\n return default\n```"} +{"i": 183, "got": "```python\ndef nullify():\n pass\n\nnullify_wrapper = lambda *args, **kwargs: (\n nullify,\n {\n 'wrapper': nullify_wrapper,\n 'value': args[0] if args else kwargs.get('value', None)\n }\n)[1]['value']\n```"} +{"i": 184, "got": "```python\ndef strippen(*args, **kwargs):\n \"\"\"pass\"\"\"\n wrapper = strip_strings(args, kwargs)\n return wrapper\n\ndef strip_strings(*args, **kwargs):\n \"\"\"pass\"\"\"\n return args + tuple(kwargs.values())\n```"} +{"i": 185, "got": "```python\ndef inten():\n pass\n\ninten_wrapper = lambda *args, **kwargs: coerce_to_int(args[0]) + inten(*args, **kwargs)\n\ndef coerce_to_int(value):\n return value\n```"} +{"i": 186, "got": "```python\ndef connect(url, max_retries, **kwargs):\n \"\"\"\n pass\n \"\"\"\n client = AvaticaClient(max_retries=max_retries)\n connection = Connection(client=client, **kwargs)\n```\n\nThis Python function `connect` takes a URL, maximum retries, and keyword arguments as input. It creates an instance of `AvaticaClient` with the specified maximum retries, then uses this client to create a new `Connection`. The `Connection` is initialized with the client and any additional keyword arguments provided."} +{"i": 187, "got": "```python\ndef connect(self):\n \"\"\"pass\"\"\"\n logger.debug('Opening connection to %s:%s', self.url, self.hostname)\n conn = httplib.HTTPConnection(self.url, self.port)\n self.connection = conn\n self.connection.connect()\n```\n\nThis Python function `connect` is defined with a docstring explaining its purpose. It opens a connection to the specified URL and port using the `httplib` library. The connection object is stored in the instance variable `self.connection`."} +{"i": 188, "got": "```python\nclass Close:\n def __init__(self, connection):\n self.connection = connection\n\n def close(self):\n if self.connection is None:\n return\n logger.debug(f\"Closing connection to {self.url}:{self.port}\")\n try:\n self.connection.close()\n except Exception as e:\n logger.warning(\"Error while closing connection\", exc_info=True)\n```"} +{"i": 189, "got": "```python\nclass ConnectionSync:\n def __init__(self, connection_id, connProps):\n self.connection_id = connection_id\n self.connProps = connProps\n\n def _apply(self, request):\n # Implementation of the apply method\n pass\n\n def ParseFromString(self, response_data):\n # Implementation of the ParseFromString method\n pass\n\n @staticmethod\n def connection_sync(connection_id, connProps):\n return ConnectionSync(connection_id, connProps)\n```"} +{"i": 190, "got": "```python\nclass open_connection:\n def __init__(self, connection_id, info):\n self.request = requests_pb2.OpenConnectionRequest()\n self.connection_id = connection_id\n self.info = info\n\n def _apply(self, request):\n # Implementation of the apply method\n pass\n\n def ParseFromString(self, response_data):\n # Implementation of the ParseFromString method\n pass\n```"} +{"i": 191, "got": "```python\ndef close_connection(self, connection_id):\n \"\"\"pass\"\"\"\n requests_pb2.CloseConnectionRequest()\n self._apply(request)\n return None\n```"} +{"i": 192, "got": "```python\ndef fit(self, X, y):\n \"\"\"\n pass\n \"\"\"\n self.X = X\n self.y = y\n if hasattr(self, 'gamma') and hasattr(self, '_optimize_gamma'):\n self.gamma = _optimize_gamma(self.gamma)\n return None\n```"} +{"i": 193, "got": "```python\nclass KernelPredictor:\n def predict(self, X):\n \"\"\"\n pass\n \"\"\"\n K = pairwise_kernels(X, X, metric='metric', gamma=self.gamma)\n return sum(K) / sum(K[:, :X.shape[1]])\n```"} +{"i": 194, "got": "```python\nclass MyClass:\n def __init__(self, activation_func=None, activation_args=None):\n self.activation_func = activation_func\n self.activation_args = activation_args\n\n def _compute_hidden_activations(self, X):\n acts = self._compute_input_activations(X)\n if callable(self.activation_func):\n args_dict = {}\n if self.activation_args:\n args_dict.update(self.activation_args)\n X_new = self.activation_func(acts, **args_dict)\n else:\n X_new = acts\n return X_new\n\n def _internal_activation_funcs(self):\n # Implementation of internal activation functions\n pass\n\n def _extra_args(self):\n # Implementation of extra arguments\n pass\n```"} +{"i": 195, "got": "```python\nclass Module:\n def __init__(self):\n self.components_ = None\n\n def transform(self, X, y):\n if self.components_ is not None:\n hidden_activations = self._compute_hidden_activations(X)\n return hidden_activations\n else:\n raise ValueError('No components initialized')\n```"} +{"i": 196, "got": "```python\nclass MyClass:\n def _compute_radii(self):\n \"\"\"\n pass\n \"\"\"\n self.radii = self._get_user_components('radii')\n if self.radii is not None:\n self.centers = self.components_['centers']\n n_centers = len(self.centers)\n max_dist = np.max(pairwise_distances(self.centers))\n radii = np.sqrt(2.0 * max_dist) * np.ones(n_centers)\n self.radii = self.radii\n else:\n self.radii = None\n\n def _get_user_components(self, component_name):\n # Implementation of _get_user_components method\n pass\n```"} +{"i": 197, "got": "```python\nclass MyClass:\n def _compute_centers(self, X, sparse, rs):\n \"\"\"\n pass\n \"\"\"\n max_dtype = None\n min_dtype = None\n\n centers = self.get_user_components('centers')\n n_features = centers.shape[0]\n if not sparse:\n fxr = range(n_features)\n else:\n fxr = np.arange(n_features)\n\n cols = []\n i = 0\n for i in range(n_features):\n col = X[:, i]\n cols.append(col)\n\n min_Xs = self.min(X, axis=0)\n spans = np.diff(min_Xs, axis=1)\n n_hidden = self.n_hidden\n ctrs_size = n_hidden * n_features\n\n centers = self.uniform(0.0, 1.0, ctrs_size)\n self.components_['centers'] = centers\n\n def get_user_components(self, name):\n # Implementation of get_user_components method\n pass\n\n def getcol(self, X, i):\n # Implementation of getcol method\n pass\n\n def min(self, X, axis=0):\n # Implementation of min method\n pass\n\n def max(self, X, axis=0):\n # Implementation of max method\n pass\n\n def uniform(self, low, high, size):\n # Implementation of uniform method\n pass\n\n def components_(self, name, value):\n # Implementation of components_ method\n pass\n```"} +{"i": 198, "got": "```python\ndef compat_serializer_check_is_valid(serializer):\n \"\"\"\n pass\n \"\"\"\n DRFVLIST = None\n if DRFVLIST[0] >= 3:\n serializer.is_valid()\n else:\n raise serializers.ValidationError('The serializer raises a validation error')\n```"} +{"i": 199, "got": "```python\ndef compat_serializer_attr(serializer, obj):\n \"\"\"pass\"\"\"\n DRFVLIST = [0, 1]\n for i in range(len(DRFVLIST)):\n if DRFVLIST[i] == serializer.instance.id:\n return obj\n return obj\n```"} +{"i": 200, "got": "```python\ndef compat_get_paginated_response(view, page):\n \"\"\"\n pass\n \"\"\"\n DRFVLIST = None\n serializer = None\n\n if DRFVLIST[0] == 3 and DRFVLIST[1] >= 1:\n ComplexMessageSerializer = rest_messaging.serializers.ComplexMessageSerializer\n serializer = ComplexMessageSerializer(page, many=True)\n else:\n serializer = Response(serializer.data)\n\n return serializer\n```"} +{"i": 201, "got": "```python\nclass compat_pagination_messages:\n def __init__(self, cls):\n DRFVLIST = getattr(settings, 'DJANGO_REST_MESSAGING_MESSAGES_PAGE_SIZE', 30)\n setattr(cls, 'pagination_class', MessagePagination())\n setattr(cls, 'paginate_by', DRFVLIST)\n\n @classmethod\n def compat_pagination_messages(cls):\n return None\n```"} +{"i": 202, "got": "```python\nclass MyClass:\n def __init__(self, callback):\n self.callback = callback\n\n def get_participants(self, obj):\n if self.callback is not None:\n return [participant.id for participant in obj.participants]\n else:\n raise ValueError(\"Callback function is not set\")\n```\n\nIn this Python 3.12 bytecode disassembly, the original source code has been reconstructed to create a class `MyClass` with an instance method `get_participants`. The method checks if a callback function is set and returns a list of participant IDs if it is. If no callback function is set, it raises a `ValueError`."} +{"i": 203, "got": "```python\nclass MyClass:\n def get_is_notification(self, obj):\n \"\"\"\n pass\n \"\"\"\n o = compat_serializer_attr(self, obj)\n return o.is_notification\n```"} +{"i": 204, "got": "```python\ndef process(self, quoted):\n \"\"\"pass\"\"\"\n from urllib.parse import urlparse, quote\n\n self.p = urlparse(quoted)\n self.scheme = self.p.scheme\n self.netloc = self.p.netloc\n if not quoted:\n self.path = self.p.path\n else:\n self.path = quote(self.p.path)\n self.opath = self.p.path.split('/')\n for x in self.opath:\n self.path.append(x)\n self.params = parse_qs(self.p.query, keep_blank_values=True)\n self.query = self.p.query\n self.fragment = self.p.fragment\n```"} +{"i": 205, "got": "```python\nclass WebHelper:\n def __init__(self):\n self.cache = {}\n\n def encode_url(self, url):\n # Implementation of encode_url method\n pass\n\n def retrieve_blob(self, url):\n # Implementation of retrieve_blob method\n pass\n\n def add_header(self, req, header_name, value):\n # Implementation of add_header method\n pass\n\n def read(self, response):\n # Implementation of read method\n pass\n\n def decode(self, content, encoding):\n # Implementation of decode method\n pass\n\n def fetch(self, url, encoding='utf-8', force_refetch=False, nocache=False, quiet=False):\n if not nocache or url not in self.cache:\n if force_refetch:\n response = self.retrieve_blob(url)\n else:\n response = self.read(self.cache[url])\n content = self.decode(response, encoding)\n if not quiet:\n print(f\"Fetching: {url} | Content: {content}\")\n return content\n```"} +{"i": 206, "got": "```python\nimport os\n\nclass Download:\n def __init__(self, path):\n self.path = path\n\n def isfile(self):\n return os.path.isfile(self.path)\n\n def fetch(self, url, force_refetch=False, nocache=False):\n # Simulate fetching the file from a server\n response = \"Mocked response\"\n if not force_refetch and not nocache:\n return True\n return False\n\n def write(self, content):\n with open(self.path, 'wb') as f:\n f.write(content)\n\n def format(self, *args):\n return str(args)\n```\n\nThis Python code snippet reconstitutes the functionality of the given bytecode disassembly. It defines a `Download` class with methods to check if a file exists, fetch a file from a server, write content to a file, and format strings. The `fetch` method simulates fetching the file based on the provided parameters."} +{"i": 207, "got": "```python\ndef _platform(self):\n pass\n\ndef main():\n return 'return'\n\nif __name__ == \"__main__\":\n print(main())\n```"} +{"i": 208, "got": "```python\ndef _delay(self):\n pass\n\ndef main():\n return 'return'\n\nif __name__ == \"__main__\":\n print(main())\n```"} +{"i": 209, "got": "```python\nimport datetime\n\nclass Departure:\n def __init__(self, journey, MainStop, BasicStop, Dep, Time):\n self.journey = journey\n self.MainStop = MainStop\n self.BasicStop = BasicStop\n self.Dep = Dep\n self.Time = Time\n\n @property\n def departure_time(self):\n return datetime.datetime.strptime(self.Journey.MainStop.BasicStop.Dep.Time.text, '%H:%M')\n\n @departure_time.setter\n def departure_time(self, value):\n self.Journey.MainStop.BasicStop.Dep.Time.text = value.strftime('%H:%M')\n\n @property\n def now(self):\n return datetime.datetime.now()\n\n @property\n def combine(self, date, time):\n return datetime.datetime.combine(date, time)\n\n @property\n def timedelta(self, hours=1):\n return datetime.timedelta(hours=hours)\n```"} +{"i": 210, "got": "```python\ndef _extract(self, attribute):\n journey = self.journey.JourneyAttributeList.JourneyAttribute\n attr_types = self.attr_types.NULL|self.index\n xpath = 'AttributeVariant/@type'\n attr_variants = journey.AttributeVariant[attr_types]\n data = attr_variants[index].Text.pyval\n return str(data)\n```"} +{"i": 211, "got": "```python\ndef _info(self):\n pass\n\ndef main():\n return 'return'\n\nif __name__ == \"__main__\":\n print(main())\n```"} +{"i": 212, "got": "```python\ndef _info_long(self):\n \"\"\"pass\"\"\"\n while True:\n try:\n text = self.journey.InfoTextList.InfoText[self.get('textL')]\n text = text.replace('
', '\\n')\n except AttributeError:\n return None\n```\n\nThis Python function `_info_long` is defined to handle the logic described in the bytecode disassembly. It attempts to retrieve a specific information from an object `self.journey`, replace certain HTML tags, and return the modified text. If an `AttributeError` occurs during this process, it catches the exception and returns `None`."} +{"i": 213, "got": "```python\ndef validate(style):\n \"\"\"pass\"\"\"\n import jsonschema\n\n def validate(self, style):\n schema = ...\n try:\n jsonschema.validate(instance=self, schema=schema)\n except jsonschema.ValidationError as exc:\n new_exc = StyleValidationError(exc)\n raise new_exc from None\n return None\n```"} +{"i": 214, "got": "```python\ndef value_type(value):\n \"\"\"\n pass\n \"\"\"\n keys = list(value.keys())\n if 'lookup' in keys or 're_lookup' in keys or 'interval' in keys:\n return 'simple'\n else:\n raise ValueError('Type of `value` could not be determined')\n```"} +{"i": 215, "got": "```python\ndef _register_mecab_loc(location):\n \"\"\"pass\"\"\"\n import os\n if not os.path.isfile(location):\n logging.getLogger(__name__).warning('Provided mecab binary location does not exist {}'.format(location))\n else:\n logging.getLogger(__name__).info('Mecab binary is switched to: {}'.format(location))\n MECAB_LOC = location\n```"} +{"i": 216, "got": "```python\ndef run_mecab_process(content, *args, **kwargs):\n \"\"\"pass\"\"\"\n encoding = kwargs.get('encoding', 'utf-8')\n mecab_loc = kwargs.get('mecab_loc', None)\n \n if mecab_loc is not None:\n proc_args = [mecab_loc]\n else:\n proc_args = []\n \n proc_args.extend(args)\n \n output = subprocess.run(proc_args, input=content.encode(encoding), stdout=subprocess.PIPE).stdout.decode(encoding).splitlines()\n \n return '\\n'.join(output)\n```"} +{"i": 217, "got": "```python\ndef parse(content, *args, **kwargs):\n \"\"\"\n pass\n \"\"\"\n if 'mecab_loc' in kwargs:\n mecab = MECAB_PYTHON3 if 'MeCab' not in globals() else MeCab\n tagger = mecab.Tagger()\n result = tagger.parse(content)\n return result\n\ndef run_mecab_process(content, *args, **kwargs):\n \"\"\"\n pass\n \"\"\"\n mecab = MECAB_PYTHON3 if 'MeCab' not in globals() else MeCab\n tagger = mecab.Tagger()\n result = tagger.parse(content)\n return result\n```"} +{"i": 218, "got": "```python\nclass Track:\n def __init__(self, path_in_ipod):\n self.path_in_ipod = path_in_ipod\n\ndef create_track(self, path_in_ipod, checksum):\n if not bool(path_in_ipod):\n raise Exception(\"path_in_ipod is None\")\n if not bool(checksum):\n raise Exception(\"checksum is None\")\n\n audiodb = self.audiodb\n voice = audiodb.get_voice(checksum)\n track = Track(path_in_ipod)\n return track\n```"} +{"i": 219, "got": "```python\nclass voice:\n def __init__(self, lldb, dbid):\n self.lldb = lldb\n self.dbid = dbid\n\n def _voiceoverdb(self):\n return get_text_lang(self.dbid)\n\n def voice(self):\n text, lang = self._voiceoverdb()\n return (text, lang)\n```"} +{"i": 220, "got": "```python\ndef add(self, src):\n \"\"\"pass\"\"\"\n audio = None # Assuming audio is a global variable or imported from another module\n type_ = get_type(src) # Assuming get_type is a function that returns the type of the input\n if type_ not in (int, float): # Check if the type is supported\n raise TypeError('The type of this file is not supported.')\n super().add(src) # Call the superclass method with the source\n```"} +{"i": 221, "got": "```python\ndef _get_cmd(command, arguments):\n \"\"\"pass\"\"\"\n if arguments is not None:\n return [arguments]\n else:\n if command.endswith('.py'):\n return [sys.executable, command] + list(arguments)\n elif command.endswith('.pyw'):\n return [sys.executable, command] + list(arguments)\n else:\n return [command] + list(arguments)\n```"} +{"i": 222, "got": "```python\nimport argparse\n\ndef add_arg(parser, arg_spec):\n parser.add_argument(arg_spec.name, help=arg_spec.help)\n\ndef parse_request(parser, args):\n return parser.parse_args(args)\n\ndef subscribe(observer):\n observer.subscribe(parse_request)\n```\n\nThis Python script defines a class `argparse` with methods to add arguments, parse requests, and subscribe observers. The `add_arg` method adds an argument to the parser using the provided specification. The `parse_request` method parses the command-line arguments into an object. The `subscribe` method subscribes an observer to the request parsing process."} +{"i": 223, "got": "```python\nimport numpy as np\n\ndef qn(phi, *n):\n \"\"\"\n pass\n \"\"\"\n i_n_phi = np.ravel(np.asarray(n)) + phi * np.zeros(np.size(n), dtype=complex)\n np.outer(n, phi, out=i_n_phi.imag)\n np.exp(i_n_phi.imag, out=i_n_phi)\n qn = np.sum(i_n_phi, axis=1) if len(n) == 1 else i_n_phi\n return qn[0] if len(qn) == 1 else qn\n```"} +{"i": 224, "got": "```python\ndef correlation(self, n, k, error):\n \"\"\"pass\"\"\"\n self._calculate_corr(n, k)\n if error:\n self._calculate_corr_err(n, k)\n return corr_nk\n```"} +{"i": 225, "got": "```python\ndef cumulant(self, n, k, error):\n \"\"\"pass\"\"\"\n corr_nk = self.correlation(n, k)\n if k == 2:\n return corr_nk\n elif k == 4:\n return self.correlation(n, 2) * self.correlation(n, 2) - self.correlation(n, 2) * self.correlation(n, 2)\n else:\n return None\n```"} +{"i": 226, "got": "```python\nclass Flow:\n def __init__(self, cumulant):\n self.cumulant = cumulant\n\n @property\n def _cnk_prefactor(self):\n return 1 / (2 * self.k)\n\n def warn(self, imaginary):\n if imaginary == 'negative':\n warnings.warn('Imaginary flow: returning NaN.', RuntimeWarning)\n elif imaginary == 'zero':\n vnk = 0.0\n else:\n vnk = -np.sqrt(np.abs(self.cnk) ** (1 / self.k))\n return vnk\n\n def __call__(self, n, k, error, imaginary):\n cnk = self.cumulant(n, k)\n if error is not None:\n cnk_err = error\n else:\n cnk_err = None\n\n vnk_to_k = cnk * (1 / self.k)\n kinv = 1 / self.k\n vnk = vnk_to_k ** (imaginary == 'negative') * np.sqrt(np.abs(cnk) ** (1 / self.k))\n\n if k == 2 and error is not None:\n return 0.5 * cnk / np.sqrt(np.abs(cnk) ** (1 / self.k))\n else:\n return vnk\n```"} +{"i": 227, "got": "```python\ndef _pdf(self, phi):\n \"\"\"\n pass\n \"\"\"\n np = self.inner\n vn = self._vn\n cos = self.cos\n outer = self.outer\n phi = self._n * phi\n pdf = np * phi + np * cos + np * outer\n pdf *= 2.0\n pdf += 1.0\n return pdf\n```"} +{"i": 228, "got": "```python\nimport numpy as np\n\ndef _uniform_phi(M):\n \"\"\"\n pass\n \"\"\"\n return np.random.uniform(-np.pi, np.pi) * M\n```"} +{"i": 229, "got": "```python\ndef smart_text(s, encoding='utf-8', strings_only=False, errors=None):\n if isinstance(s, str):\n return s\n elif isinstance(s, bytes) and not strings_only:\n return s.decode(encoding, errors)\n else:\n raise TypeError(\"smart_text() argument must be a string or bytes\")\n```"} +{"i": 230, "got": "```python\ndef smart_bytes(s, encoding='utf-8', strings_only=False, errors=None):\n if isinstance(s, bytes):\n return s\n elif isinstance(s, str) and not strings_only:\n return s.encode(encoding, errors)\n else:\n raise TypeError(\"smart_bytes() argument must be a string or bytes\")\n```"} +{"i": 231, "got": "```python\nclass Output:\n def __init__(self, response, accepts):\n self.graph = get_graph(self)\n self.format_selector = decide(self)\n self.context_aware = context_aware(self)\n mimetype, format = format_selector(self, accepts)\n if mimetype is not None and mimetype.endswith('; charset=utf-8'):\n mimetype = mimetype[:-10]\n serialized = serialize(self, format)\n response = make_new_response(self, response, mimetype, serialized)\n return response\n```"} +{"i": 232, "got": "```python\ndef decorate(self, view):\n \"\"\"pass\"\"\"\n wraps = functools.wraps(view)\n response = view(*args, **kwargs)\n accept = self.get_accept()\n output(response, accept)\n\n@functools.wraps(decorate)\ndef decorated(*args, **kwargs):\n copy_free_vars(2)\n response = decorate(*args, **kwargs)\n accept = self.get_accept()\n output(response, accept)\n```"} +{"i": 233, "got": "```python\nclass Module:\n def __init__(self):\n self.get = self.get\n\n def get(self, var, default=None):\n try:\n return getattr(self, var)\n except (KeyError, IndexError) as e:\n if isinstance(e, KeyError):\n return default\n else:\n raise e\n```"} +{"i": 234, "got": "```python\nclass MyClass:\n def __init__(self):\n self.auto_save = True\n\n def insert(self, var, value, index=None):\n if not isinstance(var, list):\n raise KeyError(f\"{var}: is not a list\")\n \n current = getattr(self, var)\n if index is None:\n current.append(value)\n else:\n current.insert(index, value)\n\n if self.auto_save:\n self.save()\n\n def save(self):\n pass\n```"} +{"i": 235, "got": "```python\nclass MyClass:\n def __init__(self):\n self.__configs = set()\n\n @property\n def keys(self):\n return self.__configs | set()\n```"} +{"i": 236, "got": "```python\nclass MyClass:\n def __init__(self, scope, key_prefix, client):\n self.scope = scope\n self.key_prefix = key_prefix\n self.client = client\n\n def get(self, variable_path, default=None, coerce_type=None, coercer=None, **kwargs):\n if hasattr(self, 'scope'):\n variable_path = f\"{self.scope}{self.path_separator}{variable_path}\"\n if hasattr(self, 'key_prefix'):\n variable_path = f\"{self.key_prefix}:{variable_path}\"\n\n val = self.client.get(variable_path)\n if val is not None:\n return val\n\n if default is not None:\n return default\n\n if hasattr(self, 'coerce'):\n bundle = self.coerce(val, coerce_type, coercer)\n if isinstance(bundle, bytes):\n bundle = self.decode(bundle)\n return bundle\n```"} +{"i": 237, "got": "```python\nimport logging\n\ndef setup_logging(verbose, logger):\n \"\"\"pass\"\"\"\n if verbose:\n format_ = '%(asctime)s %(levelname)-8s %(name)-40s %(message)s'\n else:\n format_ = '%(message)s'\n\n root_logger = logging.getLogger(logger)\n root_logger.setLevel(level)\n\n handler_stdout = logging.StreamHandler(sys.stdout)\n handler_stderr = logging.StreamHandler(sys.stderr)\n\n formatter = logging.Formatter(format_)\n handler_stdout.setFormatter(formatter)\n handler_stderr.setFormatter(formatter)\n\n root_logger.addHandler(handler_stdout)\n root_logger.addHandler(handler_stderr)\n```"} +{"i": 238, "got": "```python\ndef with_log(func):\n \"\"\"pass\"\"\"\n func = func.__closure__[0]\n wrapper = functools.wraps(func)\n decorator_logger = logging.getLogger('@with_log')\n decorator_logger.debug('Entering %s() function call.', func.__name__)\n log = decorator_logger.debug('log', func.__name__)\n ret = func(*args, **kwargs)\n decorator_logger.debug('Leaving %s() function call.', func.__name__)\n return ret\n```"} +{"i": 239, "got": "```python\ndef get_arguments(argv, environ):\n \"\"\"pass\"\"\"\n name = argv[0]\n environ = environ.copy()\n commit = None\n owner = None\n pull_request = None\n repo = None\n tag = None\n\n require = pkg_resources.require('appveyor-artifacts')\n project_name = require[0].project_name\n version = require[0].version\n\n args = docopt(__doc__, argv=argv, version=version)\n\n commit = args.get('--commit', '')\n owner = args.get('--owner-name', '')\n pull_request = args.get('--pull-request', '')\n repo = args.get('--repo-name', '')\n tag = args.get('--tag-name', '')\n\n always_job_dirs = args.get('--always-job-dirs', False)\n commit = args.get('--commit', commit)\n dir = args.get('--dir', '')\n ignore_errors = args.get('--ignore-errors', False)\n job_name = args.get('--job-name', '')\n mangle_coverage = args.get('--mangle-coverage', False)\n no_job_dirs = args.get('--no-job-dirs', False)\n owner = args.get('--owner', owner)\n pull_request = args.get('--pull-request', pull_request)\n raise_ = args.get('--raise', False)\n repo = args.get('--repo', repo)\n tag = args.get('--tag', tag)\n verbose = args.get('--verbose', False)\n\n config = {\n 'always_job_dirs': always_job_dirs,\n 'commit': commit,\n 'dir': dir,\n 'ignore_errors': ignore_errors,\n 'job_name': job_name,\n 'mangle_coverage': mangle_coverage,\n 'no_job_dirs': no_job_dirs,\n 'owner': owner,\n 'pull_request': pull_request,\n 'raise_': raise_,\n 'repo': repo,\n 'tag': tag,\n 'verbose': verbose\n }\n\n return config\n```"} +{"i": 240, "got": "```python\nimport requests\nfrom requests.exceptions import ConnectTimeout, ReadTimeout, Timeout, ConnectionError, ValueError\n\nclass HandledError(Exception):\n pass\n\nAPI_PREFIX = \"https://api.example.com\"\nQUERY_ATTEMPTS = 3\n\ndef query_api(endpoint, log):\n url = API_PREFIX + endpoint\n headers = {'Content-Type': 'application/json'}\n response = None\n debug = getattr(self, 'debug', False)\n \n for _ in range(QUERY_ATTEMPTS):\n try:\n response = requests.get(url, headers=headers, timeout=10)\n break\n except (ConnectTimeout, ReadTimeout, Timeout, ConnectionError):\n log.debug(f\"Querying {endpoint} with headers {headers}.\")\n continue\n \n if not response.ok:\n log.error(f\"Response status: {response.status_code}\")\n log.error(f\"Response headers: {str(response.headers)}\")\n log.error(f\"Response text: {response.text}\")\n \n if response.status_code == 400:\n message = response.json().get('message', 'Unknown error')\n raise HandledError(f'HTTP {response.status_code}: {message}')\n else:\n raise HandledError(f'HTTP {response.status_code}: Unknown error: {response.text}')\n \n log.debug(f\"Response status: {response.status_code}\")\n log.debug(f\"Response headers: {str(response.headers)}\")\n log.debug(f\"Response text: {response.text}\")\n \n return response.json()\n```"} +{"i": 241, "got": "```python\ndef validate(config, log):\n \"\"\"\n pass\n \"\"\"\n if config['always_job_dirs']:\n if not config['no_job_dirs']:\n raise HandledError(\"Contradiction: --always-job-dirs and --no-job-dirs used.\")\n elif config['commit']:\n match = REGEX_COMMIT.match(config['commit'])\n if match:\n pass\n else:\n raise HandledError(\"No or invalid git commit obtained.\")\n elif config['dir']:\n if os.path.isdir(config['dir']):\n pass\n else:\n raise HandledError(f\"Not a directory or doesn't exist: {config['dir']}\")\n elif config['no_job_dirs'] in ('', 'rename', 'overwrite', 'skip'):\n pass\n elif config['owner']:\n match = REGEX_GENERAL.match(config['owner'])\n if match:\n pass\n else:\n raise HandledError(\"No or invalid repo owner name obtained.\")\n elif config['pull_request'].isdigit():\n pass\n elif config['repo']:\n match = REGEX_GENERAL.match(config['repo'])\n if match:\n pass\n else:\n raise HandledError(\"No or invalid repo name obtained.\")\n elif config['tag']:\n match = REGEX_GENERAL.match(config['tag'])\n if match:\n pass\n else:\n raise HandledError(\"Invalid git tag obtained.\")\n\ndef main():\n # Example usage\n config = {'always_job_dirs': True, 'no_job_dirs': False, 'commit': 'abc123', 'dir': '/path/to/directory'}\n log = Log() # Assuming Log is a class with error attribute\n validate(config, log)\n\nif __name__ == \"__main__\":\n main()\n```"} +{"i": 242, "got": "```python\ndef query_build_version(config, log):\n \"\"\"pass\"\"\"\n url = f\"/projects/{config['owner']}/{config['repo']}/history?recordsNumber=10\"\n log.debug(f\"Querying AppVeyor history API for {config['owner']}/{config['repo']}...\")\n json_data = query_api(url)\n if 'builds' not in json_data:\n raise HandledError(\"Bad JSON reply: 'builds' key missing.\")\n for build in json_data['builds']:\n tag = build.get('tag')\n if tag is not None:\n log.debug(f\"This is a tag build.\")\n pull_request_id = build.get('pullRequestId')\n if pull_request_id is not None:\n log.debug(f\"This is a pull request build.\")\n commit_id = build.get('commitId')\n if commit_id is not None:\n log.debug(f\"This is a branch build.\")\n log.debug(f\"Build JSON dict: {build}\")\n return build['version']\n```"} +{"i": 243, "got": "```python\nclass Module:\n def __init__(self):\n self.incoming_messages = None\n\n def incoming_messages(self):\n approximate_messages = list(range(len(self._receive_buffer)))\n messages = []\n while True:\n try:\n message = self._receive_buffer.get_nowait()\n messages.append(message)\n except queue.Empty:\n break\n return messages\n```"} +{"i": 244, "got": "```python\ndef _safe_get(mapping, key, default):\n \"\"\"pass\"\"\"\n try:\n return mapping.get(key, default)\n except AttributeError as e:\n if isinstance(e, KeyError):\n return default\n raise\n```"} +{"i": 245, "got": "```python\ndef strip_callables(row):\n \"\"\"pass\"\"\"\n callables = []\n to_delete = []\n to_add = []\n\n columns = row.items()\n for column, value in columns:\n if isinstance(value, (list, tuple)):\n initial, fn = value\n if callable(fn):\n to_add.append((column, fn))\n elif inspect.isgenerator(fn):\n to_delete.append(column)\n else:\n callables.append((column, fn))\n\n lgr.debug('Using %r as the initial value for columns %r in row %r', initial, columns, row)\n\n if isinstance(columns, (list, tuple)):\n columns = tuple(columns)\n for column in to_delete:\n del columns[column]\n for column, fn in to_add:\n columns.append(fn(column))\n\n callables.extend(columns)\n return callables\n```"} +{"i": 246, "got": "```python\nclass build:\n def __init__(self, columns):\n self.columns = columns\n\n def __call__(self, columns):\n default = 'default_'\n elements = None\n init_style = 'default_'\n style = 'default_'\n c = None\n ngaps = 0\n width_separtor = 0\n lgr = None\n\n # Your code here\n```"} +{"i": 247, "got": "```python\nclass _compose:\n def __init__(self, self, name, attributes):\n pass\n\n def _safe_get(self, obj, key):\n return getattr(obj, key)\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n result.update(cstyle)\n return result\n\n def _compose(self, self, name, attributes):\n doc = 'pass'\n result = {}\n columns = self.columns\n for col in columns:\n style = self.style[col]\n items = self.items[col]\n cstyle = {k: v for k, v in zip(items, style)}\n if name_style is not None:\n result[name_style] = cstyle\n else:\n"} +{"i": 248, "got": "```python\nclass Config:\n def __init__(self):\n pass\n\n def get_config(self):\n # Implementation of get_config method\n self.create_ssl_certs()\n self.get_brokers()\n\n def create_ssl_certs(self):\n # Implementation of create_ssl_certs method\n pass\n\n def get_brokers(self):\n # Implementation of get_brokers method\n ssl_cafile = self.ssl.ca.file.name\n ssl_certfile = self.ssl.cert.file.name\n ssl_keyfile = self.ssl.key.file.name\n ssl_check_hostname = False\n ssl_password = None\n config = {\n 'bootstrap_servers': 'localhost',\n 'security_protocol': 'SSL',\n 'ssl_cafile': ssl_cafile,\n 'ssl_certfile': ssl_certfile,\n 'ssl_keyfile': ssl_keyfile,\n 'ssl_check_hostname': ssl_check_hostname,\n 'ssl_password': ssl_password\n }\n self.update(config)\n\n def update(self, config):\n # Implementation of update method\n pass\n\n# Example usage\nconfig = Config()\nconfig.get_config()\n```"} +{"i": 249, "got": "```python\nclass BrokerManager:\n def __init__(self, kafka_url):\n self.kafka_url = kafka_url\n\n def get_brokers(self):\n url_list = []\n parsed_url_list = []\n\n # Split the Kafka URL by comma\n urls = self.kafka_url.split(',')\n\n for url in urls:\n # Parse each URL using urlparse\n parsed_url = urlparse(url)\n url_list.append(parsed_url.hostname + ':' + str(parsed_url.port))\n\n # Format each parsed URL into a dictionary and append to parsed_url_list\n for parsed_url in parsed_url_list:\n parsed_dict = {'hostname': parsed_url.hostname, 'port': parsed_url.port}\n parsed_url_list.append(parsed_dict)\n\n return parsed_url_list\n```"} +{"i": 250, "got": "```python\ndef create_ssl_certs(self):\n \"\"\"pass\"\"\"\n self.ssl.items()\n for key, file in self.create_temp_file(file, 'suffix', 'content'):\n file.file = file\n```"} +{"i": 251, "got": "```python\nimport tempfile\n\nclass MyClass:\n def create_temp_file(self, suffix, content):\n with tempfile.NamedTemporaryFile(suffix=suffix) as temp:\n temp.write(content.encode('latin1'))\n temp.decode('unicode_escape').encode('utf-8')\n temp.seek(0)\n return temp.read()\n```"} +{"i": 252, "got": "```python\nclass prefix_topic:\n def __init__(self, topics):\n self.topic_prefix = None\n\n def prefix_topic(self, topics):\n if not topics:\n return None\n if isinstance(topics, str):\n return self.topic_prefix + topics\n elif isinstance(topics, collections.Iterable):\n result = []\n for topic in topics:\n result.append(self.topic_prefix + topic)\n return result\n else:\n raise TypeError(\"topics must be a string or an iterable\")\n```"} +{"i": 253, "got": "```python\nclass HerokuKafkaProducer:\n def send(self, topic, *args, **kwargs):\n pass\n\n @staticmethod\n def NULL|self + prefix_topic:\n return f\"{prefix_topic}{self}\"\n```"} +{"i": 254, "got": "```python\ndef get(self, variable_path, default=None, coerce_type=None, coercer=None, **kwargs):\n raise NotImplementedError()\n```"} +{"i": 255, "got": "```python\ndef coerce(val, coerce_type, coercer):\n \"\"\"pass\"\"\"\n if coerce_type is None:\n return coercer(val)\n elif coercer is None:\n return type(val)()\n else:\n if isinstance(coerce_type, bool):\n return bool(val)\n elif isinstance(coerce_type, str):\n return coerce_str_to_bool(val)\n else:\n raise TypeError(\"Unsupported coercion type\")\n```"} +{"i": 256, "got": "```python\nclass client:\n def __init__(self):\n self._client = None\n\n def get_client(self):\n return \"Client instance\"\n\n def __call__(self, *args, **kwargs):\n if self._client is None:\n self._client = self.get_client()\n return self._client\n```"} +{"i": 257, "got": "```python\ndef write_uwsgi_ini_cfg(fp, cfg):\n fp.write('[uwsgi]\\n')\n for key, val in cfg.items():\n if isinstance(val, str):\n val = val.lower()\n fp.write(f'{key} = {val}\\n')\n```\n\nThis Python function `write_uwsgi_ini_cfg` takes two parameters: `fp`, which is a file object, and `cfg`, which is a dictionary. It writes the configuration settings to the file in the format `[uwsgi]\\nkey1 = value1\\nkey2 = value2\\n`."} +{"i": 258, "got": "```python\nclass MyClass:\n def __init__(self, path_separator=None, consul_path_separator=None):\n self.path_separator = path_separator\n self.consul_path_separator = consul_path_separator\n\n @property\n def scope(self):\n return None\n\n @scope.setter\n def scope(self, value):\n pass\n\n @property\n def client(self):\n return None\n\n @client.setter\n def client(self, value):\n pass\n\n @property\n def kv(self):\n return None\n\n @kv.setter\n def kv(self, value):\n pass\n\n def get(self, variable_path, default=None, coerce_type=None, coercer=None, **kwargs):\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n _scope = '{0}/{1}'.format(_scope, variable_path)\n bundle = None\n index = 0\n data = None\n\n if data is not None:\n val = data['Value']\n if val.startswith(self.object_serialize_prefix):\n val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(val)\n else:\n val = self.coerce(val, coerce_type, coercer)\n\n return bundle\n```"} +{"i": 259, "got": "```python\ndef itunessd_to_dics(itunessd):\n \"\"\"\n pass\n \"\"\"\n header_size = get_table_size(header_table)\n header_chunk = itunessd[0:header_size]\n header_dic = chunk_to_dic(header_chunk, header_table)\n tracks_header_offset = itunessd[header_size:]\n tracks_header_dic, tracks_offsets = chunk_to_dic(tracks_header_offset, header_table)\n tracks_dics = []\n for track_offset in tracks_offsets:\n _track_dic = chunk_to_dic(itunessd[track_offset:], track_table)\n track_dic = get_custom_fields_dic(_track_dic, track_table)\n tracks_dics.append(track_dic)\n\n playlists_header_offset = itunessd[len(tracks_header_offset):]\n playlists_header_dic, playlists_offsets = chunk_to_dic(playlists_header_offset, header_table)\n playlists_dics_and_indexes = []\n for playlist_offset in playlists_offsets:\n _playlist_header_dic = chunk_to_dic(itunessd[playlist_offset:], playlist_header_table)\n indexes_of_tracks = get_custom_fields_dic(_playlist_header_dic, playlist_header_table)\n playlist_header_dic = get_custom_fields_dic(_playlist_header_dic, playlist_header_table)\n playlists_dics_and_indexes.append((playlist_header_dic, indexes_of_tracks))\n\n return tracks_dics + playlists_dics_and_indexes\n```"} +{"i": 260, "got": "```python\ndef dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"\n pass\n \"\"\"\n header_part_size = get_table_size(header_table)\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n all_tracks_chunck = header_part_size + len(tracks_dics) * (get_table_size(track_table) + 1)\n _length_before_tracks_offsets = get_table_size(header_table)\n tracks_offsets_chunck = _length_before_tracks_offsets + len(tracks_dics) * (len(tracks_header_dic) + 1)\n track_part_chunk = header_part_size + len(tracks_dics) * (get_table_size(track_table) + 1)\n playlists_dics = playlists_dics_and_indexes\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics:\n dic = copy(playlist_header_dic)\n get_table_size(playlist_header_table)\n length = len(indexes)\n number_of_all_track = len(tracks_dics) * (get_table_size(track_table) + 1)\n type_ = playlist_header_dic['type']\n if type_ == 1 or type_ == 2:\n length += len(tracks_dics) * (len(tracks_header_dic) + 1)\n elif type_ == 3:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n dic['length'] = length\n dic['number_of_all_track'] = number_of_all_track\n dic['type'] = type_\n _types = get_table_size(playlists_header_table)\n count = playlists_header_dic['count']\n if count == NORMAL:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == AUDIOBOOK:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == MASTER:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == PODCAST:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n dic['length'] = length\n dic['number_of_all_track'] = number_of_all_track\n dic['type'] = type_\n _types = get_table_size(playlists_header_table)\n count = playlists_header_dic['count']\n if count == NORMAL:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == AUDIOBOOK:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == MASTER:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == PODCAST:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n dic['length'] = length\n dic['number_of_all_track'] = number_of_all_track\n dic['type'] = type_\n _types = get_table_size(playlists_header_table)\n count = playlists_header_dic['count']\n if count == NORMAL:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == AUDIOBOOK:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == MASTER:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == PODCAST:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n dic['length'] = length\n dic['number_of_all_track'] = number_of_all_track\n dic['type'] = type_\n _types = get_table_size(playlists_header_table)\n count = playlists_header_dic['count']\n if count == NORMAL:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == AUDIOBOOK:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == MASTER:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == PODCAST:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n dic['length'] = length\n dic['number_of_all_track'] = number_of_all_track\n dic['type'] = type_\n _types = get_table_size(playlists_header_table)\n count = playlists_header_dic['count']\n if count == NORMAL:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == AUDIOBOOK:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == MASTER:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == PODCAST:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n dic['length'] = length\n dic['number_of_all_track'] = number_of_all_track\n dic['type'] = type_\n _types = get_table_size(playlists_header_table)\n count = playlists_header_dic['count']\n if count == NORMAL:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == AUDIOBOOK:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == MASTER:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == PODCAST:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n dic['length'] = length\n dic['number_of_all_track'] = number_of_all_track\n dic['type'] = type_\n _types = get_table_size(playlists_header_table)\n count = playlists_header_dic['count']\n if count == NORMAL:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == AUDIOBOOK:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == MASTER:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == PODCAST:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n dic['length'] = length\n dic['number_of_all_track'] = number_of_all_track\n dic['type'] = type_\n _types = get_table_size(playlists_header_table)\n count = playlists_header_dic['count']\n if count == NORMAL:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == AUDIOBOOK:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == MASTER:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == PODCAST:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n dic['length'] = length\n dic['number_of_all_track'] = number_of_all_track\n dic['type'] = type_\n _types = get_table_size(playlists_header_table)\n count = playlists_header_dic['count']\n if count == NORMAL:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == AUDIOBOOK:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == MASTER:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == PODCAST:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n dic['length'] = length\n dic['number_of_all_track'] = number_of_all_track\n dic['type'] = type_\n _types = get_table_size(playlists_header_table)\n count = playlists_header_dic['count']\n if count == NORMAL:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == AUDIOBOOK:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == MASTER:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == PODCAST:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n dic['length'] = length\n dic['number_of_all_track'] = number_of_all_track\n dic['type'] = type_\n _types = get_table_size(playlists_header_table)\n count = playlists_header_dic['count']\n if count == NORMAL:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == AUDIOBOOK:\n length += len(tracks_dics) * (get_table_size(track_table) + 1)\n elif count == MASTER:\n length += len(tracks_dics) * (get_table"} +{"i": 261, "got": "```python\ndef create_plan(existing_users, proposed_users, purge_undefined, protected_users, allow_non_unique_id, manage_home, manage_keys):\n \"\"\"pass\"\"\"\n plan = list()\n proposed_usernames = list()\n purge_undefined = constants.PURGE_UNDEFINED\n protected_users = constants.PROTECTED_USERS\n allow_non_unique_id = constants.ALLOW_NON_UNIQUE_ID\n\n for proposed_user in proposed_users:\n proposed_usernames.append(proposed_user.name)\n user_matching_name = get_user_by_uid(proposed_user.uid, existing_users)\n if not user_matching_name:\n plan.append({'action': 'add', 'proposed_user': proposed_user, 'state': 'missing'})\n else:\n user_matching_id = get_user_by_uid(proposed_user.uid, existing_users)\n if allow_non_unique_id or user_matching_id != proposed_user:\n plan.append({'action': 'update', 'proposed_user': proposed_user, 'user_comparison': compare_user(proposed_user, user_list), 'manage_home': manage_home, 'manage_keys': manage_keys})\n else:\n plan.append({'action': 'delete', 'username': proposed_user.name, 'state': 'existing', 'manage_home': manage_home, 'manage_keys': manage_keys})\n\n if purge_undefined and existing_users:\n for existing_user in existing_users:\n if existing_user.name not in proposed_usernames and existing_user.name not in protected_users:\n plan.append({'action': 'delete', 'username': existing_user.name, 'state': 'existing', 'manage_home': manage_home, 'manage_keys': manage_keys})\n\n return plan\n```"} +{"i": 262, "got": "```python\ndef execute_plan(plan):\n \"\"\"pass\"\"\"\n execution_result = list()\n for task in plan:\n action = task['action']\n if action == 'delete':\n command = generate_delete_user_command(task)\n execute_command(command)\n execution_result.append({'task': task, 'command_output': command_output})\n remove_sudoers_entry(task)\n elif action == 'add':\n command = generate_add_user_command(task)\n execute_command(command)\n execution_result.append({'task': task, 'command_output': command_output})\n write_authorized_keys(task)\n elif action == 'update':\n result = task['user_comparison']\n action_count = 0\n for k, _ in iteritems(result):\n if k == 'public_keys_action':\n write_authorized_keys(task)\n elif k == 'sudoers_entry_action':\n write_sudoers_entry(task)\n execution_result.append({'task': task, 'command_output': command_output})\n else:\n raise ValueError(f\"Unknown action: {action}\")\n return None\n```"} +{"i": 263, "got": "```python\nclass Output:\n def __init__(self, output, accepts, set_http_code, set_content_type):\n self.output = output\n self.accepts = accepts\n self.set_http_code = set_http_code\n self.set_content_type = set_content_type\n\n @classmethod\n def format_selector(cls, self, decide):\n # Implementation of format_selector method\n pass\n\n @classmethod\n def decide(cls, self, accepts, graph):\n # Implementation of decide method\n pass\n\n @classmethod\n def context_aware(cls, self, graph):\n # Implementation of context_aware method\n pass\n\n @classmethod\n def serialize(cls, self, output_format):\n # Implementation of serialize method\n pass\n\n def encode(self, content_type, serialized):\n # Implementation of encode method\n pass\n```"} +{"i": 264, "got": "```python\ndef add(self, src):\n \"\"\"pass\"\"\"\n checksum = get_checksum(src)\n self.filename = get_filename(checksum)\n if not os.path.exists(self.filename):\n new_name = _get_new_name()\n new_realpath = os.path.join(self._storage_dir, new_name)\n os.makedirs(os.path.dirname(new_realpath), exist_ok=True)\n shutil.copyfile(src, new_realpath)\n self.mtime = os.path.getmtime(new_realpath)\n self.size = os.path.getsize(new_realpath)\n self._log[new_name] = ('checksum', 'mtime', 'size')\n self.write_log()\n return checksum\n```"} +{"i": 265, "got": "```python\nclass schemas:\n def __init__(self, self):\n pass\n\n def query(self):\n return \"SELECT schema_name FROM information_schema.schemata ORDER BY schema_name\"\n\n def fetchall(self):\n # This is a placeholder for the actual database query execution logic.\n # In a real-world scenario, you would use a library like `psycopg2` or `sqlite3`.\n return [\"schema1\", \"schema2\", \"schema3\"]\n\n def __call__(self, self):\n sql = \"SELECT schema_name FROM information_schema.schemata ORDER BY schema_name\"\n schemas = self.query()\n for s in schemas:\n if not s.startswith(\"pg_\"):\n schemas.append(s)\n return schemas\n```"} +{"i": 266, "got": "```python\nclass tables:\n def __init__(self, self):\n self.schema = None\n self.schemas = []\n\n def __str__(self):\n return f\"tables(schema={self.schema}, schemas={self.schemas})\"\n```\n\nThis Python class `tables` is defined with an initializer that takes a single argument `self`. The `schema` attribute is initialized to `None`, and the `schemas` attribute is initialized as an empty list. The `__str__` method returns a string representation of the `tables` object, showing its `schema` and `schemas` attributes."} +{"i": 267, "got": "```python\nclass _valid_table_name:\n def __init__(self, table):\n self.table = table\n\n def __call__(self, table):\n if not table:\n raise ValueError('Invalid table name: %r' % table)\n return table.strip()\n```"} +{"i": 268, "got": "```python\nclass QueryBuilder:\n def build_query(self, sql, lookup):\n \"\"\"pass\"\"\"\n import six\n\n for key, val in six.iteritems(lookup):\n sql = sql.replace('$' + key, str(val))\n return sql\n```\n\nThis Python code snippet defines a class `QueryBuilder` with a method `build_query` that takes two parameters: `sql` and `lookup`. The method iterates over the items of the `lookup` dictionary, replaces occurrences of `$key` in the `sql` string with the corresponding value from the dictionary, and returns the modified `sql` string."} +{"i": 269, "got": "```python\nclass tables_in_schema:\n def __init__(self, self):\n pass\n\n def tables_in_schema(self, schema):\n sql = \"SELECT table_name\\n FROM information_schema.tables\\n WHERE table_schema = %s\"\n query = getattr(self, 'query')\n result = query(sql, (schema,))\n return list(result)\n```"} +{"i": 270, "got": "```python\nclass parse_table_name:\n def __init__(self, table):\n self.table = table\n\n def parse_table_name(self):\n if '.' in self.table:\n schema, table = self.table.split('.')\n return (schema, table)\n else:\n return None\n```\n\nThis Python code defines a class `parse_table_name` with an initializer that takes a `table` parameter. The `parse_table_name` method checks if the `table` contains a dot (`.`). If it does, it splits the `table` into two parts: `schema` and `table`. It then returns these two parts as a tuple. If the `table` does not contain a dot, it returns `None`."} +{"i": 271, "got": "```python\ndef read_authorized_keys(username):\n \"\"\"pass\"\"\"\n authorized_keys_path = '{0}/.ssh/authorized_keys'.format(username)\n rnd_chars = random_string(RANDOM_FILE_EXT_LENGTH)\n tmp_authorized_keys_path = '/tmp/authorized_keys_{0}_{1}'.format(username, rnd_chars)\n\n keys_file = open(tmp_authorized_keys_path, 'w')\n for key in authorized_keys:\n PublicKey(key).raw >> keys_file\n keys_file.close()\n\n execute_command(['chmod', '755', tmp_authorized_keys_path])\n execute_command(['rm', tmp_authorized_keys_path])\n\n return None\n```"} +{"i": 272, "got": "```python\ndef write_authorized_keys(user):\n \"\"\"pass\"\"\"\n authorized_keys = list()\n authorized_keys_dir = '{0}/.ssh'.format(user)\n rnd_chars = random_string(RANDOM_FILE_EXT_LENGTH)\n authorized_keys_path = '{0}/authorized_keys'.format(authorized_keys_dir)\n tmp_authorized_keys_path = '/tmp/authorized_keys_{0}_{1}'.format(user, rnd_chars)\n\n os.makedirs(authorized_keys_dir, exist_ok=True)\n keys_file = open(tmp_authorized_keys_path, 'w+')\n keys_file.writelines(authorized_keys)\n keys_file.close()\n\n execute_command(['mkdir', '-p', authorized_keys_dir], sudo_check=True)\n execute_command(['cp', tmp_authorized_keys_path, authorized_keys_path], sudo_check=True)\n execute_command(['chown', '-R', user.name, authorized_keys_dir], sudo_check=True)\n execute_command(['chmod', '700', authorized_keys_dir], sudo_check=True)\n execute_command(['chmod', '600', authorized_keys_path], sudo_check=True)\n execute_command(['rm', tmp_authorized_keys_path], sudo_check=True)\n\n return None\n```"} +{"i": 273, "got": "```python\nclass b64encoded:\n def __init__(self, raw):\n self._b64encoded = raw\n\n @property\n def _b64encoded(self):\n return self._b64encoded\n\n @_b64encoded.setter\n def _b64encoded(self, value):\n self._b64encoded = value\n\n def __str__(self):\n if self.raw:\n return base64encode(self.raw).decode('utf-8').strip()\n else:\n return None\n```"} +{"i": 274, "got": "```python\nclass Module:\n def __init__(self):\n self._raw = None\n self._b64encoded = None\n\n @property\n def raw(self):\n return self._raw\n\n @raw.setter\n def raw(self, value):\n self._raw = value\n\n @property\n def b64encoded(self):\n return self._b64encoded\n\n @b64encoded.setter\n def b64encoded(self, value):\n self._b64encoded = value\n\n def __str__(self):\n if self.raw:\n return self.raw.strip()\n elif self.b64encoded:\n return base64.decodebytes(self.b64encoded).decode('utf-8').strip()\n else:\n return \"pass\"\n```"} +{"i": 275, "got": "```python\ndef add_format(mimetype, format, requires_context):\n \"\"\"\n pass\n \"\"\"\n formats[mimetype] = format\n if requires_context:\n ctxless_mimetypes.append(mimetype)\n else:\n all_mimetypes.append(mimetype)\n```"} +{"i": 276, "got": "```python\ndef add_format(self, mimetype, format, requires_context):\n \"\"\"\n pass\n \"\"\"\n self.formats[mimetype] = format\n if not requires_context:\n self.ctxless_mimetypes.append(mimetype)\n self.all_mimetypes.append(mimetype)\n```\n\nThis Python function `add_format` takes three parameters: `mimetype`, `format`, and `requires_context`. It updates the `formats` dictionary with the given `mimetype` and `format`. If `requires_context` is `False`, it appends the `mimetype` to the `ctxless_mimetypes` list. Finally, it appends the `mimetype` to the `all_mimetypes` list."} +{"i": 277, "got": "```python\nclass MyClass:\n def __init__(self):\n self.default_mimetype = None\n\n def get_default_mimetype(self):\n if self.default_mimetype is not None:\n return self.default_mimetype\n elif 'DEFAULT_MIMETYPE' in globals():\n return globals()['DEFAULT_MIMETYPE']\n else:\n return 'application/rdf+xml'\n```"} +{"i": 278, "got": "```python\nimport asyncio\nfrom aiohttp import ClientResponseError, TimeoutError\n\nclass FailedRequest(Exception):\n def __init__(self, code, message, raised=None, url=None):\n self.code = code\n self.message = message\n self.raised = raised\n self.url = url\n\nasync def send_http(session, method, url, *, retries=3, interval=1, backoff=2, http_status_codes_to_retry=(200,), fn=None, **kwargs):\n logger = None # Assuming logger is defined elsewhere\n attempt = 0\n while True:\n try:\n response = await session.request(method, url, **kwargs)\n if response.status in http_status_codes_to_retry:\n backoff_interval = backoff * (2 ** attempt)\n await asyncio.sleep(backoff_interval)\n attempt += 1\n else:\n return fn(response) if fn else response\n except ValueError as e:\n logger.error(f\"Caught '{e}' url:{url} method:{method}, remaining tries {retries - attempt}, sleeping %.2fsecs\", e, method, url, backoff_interval)\n await asyncio.sleep(interval)\n attempt += 1\n except ClientResponseError as e:\n logger.error(f\"Received invalid response code:{e.status} error:{e.reason} response:{e.response.url}\")\n raise FailedRequest(e.status, e.reason, e.response, e.request_info) from e\n except TimeoutError as e:\n logger.error(f\"Non-retryable response code: {e.code} error:'asyncio.TimeoutError' url:{url}\")\n raise FailedRequest(e.code, \"asyncio.TimeoutError\", None, url) from e\n\n# Example usage\nasync def main():\n async with aiohttp.ClientSession() as session:\n response = await send_http(session, 'get', 'https://example.com')\n print(response.text)\n\nasyncio.run(main())\n```"} +{"i": 279, "got": "```python\nimport codecs\nimport os\n\nclass SitemapGenerator:\n def __init__(self, context):\n self.context = context\n self.url_site = None\n self.path_output = None\n\n def generate_output(self, writer):\n with codecs.open(os.path.join(self.url_site, 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as xsl_file:\n xsl = xsl_file.read()\n\n with codecs.open(os.path.join(self.url_site, 'sitemap.xml'), 'w', encoding='utf-8') as xml_file:\n xml_file.write(self.xml_wrap(self.context['articles'], self.context['pages']))\n\n def __create_url_node_for_content(self, node_type, url):\n return f'<{node_type} url=\"{url}\" />'\n\n def __process_url_wrapper_elements(self, elements):\n for element in elements:\n if element['modified'] is not None and element['date'] is not None:\n element['modified'] = self.__get_direct_template_url(element)\n elif element['modified'] is not None:\n element['modified'] = None\n elif element['date'] is not None:\n element['date'] = None\n\n def __get_direct_template_url(self, element):\n # Implementation of getting direct template URL\n pass\n\n def xml_wrap(self, articles, pages):\n # Implementation of XML wrapping logic\n pass\n\n def __get_date_key(self, item):\n # Implementation of date key retrieval logic\n pass\n\n def __get_title_key(self, item):\n # Implementation of title key retrieval logic\n pass\n```"} +{"i": 280, "got": "```python\nclass PelicanSettings:\n def __init__(self, pelican_settings):\n self.pelican_settings = pelican_settings\n\n def get(self, key):\n return self.pelican_settings.get(key)\n\n def format(self, template, name):\n return template.format(name=name)\n\n def upper(self, value):\n return value.upper()\n\ndef __get_direct_template_url(self, name):\n url_site = self.url_site\n url = None\n\n if self.settings.get('{}_SAVE_AS'.format(name)):\n url = self.settings.get('{}_SAVE_AS'.format(name)).format(name=name)\n else:\n url = self.settings.get('{}_URL'.format(name)).format(name=name) + '.html'\n\n return urljoin(url_site, url)\n\ndef urljoin(base_url, path):\n # Implementation of urljoin function\n pass\n```"} +{"i": 281, "got": "```python\ndef __process_url_wrapper_elements(self, elements):\n \"\"\"pass\"\"\"\n urls = []\n for url_wrapper, articles in zip(elements, self.__create_url_node_for_content(url_wrapper, self.url_site, url_wrapper.url)):\n dates = sorted(articles, key=self.__get_date_key, reverse=True)\n modification_time = dates[0]['modification_time']\n urls.append(urls + [modification_time])\n return urls\n```"} +{"i": 282, "got": "```python\nclass __create_url_node_for_content:\n def __init__(self, content, content_type, url, modification_time):\n self.url = url\n self.content_type = content_type\n self.modification_time = modification_time\n\n def format(self, template):\n loc = self.url\n lastmod = None\n if self.url is not None:\n loc = self.urljoin(self.url_site, self.context.get('url', 'ARTICLE_URL'))\n if self.modification_time is not None:\n lastmod = self.strftime('%Y-%m-%d')\n output = template.format(loc)\n if lastmod is not None:\n output += '\\n{}'.format(lastmod)\n if self.settings.get('changefrequencies') is not None and self.content_type in self.settings['changefrequencies']:\n output += '\\n{:.2f}'.format(self.settings['changefrequencies'][self.content_type])\n if self.settings.get('priorities') is not None and self.content_type in self.settings['priorities']:\n output += '\\n{:.2f}'.format(self.settings['priorities'][self.content_type])\n return template.format(output)\n```"} +{"i": 283, "got": "```python\ndef add_attachment(message, attachment, rfc2231):\n \"\"\"pass\"\"\"\n data = attachment.read()\n part = MIMEBase('application', 'octet-stream')\n part.set_payload(data)\n encoders.encode_base64(part)\n if rfc2231:\n filename = attachment.name\n else:\n filename = Header(attachment.name, 'utf-8').encode()\n message.attach(part)\n```"} +{"i": 284, "got": "```python\nclass _login(object):\n def __init__(self, connection_details):\n server, port, mode, debug = connection_details\n self.smtp_class = smtplib.SMTP_SSL if mode == 'SSL' else smtplib.SMTP\n self.smtp = self.smtp_class(server, port)\n self.smtp.set_debuglevel(debug)\n if mode == 'TLS':\n self.smtp.starttls()\n self.smtp.authenticate(smtp)\n```"} +{"i": 285, "got": "```python\ndef send(self, email, attachments):\n \"\"\"pass\"\"\"\n msg = self.as_mime(email, attachments)\n if 'From' in msg:\n self.sender_address(msg)\n self._conn.sendmail(self.username, self.recipients, msg.as_string())\n```\n\nThis Python function `send` takes an email and a list of attachments as input. It first creates a MIME message using the `as_mime` method. If the 'From' header is present in the message, it sets the sender address using the `sender_address` method. Then, it sends the email using the SMTP connection stored in `_conn`. The function handles exceptions that may occur during the process and re-raises them if necessary."} +{"i": 286, "got": "```python\ndef attributes(qpi_or_h5file, checks):\n if isinstance(qpi_or_h5file, QPImage):\n qpi = qpi_or_h5file\n else:\n qpi = QPImage(h5file=qpi_or_h5file, h5mode='r')\n \n if 'attributes' in checks:\n check_attributes(qpi)\n \n if 'background' in checks:\n check_background(qpi)\n\ndef check(qpi_or_h5file, checks):\n if isinstance(qpi_or_h5file, QPImage):\n qpi = qpi_or_h5file\n else:\n qpi = QPImage(h5file=qpi_or_h5file, h5mode='r')\n \n for ch in checks:\n if ch == 'attributes':\n check_attributes(qpi)\n elif ch == 'background':\n check_background(qpi)\n\ndef check_attributes(qpi):\n pass\n\ndef check_background(qpi):\n pass\n```"} +{"i": 287, "got": "```python\ndef check_attributes(qpi):\n \"\"\"pass\"\"\"\n missing_attrs = []\n for key in DATA_KEYS:\n if key not in qpi.meta:\n missing_attrs.append(key)\n if missing_attrs:\n msg = 'Attributes are missing: {} '.format(', '.join(missing_attrs)) + \\\n 'in {}'.format(qpi)\n raise IntegrityCheckError(msg)\n```"} +{"i": 288, "got": "```python\ndef check_background(qpi):\n \"\"\"pass\"\"\"\n imdat = qpi._amp\n _pha = qpi._pha\n fit, attrs = get_bg(imdat)\n binkey = 'fit'\n kwargs = {'key': 'ret_attrs', 'ret_attrs': True}\n h5 = h5py.File('check.h5', 'core', driver=False)\n testimdat = None\n bg = None\n\n with h5:\n if 'core' in h5 and binkey in h5['core']:\n bg = h5['core'][binkey][()]\n else:\n bg = estimate_bg_from_mask(imdat, from_mask=True)\n\n testimdat = np.allclose(testimdat, get_bg(imdat)['fit'], key='key')\n if not testimdat:\n msg = 'Wrong estimated (fitted) background!'\n raise IntegrityCheckError(msg)\n else:\n h5['core'][binkey] = bg\n set_bg(testimdat, bg, key='data')\n estimate_bg(imdat, from_mask=False)\n\n return None\n```"} +{"i": 289, "got": "```python\ndef write_image_dataset(group, key, data, h5dtype):\n \"\"\"\n pass\n \"\"\"\n if h5dtype is not None:\n h5dtype = data.dtype\n else:\n h5dtype = data.attrs['dtype']\n \n if key in group:\n del group[key]\n \n group.create_dataset(key, data=data, dtype=h5dtype)\n dset = group[key]\n \n dset.attrs.create('CLASS', b'IMAGE')\n dset.attrs.create('IMAGE_VERSION', b'1.2')\n dset.attrs.create('IMAGE_SUBCLASS', b'IMAGE_GRAYSCALE')\n```"} +{"i": 290, "got": "```python\nclass MyClass:\n def __init__(self, h5):\n self.h5 = h5\n\n def info(self):\n info = []\n for key in self.h5['bg_data']:\n if 'background' in key:\n name = self.h5['bg_data'][key]['name']\n attrs = self.h5['bg_data'][key]['attrs']\n for akey, atr in attrs.items():\n var = '{} background {}'.format(name, akey)\n info.append(var)\n if 'fit' in self.h5['bg_data']:\n name = self.h5['bg_data']['fit']['name']\n var_mask = '{} background from mask'.format(name)\n estimate_bg_from_mask = '{} estimate_bg_from_mask'.format(name)\n if estimate_bg_from_mask in self.h5['bg_data']:\n info.append(var_mask)\n info.append(estimate_bg_from_mask)\n else:\n warnings.warn('Old file format detected!', DeprecationWarning)\n var_mask = '{} background from mask'.format(self.h5['bg_data']['fit']['name'])\n estimate_bg_from_binary = '{} estimate_bg_from_binary'.format(self.h5['bg_data']['fit']['name'])\n if estimate_bg_from_binary in self.h5['bg_data']:\n info.append(var_mask)\n info.append(estimate_bg_from_binary)\n info.append('estimate_bg_from_binary')\n return info\n```"} +{"i": 291, "got": "```python\ndef del_bg(self, key):\n \"\"\"pass\"\"\"\n if key not in VALID_BG_KEYS:\n raise ValueError('Invalid bg key: {}'.format(key))\n self.h5['bg_data'][key] = None\n\ndef clear_bg(self, key):\n \"\"\"No bg data to clear for '{}' in {}.\"\"\"\n warnings.warn(\"No bg data to clear for '{}' in {}\".format(key, self))\n```"} +{"i": 292, "got": "```python\nimport argparse\nfrom pathlib import Path\nimport os\nimport subprocess\n\ndef main():\n parser = argparse.ArgumentParser(description='Overwrites the unformatted source files with the well-formatted code in place. If not set, an exception is raised if any of the files do not conform to the style guide.')\n parser.add_argument('--overwrite', action='store_true', help='Overwrites the unformatted source files with the well-formatted code in place. If not set, an exception is raised if any of the files do not conform to the style guide.')\n args = parser.parse_args()\n\n repo_root = Path(__file__).parent\n overwrite = args.overwrite\n\n print(\"YAPF'ing...\")\n subprocess.check_call(['yapf', '--in-place', '--style=style.yapf', '--recursive', 'tests', 'icontract', 'setup.py', 'precommit.py'])\n\n if overwrite:\n print(\"Mypy'ing...\")\n subprocess.check_call(['mypy', 'icontract', 'tests'])\n else:\n print(\"Mypy failed to run due to unformatted files.\")\n\n print(\"Pylint'ing...\")\n subprocess.check_call(['pylint', '--rcfile=pylint.rc', 'tests', 'icontract'])\n\n print(\"Pydocstyle'ing...\")\n subprocess.check_call(['pydocstyle', 'icontract'])\n subprocess.check_call(['pydocstyle', 'README.rst'])\n\n print(\"Testing...\")\n os.environ['ICONTRACT_SLOW'] = 'true'\n subprocess.check_call(['coverage', 'run', '--source', 'icontract', '-m', 'unittest', 'discover', 'tests'])\n subprocess.check_call(['coverage', 'report', '--env', os.environ])\n\n print(\"Doctesting...\")\n subprocess.check_call(['python3', '-m', 'doctest', 'README.rst'])\n\n print(\"Checking the restructured text of the readme...\")\n subprocess.check_call(['python3', 'setup.py', 'check', '--restructuredtext', '--strict'])\n\nif __name__ == \"__main__\":\n main()\n```"} +{"i": 293, "got": "```python\ndef _collapse_invariants(bases, namespace):\n invariants = []\n for base in bases:\n if hasattr(base, '__invariants__'):\n invariants.extend(getattr(base, '__invariants__'))\n if '__invariants__' in namespace:\n invariants.extend(namespace['__invariants__'])\n return invariants\n```"} +{"i": 294, "got": "```python\ndef _collapse_preconditions(base_preconditions, bases_have_func, preconditions, func):\n if not bases_have_func:\n raise TypeError(\"The function {} can not weaken the preconditions because the bases specify no preconditions at all. Hence this function must accept all possible input since the preconditions are OR'ed and no precondition implies a dummy precondition which is always fulfilled.\".format(func.__qualname__))\n return base_preconditions + preconditions\n```"} +{"i": 295, "got": "```python\ndef _collapse_snapshots(base_snapshots, snapshots):\n seen_names = set()\n collapsed = base_snapshots + snapshots\n\n for snap in collapsed:\n if snap.name in seen_names:\n raise ValueError(\n 'There are conflicting snapshots with the name: {!r}.\\n\\nPlease mind that the snapshots are inherited from the base classes. Does one of the base classes defines a snapshot with the same name?'.format(snap.name)\n )\n seen_names.add(snap.name)\n\n return collapsed\n```"} +{"i": 296, "got": "```python\ndef _collapse_postconditions(base_postconditions, postconditions):\n return base_postconditions + postconditions\n```"} +{"i": 297, "got": "```python\ndef _decorate_namespace_function(bases, namespace, key):\n \"\"\"pass\"\"\"\n value = namespace[key]\n if inspect.isfunction(value):\n func = value\n elif isinstance(value, staticmethod) or isinstance(value, classmethod):\n func = value.__func__\n else:\n raise NotImplementedError('Unexpected value for a function: {}'.format(value))\n \n contract_checker = icontract._checkers.find_checker(func)\n if contract_checker is not None:\n preconditions = contract_checker.__preconditions__\n snapshots = contract_checker.__postcondition_snapshots__\n postconditions = contract_checker.__postconditions__\n \n if key in bases:\n base_preconditions = contract_checker.__base_preconditions__\n base_snapshots = contract_checker.__base_postcondition_snapshots__\n base_postconditions = contract_checker.__base_postconditions__\n \n preconditions.extend(base_preconditions)\n snapshots.extend(base_snapshots)\n postconditions.extend(base_postconditions)\n \n return None\n```"} +{"i": 298, "got": "```python\ndef tokenize_sents(string):\n \"\"\"pass\"\"\"\n import six\n import re\n\n spans = []\n string = six.text_type(string)\n matches = re.finditer('[^\\\\s]+', string)\n for match in matches:\n spans.append(match)\n\n spans_count = len(spans)\n rez = []\n off = 0\n for i, tok in enumerate(spans):\n next_tok = None\n if i + 1 < spans_count:\n next_tok = spans[i + 1]\n tok1 = re.search('[.!?\u2026\u00bb]', tok)\n if tok1:\n tok1 = tok1.group(0)\n else:\n tok1 = ''\n if tok.isupper():\n off += 1\n elif tok1 == '.' or tok1 == '!' or tok1 == '?' or tok1 == '\u2026' or tok1 == '\u00bb':\n off += 1\n elif tok1 in ABBRS and next_tok:\n rez.append(string[off:tok.start()])\n off = tok.end()\n if tok:\n rez.append(string[off:])\n return rez\n```"} +{"i": 299, "got": "```python\ndef tokenize_text(string):\n \"\"\"pass\"\"\"\n import six\n\n text = string\n rez = []\n part = ''\n for part in text.split('\\n'):\n par = []\n for sent in tokenize_sents(part):\n par.append(tokenize_words(sent))\n rez.append(par)\n return rez\n```"} +{"i": 300, "got": "```python\ndef override_djconfig(**new_cache_values):\n \"\"\"pass\"\"\"\n new_cache_values = closure(new_cache_values)\n decorator = closure(decorator)\n func_wrapper = closure(func_wrapper)\n\n def decorator(func):\n func_wrapper.func = func\n return func_wrapper\n\n @decorator\n def func_wrapper(*args, **kw):\n old_cache_values = closure(old_cache_values)\n key = closure(key)\n conf.config[key] = closure(conf.config[key])\n conf._set_many(new_cache_values)\n conf.config[key] = closure(conf.config[key])\n return closure(func(*args, **kw))\n\n def _set_many(self, new_cache_values):\n pass\n\n override_djconfig.conf = closure(override_djconfig.conf)\n override_djconfig.key = closure(override_djconfig.key)\n\n return override_djconfig\n```"} +{"i": 301, "got": "```python\ndef serialize(value, field):\n \"\"\"pass\"\"\"\n if isinstance(field, forms.Field):\n return json.dumps(value)\n elif isinstance(field, models.ModelMultipleChoiceField):\n return [v.pk for v in value]\n elif isinstance(field, models.Model):\n return value.pk\n else:\n raise AssertionError(\"Unsupported field type\")\n```"} +{"i": 302, "got": "```python\nimport io\nimport os\n\nBASE_DIR = 'path/to/base/directory'\n\ndef get_version(package):\n with open(os.path.join(BASE_DIR, package, '__init__.py'), 'r', encoding='utf-8') as fh:\n lines = fh.readlines()\n version = next((line.strip() for line in lines if line.startswith('__version__')), None)\n return version\n```"} +{"i": 303, "got": "```python\ndef _check_backend():\n \"\"\"pass\"\"\"\n middleware = set(settings.MIDDLEWARE)\n if 'djconfig.middleware.DjConfigLocMemMiddleware' in middleware:\n return None\n elif 'djconfig.middleware.DjConfigMiddleware' in settings.MIDDLEWARE_CLASSES:\n return None\n else:\n raise ValueError('djconfig.middleware.DjConfigMiddleware is required but it was not found in MIDDLEWARE_CLASSES nor in MIDDLEWARE')\n```"} +{"i": 304, "got": "```python\nclass _register(object):\n def __init__(self, form_class, check_middleware):\n self._registry = {}\n self.add(form_class)\n if check_middleware:\n _check_backend()\n\ndef issubclass(cls, basecls):\n return cls.__bases__ == (basecls,) or any(issubclass(c, basecls) for c in cls.__bases__)\n\ndef ValueError(message):\n raise ValueError(message)\n\ndef _check_backend():\n pass\n```"} +{"i": 305, "got": "```python\nclass _reload:\n def __init__(self, self):\n pass\n\n def __call__(self, self):\n apps = None\n ConfigModel = None\n cache = {}\n data = None\n form_class = None\n empty_form = None\n field = None\n name = None\n value = None\n _registry = None\n forms = None\n\n for form_class in apps.get_model('djconfig.Config').objects.all().values_list('key', 'value'):\n cache[name] = field.initial if field.initial is not None else field.default\n\n for name, field in apps.get_model('djconfig.Config').fields.items():\n if isinstance(field, forms.FileField):\n data[name] = _deserialize(data[name], name)\n\n for name, value in data.items():\n if isinstance(value, forms.FileField):\n value = _unlazify(value)\n\n cache['_updated_at'] = apps.get_model('djconfig.Config').get('_updated_at')\n cache['_cache'] = self\n\n return None\n```"} +{"i": 306, "got": "```python\ndef Mixed(*types):\n \"\"\"pass\"\"\"\n types = tuple(types)\n MixedType = type('MixedType', (object,), {'__instancecheck__': lambda cls, instance: isinstance(instance, types)})\n Mixed = type('Mixed', (object,), {'__init__': lambda self: None})\n return Mixed\n\nclass MixedType:\n \"\"\"Mixed..MixedType\"\"\"\n __metaclass__ = Mixed\n```\n\nThis Python code snippet reconstitutes the bytecode disassembly into a complete, runnable Python program. The `Mixed` function is defined to take any number of types as arguments and returns a new class that checks if an instance is an instance of those types using the `isinstance` function. The `MixedType` class is also defined with a metaclass set to `Mixed`, which ensures that instances of `MixedType` are instances of the specified types."} +{"i": 307, "got": "```python\ndef one_of(*args):\n \"\"\"pass\"\"\"\n items = args[0]\n if len(items) == 1 and isinstance(items[0], list):\n items = items[0]\n\n def validate(value):\n if value in items:\n return True\n else:\n e = '{} is not in the list {}'.format(value, items)\n raise ValueError(e)\n\n return validate\n```"} +{"i": 308, "got": "```python\ndef gte(min_value):\n \"\"\"pass\"\"\"\n validate = closure(min_value)\n return validate(value)\n\ndef closure(min_value):\n def validate(value):\n if value < min_value:\n raise ValueError('{} is not greater than or equal to {}'.format(value, min_value))\n return None\n return validate\n```"} +{"i": 309, "got": "```python\ndef lte(max_value):\n def validate(value):\n if value > max_value:\n raise ValueError('{} is not less than or equal to {}'.format(value, max_value))\n return validate\n\n# Example usage:\ntry:\n result = lte(10)(5)\nexcept ValueError as e:\n print(e) # Output: 5 is not less than or equal to 10\n```"} +{"i": 310, "got": "```python\ndef gt(gt_value):\n def validate(value):\n if value <= gt_value:\n raise ValueError('{} is not greater than {}'.format(value, gt_value))\n return validate\n```"} +{"i": 311, "got": "```python\ndef lt(lt_value):\n def validate(value):\n if value >= lt_value:\n raise ValueError('{} is not less than {}'.format(value, lt_value))\n return validate\n```"} +{"i": 312, "got": "```python\ndef load_config(path, defaults):\n \"\"\"pass\"\"\"\n config = None\n if defaults is not None:\n config = ConfigParser(allow_no_value=True)\n config.read(defaults)\n with open(path) as fh:\n config.read_file(fh)\n return config\n```"} +{"i": 313, "got": "```python\ndef as_dict(config):\n \"\"\"pass\"\"\"\n settings = defaultdict(dict)\n for section in config.sections():\n for key, val in config.items(section):\n settings[section][key] = val\n return settings\n\nas_dict..() = lambda: {}\n```"} +{"i": 314, "got": "```python\nclass MyClass:\n def __init__(self, timeouts):\n self.bind = True\n self.socket = None\n self.address = None\n\n def bind(self):\n pass\n\n def connect(self):\n pass\n\n def _set_timeouts(self, timeouts):\n pass\n```"} +{"i": 315, "got": "```python\nclass _set_timeouts:\n def __init__(self, timeouts):\n self.send_timeout = timeouts[0]\n self.recv_timeout = timeouts[1]\n\n def __call__(self, self, socket, nanomsg):\n send_timeout, recv_timeout = timeouts\n if send_timeout is None or recv_timeout is None:\n raise TypeError(\"`timeouts` must be a pair of numbers (2, 3) which represent the timeout values for send and receive respectively\")\n socket.set_int_option(nanomsg.SOL_SOCKET, nanomsg.SNDTIMEO, send_timeout)\n socket.set_int_option(nanomsg.SOL_SOCKET, nanomsg.RCVTIMEO, recv_timeout)\n```"} +{"i": 316, "got": "```python\nclass MyClass:\n def __init__(self, encode, sign):\n self.encode = encode\n self.sign = sign\n\n def send(self, payload):\n self.payload = payload\n self.socket.send(payload)\n```\n\nThis Python code snippet defines a class `MyClass` with an initializer that takes two parameters: `encode` and `sign`. The `send` method takes a `payload` as input, updates the `payload` attribute of the instance, and then sends it using the `socket` attribute."} +{"i": 317, "got": "```python\nclass Module:\n def __init__(self):\n pass\n\n def receive(self, decode):\n self.socket.recv()\n self.verify(self.payload)\n if decode:\n self.decode(self.payload)\n```\n\nThis Python code snippet is the decompiled version of the bytecode provided. It defines a class `Module` with an instance method `receive`. The method takes two parameters: `self` and `decode`. Inside the method, it calls `socket.recv()` to receive data from the socket, then verifies the received payload using `verify(self.payload)`, and finally decodes the payload if `decode` is True."} +{"i": 318, "got": "```python\ndef sign(self, payload):\n \"\"\"pass\"\"\"\n if self.authenticator is not None and self.authenticator.signed(payload):\n return payload\n else:\n return payload\n```"} +{"i": 319, "got": "```python\nclass AuthenticatorInvalidSignature(Exception):\n pass\n\nclass AuthenticateError(Exception):\n pass\n\ndef verify(self, payload):\n if self.authenticator is None:\n return payload\n authenticator_null = self.authenticator.null\n authenticator_unsigned = self.authenticator.unsigned\n return authenticator_null(payload) + authenticator_unsigned(payload)\n```"} +{"i": 320, "got": "```python\ndef get_summary(list_all, **kwargs):\n \"\"\"pass\"\"\"\n all_summary = []\n for module in list_all:\n summary = {\n 'module_name': module,\n 'show_all': kwargs.get('show_all', True),\n 'project_name': kwargs.get('proj_name', 'TestProject'),\n 'home_page': kwargs.get('home_page', __about__.HOME_PAGE),\n 'start_time': None,\n 'end_time': None,\n 'duration_seconds': 0,\n 'total_case_num': 0,\n 'pass_cases_num': 0,\n 'fail_cases_num': 0,\n 'details': []\n }\n for case in module.TestCases:\n case_detail = {\n './caselogs/': f\"{case.case_name}_{case.exec_date}.log\",\n 'linkurl': None,\n 'status': case.lower(),\n 'pass': case == 'pass',\n 'tr_pass': case == 'pass',\n 'tr_fail': case == 'fail'\n }\n summary['details'].append(case_detail)\n all_summary.append(summary)\n return all_summary\n```"} +{"i": 321, "got": "```python\ndef add_report_data(list_all, module_name, **kwargs):\n exec_date_time = time.localtime()\n execdate = time.strftime('%Y-%m-%d', exec_date_time)\n exectime = time.strftime('%H:%M:%S', exec_date_time)\n\n case_report = {\n 'resp_tester': 'administrator',\n 'tester': 'administrator',\n 'case_name': kwargs.get('case_name'),\n 'raw_case_name': kwargs.get('raw_case_name'),\n 'status': 'Pass',\n 'exec_date': execdate,\n 'exec_time': exectime,\n 'start_at': kwargs.get('start_at'),\n 'end_at': kwargs.get('end_at')\n }\n\n for module in list_all:\n if module['Name'] != module_name:\n continue\n\n test_cases = module['TestCases']\n for case in test_cases:\n if case['raw_case_name'] == raw_case_name:\n update(case, case_report)\n break\n else:\n append(test_cases, case_report)\n\n list_all.append({'Name': module_name, 'TestCases': [case_report]})\n```"} +{"i": 322, "got": "```python\ndef get_webpack(request, name):\n \"\"\"\n pass\n \"\"\"\n if hasattr(request, '_webpack_map'):\n return request._webpack_map[name]\n else:\n Webpack = None\n wp = getattr(request, '_webpack_map', {}).get(name)\n if wp is not None:\n return wp\n else:\n return Webpack(request, name)\n```"} +{"i": 323, "got": "```python\ndef includeme(config):\n \"\"\"pass\"\"\"\n settings = config.registry.settings\n root_package_name = config.root_package.__name__\n webpack_state = WebpackState(settings, root_package_name)\n webpack_configs = aslist(settings.get('webpack.configs', []))\n for extra_config in webpack_configs:\n state = WebpackState(settings, root_package_name)\n webpack_state.webpack[extra_config.name] = None\n static_views = six.itervalues(config.registry.webpack.static_view)\n for state in static_views:\n if not state.static_view_name:\n continue\n state.static_view_path = state.static_view_path or ''\n state.cache_max_age = state.cache_max_age or 0\n config.add_static_view(state.static_view_name, state.static_view_path, cache_max_age=state.cache_max_age)\n get_webpack = get_webpack('webpack')\n config.add_request_method(get_webpack)\n```"} +{"i": 324, "got": "```python\nclass Module:\n def __init__(self):\n self._settings = {}\n\n def _get_setting(self, setting, default, name, inherit):\n if name is not None:\n return getattr(self, name)\n else:\n settings = getattr(self, '_settings')\n if setting in settings:\n return settings[setting]\n elif f\"webpack.{setting}\" in settings:\n return settings[f\"webpack.{setting}\"]\n elif f\"webpack.{name}.{setting}\" in settings:\n return settings[f\"webpack.{name}.{setting}\"]\n else:\n return default\n```"} +{"i": 325, "got": "```python\nclass Module:\n def __init__(self):\n self.load_stats = None\n\ndef load_stats(self, cache, wait):\n pass\n```"} +{"i": 326, "got": "```python\nimport json\nimport time\n\nclass StatsTracker:\n def __init__(self, stats_file):\n self.stats_file = stats_file\n\n def load_stats(self):\n with open(self.stats_file, 'r') as f:\n return json.load(f)\n\n def save_stats(self, data):\n with open(self.stats_file, 'w') as f:\n json.dump(data, f)\n```\n\nThis Python code snippet defines a class `StatsTracker` that loads and saves statistics from a file using the `json` module. The `load_stats` method reads the JSON data from the specified file, while the `save_stats` method writes the provided data to the same file in JSON format."} +{"i": 327, "got": "```python\ndef _chunk_filter(self, extensions):\n \"\"\"pass\"\"\"\n self = cell(self)\n extensions = cell(extensions)\n if isinstance(extensions, six.string_types):\n extensions = extensions.split()\n def _filter(chunk):\n name = cell(None)\n if extensions is not None:\n if any(fnmatch.fnmatchcase(name, pattern) for pattern in extensions):\n return False\n state = self.state\n ignore_re = self.ignore_re\n for pattern in state.ignore:\n if fnmatch.fnmatchcase(name, pattern):\n return False\n for pattern in state.ignore:\n if fnmatch.fnmatchcase(name, pattern):\n return False\n return True\n _filter = closure(_filter)\n yield from _filter(chunk)\n\ndef _chunk_filter._filter._filter..(.0):\n \"\"\"pass\"\"\"\n name = cell(None)\n for e in state.ignore:\n if fnmatch.fnmatchcase(name, e):\n return False\n return True\n```"} +{"i": 328, "got": "```python\ndef _unique_names():\n \"\"\"pass\"\"\"\n yield from irange(len('abcdefghijklmnopqrstuvwxyz0123456789'))\n for i in range(10):\n yield choice('abcdefghijklmnopqrstuvwxyz0123456789')\n```\n\nThis Python function `_unique_names` generates a sequence of unique characters by first generating all possible characters and then choosing 10 random ones from this set."} +{"i": 329, "got": "```python\ndef escape_queue(s):\n \"\"\"pass\"\"\"\n if isinstance(s, PosixPath):\n s = unicode_(s)\n elif isinstance(s, bytes):\n s = s.decode('utf-8')\n if s.startswith('~'):\n return shell_escape(s[2:], 2)\n else:\n return shell_escape(s)\n```"} +{"i": 330, "got": "```python\ndef parse_ssh_destination(destination):\n \"\"\"pass\"\"\"\n _re_ssh = re.compile(r'^(?P[^@]+)@(?P[^:]+)(:(?P\\d+))?$')\n match = _re_ssh.match(destination)\n if not match:\n raise InvalidDestination('Invalid destination: %s' % destination)\n\n user, password, host, port = match.groups()\n info = {\n 'username': user,\n 'password': password,\n 'hostname': host,\n 'port': int(port),\n }\n return info\n```"} +{"i": 331, "got": "```python\nclass SSHClient:\n def __init__(self, paramiko):\n self.paramiko = paramiko\n\n def load_system_host_keys(self):\n pass\n\n def set_missing_host_key_policy(self):\n self.paramiko.set_missing_host_key_policy(paramiko.RejectPolicy())\n```\n\nThis Python code snippet reconstitutes the original Python source code from the provided bytecode disassembly. The `SSHClient` class is defined with methods to handle SSH client operations, including loading system host keys and setting a missing host key policy."} +{"i": 332, "got": "```python\nclass ConnectionManager:\n def __init__(self, ssh_client, destination):\n self._ssh_client = ssh_client\n self.destination = destination\n\n def connect(self):\n logger.debug(f\"Connecting with {self.destination}\")\n ssh = self._ssh_client.connect()\n logger.debug(f\"Connected to {self.destination} hostname={ssh.hostname}\")\n self._ssh = ssh\n\n @property\n def ssh(self):\n return self._ssh\n```"} +{"i": 333, "got": "```python\nclass Client:\n def __init__(self, ssh):\n self._ssh = ssh\n\n def get_client(self):\n if self._ssh is not None:\n return self._connect()\n else:\n return self.open_session()\n\n def _connect(self):\n # Implementation of connect method\n pass\n\n def open_session(self):\n # Implementation of open_session method\n pass\n\n def close(self):\n # Implementation of close method\n pass\n\n def warning(self, message):\n # Implementation of warning method\n pass\n```"} +{"i": 334, "got": "```python\ndef activate(lancet, method, project):\n \"\"\"pass\"\"\"\n taskstatus = lancet.taskstatus\n if method == 'key':\n func = get_project_keys\n elif method == 'dir':\n func = get_project_keys\n else:\n raise ValueError(\"Invalid method\")\n \n ts = None\n try:\n ts = taskstatus('Looking up project')\n with before_with():\n for key, project_path in enumerate(project):\n if key.lower() == method.lower():\n venv = load_config(os.path.join(project_path, os.path.expanduser(\"~/.lancet/virtualenv\")))\n if venv is not None:\n lancet.defer_to_shell('cd', project_path)\n lancet.defer_to_shell('source', activate_script)\n return\n except Exception as e:\n taskstatus.abort(f\"Project '{project}' not found (using {method}-based lookup)\", method, project)\n finally:\n if ts is not None:\n ts.abort()\n```"} +{"i": 335, "got": "```python\ndef workon(ctx, issue_id=None, new=False, base_branch=None):\n \"\"\"pass\"\"\"\n if issue_id is not None and new:\n raise UsageError('Provide either an issue ID or the --new flag.')\n elif issue_id is None and new is False:\n raise UsageError('Provide either an issue ID or the --new flag, but not both.')\n else:\n summary = click.prompt('Issue summary')\n issue = create_issue(lancet, summary, add_to_active_sprint=True)\n branch = get_branch(lancet, issue, base_branch)\n transition = get_transition(ctx, lancet, issue, active_status)\n assign_issue(lancet, issue, username, active_status)\n set_issue_status(lancet, issue, active_status, transition)\n taskstatus('Checking out working branch')\n checkout(lancet, branch.name)\n taskstatus('Starting harvest timer')\n start(timer, issue)\n```"} +{"i": 336, "got": "```python\ndef time(lancet, issue):\n \"\"\"pass\"\"\"\n ts = None\n lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n while True:\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet.timer.start(issue)\n lancet.ok('Started harvest timer')\n yield None\n ts = lancet"} +{"i": 337, "got": "```python\ndef pause(ctx):\n \"\"\"pass\"\"\"\n lancet = ctx.obj\n paused_status = lancet.config.get('tracker', 'paused_status')\n issue = lancet.get_issue()\n transition = lancet.get_transition(ctx, lancet.issue, paused_status)\n lancet.set_issue_status(lancet.issue, paused_status, transition)\n taskstatus('Pausing harvest timer')\n ts = lancet.timer.pause()\n lancet.ok('Harvest timer paused')\n return None\n```"} +{"i": 338, "got": "```python\ndef raisefrom(exc_type, message, exc):\n import sys\n from six import raise_from, reraise\n\n if sys.version_info >= (3, 2):\n raise_from(exc_type, message)\n else:\n six.raise_from(exc_type, message)\n\n six.reraise(exc_type, message, sys.exc_info()[2])\n```"} +{"i": 339, "got": "```python\ndef init_runner(self, parser, tracers, projinfo):\n \"\"\"pass\"\"\"\n self.parser = parser\n self.tracers = tracers\n self.proj_info = projinfo\n```"} +{"i": 340, "got": "```python\nimport multiprocessing\n\ndef _run_grid_multiprocess(self, func, iterables):\n \"\"\"pass\"\"\"\n multiprocessing.freeze_support()\n pool = multiprocessing.Pool()\n pool_tracers = pool.map(func, iterables)\n pool.close()\n pool.join()\n self.tracers = dict(zip(self._default_devices, pool_tracers))\n```"} +{"i": 341, "got": "```python\nimport threading\n\ndef _run_grid_multithread(self, func, iterables):\n \"\"\"pass\"\"\"\n func = threading.Thread(target=func, args=(x,))\n threads = []\n for thread in iterables:\n func.setDaemon(True)\n func.start()\n threads.append(thread)\n for thread in threads:\n thread.join()\n\ndef _run_grid_multithread..(x):\n \"\"\"pass\"\"\"\n threading.Thread(target=func, args=(x,))\n```"} +{"i": 342, "got": "```python\ndef init_project_env(subject, proj_path, sysencoding, debug):\n executable_file_path = None\n proj_conf = {\n 'path': os.path.dirname(os.path.abspath(inspect.stack()[0][1])),\n 'sys_coding': sys.getdefaultencoding(),\n 'debug': debug,\n 'module_name': __name__,\n 'cfg_file': os.path.join(proj_path, 'config.ini'),\n 'path': os.path.join(proj_path, 'case', 'data', 'buffer', 'resource', 'tools', 'rst', 'rst_log', 'rst_shot')\n }\n \n if not os.path.exists(proj_path):\n os.makedirs(proj_path)\n \n for v in os.listdir(proj_path):\n FileSystemUtils.mkdirs(os.path.join(proj_path, v))\n \n if os.path.isdir(proj_conf['path']):\n with open(os.path.join(proj_conf['path'], 'config.ini'), 'w') as f:\n pass\n \n return None\n```"} +{"i": 343, "got": "```python\nimport os\n\ndef get_long_description():\n here = os.path.abspath(os.path.dirname(__file__))\n with open(os.path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f:\n description = f.read()\n return description\n```"} +{"i": 344, "got": "```python\ndef flatten(nested_list):\n def flatten_lambda(y):\n return y if y is None else sorted(filter(lambda x: isinstance(x, list), map(flatten_lambda, y)))\n\n return flatten_lambda(nested_list)\n```"} +{"i": 345, "got": "```python\ndef get_py_files(dir_name):\n \"\"\"pass\"\"\"\n flatten = os.walk(dir_name)\n files = []\n for path, _, f in flatten:\n if path.startswith('./build'):\n files.extend([f'{path}/{file}' for file in f if file.endswith('.py')])\n return files\n\n# Example usage\nprint(get_py_files('your_directory'))\n```"} +{"i": 346, "got": "```python\ndef exit(self):\n \"\"\"pass\"\"\"\n total = sum(logs for log in self.logs.values())\n if total:\n print(f\"[[{total}]]\")\n json.dump(self.logs, indent=self.indent)\n print(f\"[[{self.format(name)}]]\")\n print(\"\\n\")\n print(\"------------------------------\")\n print(f\"Total: {total}\")\n sys.exit(self.status_code)\n\ndef exit..(.0):\n \"\"\"return_generator\"\"\"\n for logs in self.logs.values():\n yield len(logs)\n```"} +{"i": 347, "got": "```python\ndef run_linter(self, linter):\n \"\"\"pass\"\"\"\n self.current = getattr(linter, 'name')\n self.parser = getattr(linter, 'parser')\n\n if getattr(linter, 'base_pyversion') > sys.version_info:\n return None\n\n if getattr(linter, 'requires_install'):\n return any(getattr(linter, 'requires_install'))\n\n getattr(linter, 'add_output_hook')(self.out_func)\n getattr(linter, 'set_config')(self.fn, self.parser, getattr(linter, 'name'))\n getattr(linter, 'run')(self.files)\n\n if self.status_code:\n return None\n\n self.status_code = 0\n```"} +{"i": 348, "got": "```python\ndef read_rcfile():\n \"\"\"pass\"\"\"\n files = ['{}/.millipederc'.format(os.environ.get('HOME', '/usr/local/etc/millipederc')), '/etc/millipederc']\n for filepath in files:\n if os.path.isfile(filepath):\n rcfile = open(filepath)\n parse_rcfile(rcfile)\n```"} +{"i": 349, "got": "```python\ndef parse_rcfile(rcfile):\n \"\"\"pass\"\"\"\n valid_keys = {'size', 'comment', 'template', 'reverse', 'opposite', 'position'}\n params = {}\n \n for linenum, line in enumerate(rcfile):\n line = line.strip()\n pos = line.find(' ')\n key = line[:pos]\n value = line[pos+1:]\n \n if key in valid_keys:\n if key == 'size':\n params[key] = int(value)\n elif key == 'comment':\n params[key] = value\n elif key == 'template':\n params[key] = value\n elif key == 'reverse':\n params[key] = True if value.lower() == 'yes' else False\n elif key == 'opposite':\n params[key] = True if value.lower() == 'yes' else False\n elif key == 'position':\n params[key] = int(value)\n else:\n print(f\"Ignoring line {linenum} from rcfile\")\n\ndef parse_bool(value):\n \"\"\"pass\"\"\"\n value = value.lower()\n if value in ('yes', 'true'):\n return True\n elif value in ('no', 'false'):\n return False\n else:\n raise ValueError(\"Can't parse {}\")\n```"} +{"i": 350, "got": "```python\ndef compute_settings(args, rc_settings):\n \"\"\"pass\"\"\"\n settings = {}\n for key, value in args.items():\n if key in ('reverse', 'opposite'):\n if not rc_settings.get(key, False):\n settings[key] ^= rc_settings.get('size')\n else:\n settings[key] = rc_settings.get(key)\n return settings['size'] if 'size' in settings else DEFAULT_SIZE\n```"} +{"i": 351, "got": "```python\ndef millipede(size, comment, reverse, template, position, opposite):\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n templates = {'default': 'pass'}\n template = templates['default']\n body_lines = []\n x = None\n\n for _ in range(size):\n body_lines.append('\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557')\n body_lines.append('\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d')\n body_lines.append('\u2554\u2299 \u2299\u2557')\n body_lines.append('\u255a\u2299 \u2299\u255d')\n\n head = '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557'\n if reverse:\n head = '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d'\n\n body = '\\n'.join(body_lines)\n output = ''\n\n if comment:\n output += f'{comment}\\n\\n'\n\n output += head + body\n output += head\n\n return output\n```"} +{"i": 352, "got": "```python\ndef api_post(message, url, name, http_data, auth):\n \"\"\"pass\"\"\"\n requests = None\n data = {}\n if http_data:\n for key, value in http_data.split('='):\n data[key] = value\n response = requests.post(url, data=data, auth=auth)\n if response.status_code != 200:\n raise RuntimeError('Unable to post data')\n```"} +{"i": 353, "got": "```python\nimport argparse\n\ndef run_main(args, do_exit):\n \"\"\"pass\"\"\"\n args.init()\n if not args.config_file:\n generate()\n CheckHandler(args.config_file, args.json, args.files)\n get_stylers()\n for style in get_linters():\n handler.run_linter(style)\n get_security()\n for security in get_tools():\n handler.run_linter(security)\n if do_exit:\n handler.exit()\n```"} +{"i": 354, "got": "```python\nimport argparse\n\ndef main():\n parser = argparse.ArgumentParser(description='pass')\n parser.add_argument('--json', action='store_true', default=False, help='output in JSON format')\n parser.add_argument('--config-file', default='.snekrc', help='Select config file to use')\n parser.add_argument('files', nargs='*', metavar='file', help='Files to run checks against')\n parser.add_argument('--init', action='store_true', default=False, help='generate snekrc')\n args = parser.parse_args()\n\ndef run_main(args):\n # Your main logic here\n pass\n\nif __name__ == \"__main__\":\n main()\n```"} +{"i": 355, "got": "```python\nimport requests\nfrom os import getenv\nfrom dict import load_json, load_yaml\nfrom SessionError import SessionError\nfrom decode import decode\nfrom Retry import Retry\n\ndef get_session(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs):\n s = requests.Session()\n ua = kwargs.get('full_agent', None)\n if ua is not None:\n headers = {'User-Agent': ua}\n os.environ['EXTRA_PARAMS'] = ', '.join(kwargs.get('extra_params', []))\n extra_params_dict = load_json(kwargs.get('extra_params_json', '{}'))\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n extra_params_lookup = kwargs.get('extra_params_lookup', None)\n auth_found = False\n basic_auth = getenv('BASIC_AUTH')\n if basic_auth:\n auth_found = True\n elif 'basic_auth' in kwargs:\n auth_found = True\n elif 'basic_auth_file' in kwargs:\n auth_found = True\n if auth_found:\n bauth = decode(kwargs.get('basic_auth', ''))\n if bauth:\n auth_found = True\n if not auth_found:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n s.params.update(auth=bauth)\n else:\n os.environ['EXTRA_PARAMS'] = ', '.join(kwargs.get('extra_params', []))\n extra_params_dict = load_json(kwargs.get('extra_params_json', '{}'))\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n extra_params_lookup = kwargs.get('extra_params_lookup', None)\n auth_found = False\n basic_auth = getenv('BASIC_AUTH')\n if basic_auth:\n auth_found = True\n elif 'basic_auth' in kwargs:\n auth_found = True\n elif 'basic_auth_file' in kwargs:\n auth_found = True\n if auth_found:\n bauth = decode(kwargs.get('basic_auth', ''))\n if bauth:\n auth_found = True\n if not auth_found:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n s.params.update(auth=bauth)\n status_forcelist = [429, 500, 502, 503, 504]\n method_whitelist = frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE'])\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(max_retries=retries, pool_connections=100, pool_maxsize=100))\n s.mount('https://', HTTPAdapter(max_retries=retries, pool_connections=100, pool_maxsize=100))\n return s\n```"} +{"i": 356, "got": "```python\nclass SMTP:\n def __init__(self, host, port, local_hostname, timeout, source_address):\n self.connection_type = 'smtp'\n self.host = host\n self.port = port\n self.local_hostname = local_hostname\n self.timeout = timeout\n self.source_address = source_address\n\n def connect(self):\n if self.connection_type == 'ssl':\n return smtplib.SMTP_SSL(self.host, self.port, local_hostname=self.local_hostname, timeout=self.timeout, source_address=self.source_address)\n elif self.connection_type == 'lmtp':\n return smtplib.LMTP(self.host, self.port, local_hostname=self.local_hostname, timeout=self.timeout, source_address=self.source_address)\n else:\n return smtplib.SMTP(self.host, self.port, local_hostname=self.local_hostname, timeout=self.timeout, source_address=self.source_address)\n\n def login(self, username, password):\n self.server.login(username, password)\n```"} +{"i": 357, "got": "```python\nclass EmailSender:\n def __init__(self, server):\n self.server = server\n\n def connect(self):\n # Simulate connecting to the email server\n pass\n\n def sendmail(self, sender, recipients, subject, text_body, html_body, **kwargs):\n # Create a MIME multipart message\n msg = MIMEMultipart('alternative')\n msg['Subject'] = subject\n msg['From'] = sender\n msg['To'] = ', '.join(recipients)\n\n # Attach plain text and HTML parts\n part1 = MIMEText(text_body, 'plain')\n part2 = MIMEText(html_body, 'html')\n msg.attach(part1)\n msg.attach(part2)\n\n # Send the email\n self.server.sendmail(sender, recipients, msg.as_string())\n\n def close(self):\n # Simulate closing the connection to the email server\n pass\n\ndef validate_email(email, check_deliverability=False):\n # Simulate validating an email address\n return True\n```"} +{"i": 358, "got": "```python\ndef get_session(db_url):\n \"\"\"pass\"\"\"\n engine = create_engine(db_url, poolclass=NullPool, echo=False)\n Session = sessionmaker(bind=engine)\n Base.metadata.create_all(engine)\n return Session()\n```"} +{"i": 359, "got": "```python\ndef get_params_from_sqlalchemy_url(db_url):\n \"\"\"\n pass\n \"\"\"\n result = urlsplit(db_url)\n return {\n 'database': result.path[1:],\n 'host': result.hostname,\n 'port': result.port,\n 'username': result.username,\n 'password': result.password,\n 'driver': None # Assuming the driver is not provided in the URL\n }\n```"} +{"i": 360, "got": "```python\ndef get_unset_cache(self):\n \"\"\"pass\"\"\"\n caches = []\n if self._cached_api_global_response is not None:\n caches.append('global')\n if self._cached_api_ticker_response is not None:\n caches.append('ticker')\n return len(caches), tuple(caches)\n```"} +{"i": 361, "got": "```python\ndef dicts_filter(dicts_object, field_to_filter, value_of_filter):\n \"\"\"\n pass\n \"\"\"\n lambda_query = lambda value: value[field_to_filter] == value_of_filter\n filtered_coin = list(filter(lambda_query, dicts_object))\n selected_coins = list(filtered_coin)\n return selected_coins\n```"} +{"i": 362, "got": "```python\nclass Ticker:\n def __init__(self):\n pass\n\n def send_request(self, endpoint, coin_name, **kwargs):\n built_url = self._make_url(endpoint, coin_name)\n payload = dict(kwargs)\n return self._process_request(endpoint, built_url, payload)\n\n def _make_url(self, endpoint, coin_name):\n # Implementation of _make_url method\n pass\n\n def _process_request(self, endpoint, built_url, payload):\n # Implementation of _process_request method\n pass\n```"} +{"i": 363, "got": "```python\nclass Module:\n def __init__(self):\n self.cache = {}\n\n def get_response(self, data_type):\n if data_type == 'ticker':\n return self.cache.get('ticker', None)\n elif data_type == 'global':\n return self.cache.get('global', None)\n else:\n raise ValueError(\"Invalid data type\")\n```"} +{"i": 364, "got": "```python\ndef iso_639_alpha3(code):\n \"\"\"\n pass\n \"\"\"\n normalize_code = code\n ISO3_MAP = {}\n ISO3_ALL = set()\n\n def get(code):\n return ISO3_MAP.get(code)\n\n if code in ISO3_ALL:\n return code\n\n return None\n```"} +{"i": 365, "got": "```python\ndef list_to_alpha3(languages, synonyms):\n \"\"\"\n pass\n \"\"\"\n codes = set()\n codes.update(iso_639_alpha3(language) for language in languages)\n codes.update(expand_synonyms(code) for code in codes if code is not None)\n return codes\n```"} +{"i": 366, "got": "```python\ndef _search_generator(self, item, reverse):\n \"\"\"pass\"\"\"\n results = []\n for _, x in enumerate(item, reverse=reverse):\n yield x\n return None\n\ndef search_generator(self, item, reverse=False):\n \"\"\"pass\"\"\"\n results = []\n for _, x in enumerate(item, reverse=reverse):\n yield x\n return None\n```"} +{"i": 367, "got": "```python\ndef item():\n return (item, Any(), return, Generator(Any(), None, None), _search_generator)\n\ndef _search_generator(self, item):\n results = []\n for x in enumerate(item):\n yield 1\n results.append(1)\n if len(results) == 0:\n raise SearchError(str(item))\n return None\n\nclass SearchError(Exception):\n pass\n```"} +{"i": 368, "got": "```python\ndef item():\n return (item, None)\n\ndef _search_generator(self, item):\n results = []\n for key, value in enumerate(item):\n results.append((key, value))\n yield from results\n\nclass SearchError(Exception):\n pass\n```"} +{"i": 369, "got": "```python\ndef serialize(obj):\n \"\"\"pass\"\"\"\n if isinstance(obj, (datetime.date, datetime.time)):\n return obj.isoformat()\n elif isinstance(obj, datetime.datetime):\n return obj.combine(datetime.date.today(), obj.min).isoformat()\n else:\n return None\n```"} +{"i": 370, "got": "```python\ndef check(response, expected_status, url):\n \"\"\"pass\"\"\"\n err = cell()\n with tempfile.NamedTemporaryFile(suffix='.html', delete=False) as f:\n response.text.encode('utf-8').write(f)\n msg = None\n if 'Content-Type' in response.headers and response.headers['Content-Type'] == 'application/json':\n try:\n data = response.json()\n if data.get('status') != expected_status or data.get('message') is not None or data.get('description') is not None or data.get('details') is not None:\n raise _APIError(response.status_code, msg)\n except ValueError:\n pass\n else:\n if 'Content-Type' in response.headers and response.headers['Content-Type'] == 'text/plain':\n if '.html' in response.text:\n suffix = '.html'\n elif '.txt' in response.text:\n suffix = '.txt'\n else:\n raise _APIError(response.status_code, msg)\n else:\n raise _APIError(response.status_code, msg)\n msg = f'Request {url!r} returned code {response.status_code}, expected {expected_status}. \\n{msg}'\n if response.text.startswith('.(.0):\n \"\"\"pass\"\"\"\n for x in .0:\n if x not in err:\n yield x\n```"} +{"i": 371, "got": "```python\nclass AuthManager:\n def __init__(self, host):\n self.host = host\n\n def _get_auth(self, user, password):\n fn = os.path.expanduser(\"~/.amcat/auth.csv\")\n if not os.path.exists(fn):\n log.warning(\"Cannot parse line {i} in {fn}\".format(i=line, fn=fn))\n return\n reader = csv.reader(open(fn, newline=''))\n for i, line in enumerate(reader):\n hostname, username, pwd = line[:3]\n if hostname == self.host:\n if user and username == user:\n if password and pwd == password:\n return (hostname, username, pwd)\n else:\n log.warning(\"No authentication info for {user}@{self.host} from {fn}\".format(user=user, fn=fn))\n raise Exception(\"No authentication info for {user}@{self.host} from AMCAT_USER / AMCAT_PASSWORD variables\".format(user=user, self=self))\n\n def get_auth(self):\n user = os.getenv('AMCAT_USER')\n password = os.getenv('AMCAT_PASSWORD')\n if not user:\n user = os.getenv('USER')\n if not password:\n password = os.getenv('PASSWORD')\n return self._get_auth(user, password)\n```"} +{"i": 372, "got": "```python\ndef get(self, url, method='get', format=None, data=None, expected_status=None, headers=None, use_xpost=False, **options):\n if expected_status is None and method not in ('get', 'post'):\n raise ValueError('No expected status supplied and method unknown.')\n \n if method == 'get':\n expected_status = 200\n elif method == 'post':\n expected_status = 201\n \n url = f'http://{self.host}/api/v4/{url}'\n if format is not None:\n url = f'{url}{format}'\n \n headers = self.headers.copy()\n if use_xpost and data is not None:\n headers['X-HTTP-METHOD-OVERRIDE'] = method\n options['data'] = data\n \n r = requests.request(method, url, **options)\n \n log.debug(f'HTTP {method} {url} (options={options!r}, data={data!r},headers={headers}) -> {r.status_code}')\n \n check(r, expected_status)\n\ndef request(self, url, method='get', format=None, data=None, expected_status=None, headers=None, use_xpost=False, **options):\n if expected_status is None and method not in ('get', 'post'):\n raise ValueError('No expected status supplied and method unknown.')\n \n if method == 'get':\n expected_status = 200\n elif method == 'post':\n expected_status = 201\n \n url = f'http://{self.host}/api/v4/{url}'\n if format is not None:\n url = f'{url}{format}'\n \n headers = self.headers.copy()\n if use_xpost and data is not None:\n headers['X-HTTP-METHOD-OVERRIDE'] = method\n options['data'] = data\n \n r = requests.request(method, url, **options)\n \n log.debug(f'HTTP {method} {url} (options={options!r}, data={data!r},headers={headers}) -> {r.status_code}')\n \n check(r, expected_status)\n\ndef check(r, expected_status):\n if r.status_code != expected_status:\n raise AssertionError(f'Expected status {expected_status}, but got {r.status_code}')\n\ndef log(self, message, **kwargs):\n pass\n```"} +{"i": 373, "got": "```python\nclass MyModule:\n def get_pages(self, url, page, page_size, yield_pages, **filters):\n \"\"\"pass\"\"\"\n r = []\n n = 0\n for page in itertools.count(page):\n response = self.request(url, page, page_size, filters)\n results = response['results']\n n += len(results)\n log.debug(f'Got {url} page {page} / {n}')\n if yield_pages:\n yield results\n r.append(results)\n return r\n\n def request(self, url, page, page_size, filters):\n # Simulate a request to fetch data from the URL\n return {'results': [f'Page {page}, Result {i}' for i in range(page * page_size, (page + 1) * page_size)]}\n```"} +{"i": 374, "got": "```python\nclass Module:\n def __init__(self):\n self.get_scroll = self.get_scroll_func\n\n def get_scroll_func(self, url, page_size, yield_pages, **filters):\n \"\"\"pass\"\"\"\n options = dict(page_size=page_size, filters=filters)\n format = self.request(url, use_xpost=False, options=options).results\n log.debug(f'Got {n}/{total} {url.split(\"?\")[0]} total={r.total}')\n if yield_pages:\n for row in r.results:\n yield row\n else:\n return r.results\n\n def request(self, url, use_xpost=False, options=None):\n # Simulated request logic\n results = [1, 2, 3] # Example results\n total = len(results)\n return {'results': results, 'total': total}\n\n def split(self, string):\n # Simulated split logic\n return string.split('?')[0]\n\n def debug(self, message, *args):\n print(message.format(*args))\n\nlog = {\n 'debug': self.debug\n}\n```"} +{"i": 375, "got": "```python\nclass Module:\n def __init__(self):\n self._error_queue = None\n\n def get_error(self, block, timeout):\n pass\n```"} +{"i": 376, "got": "```python\nclass Module:\n def __init__(self):\n self._feedback_greenlet = None\n self._feedback_queue = None\n\n def get_feedback(self, block, timeout):\n \"\"\"pass\"\"\"\n if self._feedback_greenlet is not None:\n return self._feedback_queue.get(block=block, timeout=timeout)\n else:\n gevent.spawn(self._feedback_loop)\n return self._feedback_queue.get(block=block, timeout=timeout)\n\n def _feedback_loop(self):\n # Implementation of the feedback loop\n pass\n```"} +{"i": 377, "got": "```python\nclass MyClass:\n def __init__(self):\n self._send_queue_cleared = True\n\n def wait_send(self, timeout):\n # pass\n if not self._send_queue_cleared:\n raise ValueError(\"Send queue is not cleared\")\n self._send_queue_cleared = False\n self.wait(timeout)\n```"} +{"i": 378, "got": "```python\nclass Module:\n def __init__(self):\n self._send_greenlet = None\n\n def start(self):\n \"\"\"pass\"\"\"\n if self._send_greenlet is not None:\n gevent.spawn(self._send_loop)\n self._send_greenlet = None\n```\n\nThis Python code snippet corresponds to the bytecode disassembly provided. It defines a class `Module` with an instance variable `_send_greenlet`. The `start` method checks if `_send_greenlet` is not `None`, and if so, it spawns a new greenlet using `gevent.spawn`. After spawning, it sets `_send_greenlet` to `None`."} +{"i": 379, "got": "```python\nclass Stop:\n def __init__(self, timeout):\n self._send_greenlet = None\n self._send_queue = None\n self._wait_send = None\n self._error_greenlet = None\n self._feedback_greenlet = None\n\n def _send_greenlet(self):\n pass\n\n def _send_queue(self):\n return len(self._send_queue)\n\n def _wait_send(self, timeout):\n pass\n\n def kill(self):\n gevent.kill(self._send_greenlet)\n gevent.kill(self._error_greenlet)\n gevent.kill(self._feedback_greenlet)\n```"} +{"i": 380, "got": "```python\ndef convert_to_ssml(text, text_format):\n \"\"\"\n pass\n \"\"\"\n if text_format is None:\n return text\n elif text_format == 'plain':\n return plain_to_ssml(text)\n elif text_format == 'html':\n return html_to_ssml(text)\n else:\n raise ValueError(': text format not found.')\n```"} +{"i": 381, "got": "```python\ndef html_to_ssml(text):\n \"\"\"pass\"\"\"\n ssml_text = reduce(html_to_ssml.., text, \"\")\n return ssml_text\n\ndef html_to_ssml_maps(x, y):\n return x.replace(y, html_to_ssml_maps[y])\n```\n\nThe Python source code corresponding to the given bytecode disassembly is as follows:\n\n```python\ndef html_to_ssml(text):\n \"\"\"pass\"\"\"\n ssml_text = reduce(html_to_ssml.., text, \"\")\n return ssml_text\n\ndef html_to_ssml_maps(x, y):\n return x.replace(y, html_to_ssml_maps[y])\n```\n\nThis Python code defines two functions: `html_to_ssml` and `html_to_ssml_maps`. The `html_to_ssml` function takes a string `text` as input, applies the `reduce` function with `html_to_ssml..` as the reducer, and returns the resulting string. The `html_to_ssml_maps` function replaces all occurrences of a substring `y` in a string `x` using the `replace` method and then recursively calls itself to replace any further occurrences of `y`."} +{"i": 382, "got": "```python\ndef iexpand(string, keep_escapes):\n \"\"\"pass\"\"\"\n is_bytes = isinstance(string, bytes)\n if not is_bytes:\n string = string.decode('latin-1')\n if is_bytes:\n return [entry.encode('latin-1') for entry in ExpandBrace(keep_escapes, expand(string))]\n else:\n return [entry.encode('latin-1') for entry in ExpandBrace(keep_escapes, expand(string))]\n\ndef ExpandBrace(keep_escapes, string):\n \"\"\"pass\"\"\"\n # Implementation of ExpandBrace function\n pass\n\ndef NULL():\n \"\"\"pass\"\"\"\n pass\n\ndef INTRINSIC_STOPITERATION_ERROR():\n \"\"\"pass\"\"\"\n pass\n```"} +{"i": 383, "got": "```python\nclass MyClass:\n def set_expanding(self):\n \"\"\"pass\"\"\"\n if not self.expanding:\n self.expanding = True\n```\n\nThis Python code snippet defines a class `MyClass` with a method `set_expanding`. The method checks the value of the attribute `expanding`, and if it is `False`, it sets it to `True`."} +{"i": 384, "got": "```python\nclass MyClass:\n def __init__(self):\n self.keep_escapes = True\n\n def get_escape(self, c, i):\n escaped = None\n while True:\n next_value = next(i)\n if not self.keep_escapes or c in next_value:\n escaped = next_value\n break\n return escaped\n```"} +{"i": 385, "got": "```python\ndef squash(self, a, b):\n \"\"\"pass\"\"\"\n for x in itertools.product(a, b):\n yield '' + self.join(x)\n```\n\nThis Python function `squash` takes two arguments `a` and `b`, generates all possible combinations of elements from both lists using the `itertools.product` function, and then joins each combination with an empty string using the `join` method. The result is a generator that yields these joined strings."} +{"i": 386, "got": "```python\nclass MyClass:\n def get_literals(self, c, i, depth):\n result = []\n is_dollar = False\n ignore_brace = False\n\n while True:\n if not c:\n break\n if is_dollar:\n ignore_brace = not ignore_brace\n is_dollar = False\n elif c == '$':\n is_dollar = True\n elif c == '{':\n index = i\n self.rewind(i)\n seq = next(self.get_sequence())\n result.append(seq)\n if seq == '}':\n break\n i += 1\n else:\n ignore_brace = False\n result.append(c)\n\n return ''.join(result)\n\n def get_escape(self, c, i):\n # Implementation of get_escape method\n pass\n\n def index(self, value):\n # Implementation of index method\n pass\n\n def is_expanding(self):\n # Implementation of is_expanding method\n pass\n\n def rewind(self, i):\n # Implementation of rewind method\n pass\n\n def get_sequence(self):\n # Implementation of get_sequence method\n pass\n\n def squash(self, result):\n # Implementation of squash method\n pass\n```"} +{"i": 387, "got": "```python\ndef combine(self, a, b):\n \"\"\"pass\"\"\"\n yield from ((a, b),)\n```\n\nThis Python function `combine` takes two arguments `a` and `b`, combines them into a tuple, and yields the result. The function does not perform any operations other than combining the inputs."} +{"i": 388, "got": "```python\nclass Episode:\n def __init__(self, text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break):\n self.text = text\n self.text_format = text_format\n self.title = title\n self.author = author\n self.link = link\n self.summary = summary\n self.publish_date = publish_date\n self.synthesizer = synthesizer\n self.synth_args = synth_args\n self.sentence_break = sentence_break\n\n def __repr__(self):\n return f\"Episode(text='{self.text}', text_format='{self.text_format}', title='{self.title}', author='{self.author}', link='{self.link}', summary='{self.summary}', publish_date='{self.publish_date}', synthesizer='{self.synthesizer}', synth_args={self.synth_args}, sentence_break={self.sentence_break})\"\n\ndef add_episode(self, text, text_format, title, author, summary, publish_date, synthesizer, synth_args, sentence_break):\n if title in self.episodes:\n raise ValueError(f\"'{title}' already exists as an episode title.\")\n \n output_path = f\"{self.output_path}/{title.replace(' ', '_').lower()}.mp3\"\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, output_path, summary, publish_date, synthesizer, synth_args, sentence_break)\n \n self.episodes[title] = new_episode\n```\n\nThis Python code defines a class `Episode` and a method `add_episode` that adds a new episode to the list of episodes. The method checks if an episode with the same title already exists before adding it. If it does, it raises a `ValueError`. Otherwise, it creates a new `Episode` object and stores it in the list of episodes under the given title."} +{"i": 389, "got": "```python\nclass Watson:\n def __init__(self):\n self._scheduler = None\n self.scheduled_jobs = {}\n\n def add_scheduled_job(self, text_source, cron_args, text_format, title, author, summary, synthesizer, synth_args, sentence_break):\n # Check if the text_source is a function\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n # Create closures for each argument\n self.add_episode = self._create_add_episode_closure()\n\n def _create_add_episode_closure(self):\n def add_episode(episode_text, title, author, summary, synthesizer, synth_args, sentence_break):\n # Extract episode details from text_source\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n episode_text = text_source()\n\n # Add the episode to the scheduler\n self._scheduler.add_job(self.add_episode, 'cron', id=title, kwargs={\n 'episode_text': episode_text,\n 'text_format': text_format,\n 'episode_title': episode_title,\n 'author': author,\n 'summary': summary,\n 'synthesizer': synthesizer,\n 'synth_args': synth_args,\n 'sentence_break': sentence_break\n })\n\n return add_episode\n\n def _scheduler(self):\n # Placeholder for the scheduler implementation\n pass\n\n def utcnow(self):\n # Placeholder for the current UTC time implementation\n pass\n\n def strftime(self, format_string):\n # Placeholder for the string formatting implementation\n pass\n```"} +{"i": 390, "got": "```python\nclass MyClass:\n def publish(self, titles):\n \"\"\"pass\"\"\"\n if not isinstance(titles, (str, tuple)):\n raise TypeError('titles must be a string or a sequence of strings.')\n for title in titles:\n self.episodes[title] = self.publish(title)\n self.update_rss_feed()\n\n def update_rss_feed(self):\n pass\n```"} +{"i": 391, "got": "```python\nclass AudioRenderer:\n def render_audio(self):\n \"\"\"pass\"\"\"\n text_to_speech = self.text_to_speech\n segment = text_to_speech(self._text, self.synthesizer, self.synth_args, self.sentence_break)\n milli = len(segment) * 1000 / (60 * 60 * 24)\n seconds = int(milli // 60)\n minutes = int((milli % 60) // 60)\n hours = int((milli % 3600) // 3600)\n self.duration = f\"{hours:02}:{minutes:02}:{seconds:02}\"\n self.export(self.link, 'mp3', format={'format': 'mp3'})\n os.path.getsize(self.link)\n return None\n```"} +{"i": 392, "got": "```python\ndef remove_exponent(d):\n \"\"\"\n pass\n \"\"\"\n if d == d.to_integral():\n return d.quantize(Decimal('1'), rounding=ROUND_HALF_UP)\n else:\n return d.normalize()\n```"} +{"i": 393, "got": "```python\ndef millify(n, precision=3, drop_nulls=True, prefixes=None):\n \"\"\"pass\"\"\"\n millnames = ['', 'k', 'M', 'B', 'T', 'P', 'E', 'Z', 'Y']\n if prefixes is None:\n prefixes = []\n millidx = max(0, int(math.floor(math.log10(abs(n)) / 3)))\n result = '{:.{precision}f}'.format(n * (10 ** -millidx))\n if drop_nulls and not result.endswith('0'):\n result = remove_exponent(result)\n return '{0}{dx}'.format(result, dx=millnames[millidx])\n```"} +{"i": 394, "got": "```python\ndef prettify(amount, separator):\n orig = str(amount)\n new = re.sub(r'^(-?\\d+)(\\d{3})', r'\\g<1>{0}\\g<2>', amount, flags=re.IGNORECASE)\n if orig == new:\n return new\n else:\n return prettify(new, separator)\n```"} +{"i": 395, "got": "```python\ndef load_json(json_data, decoder=None):\n \"\"\"\n pass\n \"\"\"\n if decoder is None:\n decoder = DateTimeDecoder()\n return json.loads(json_data, object_hook=decoder.decode)\n```"} +{"i": 396, "got": "```python\ndef load_json_file(file, decoder):\n \"\"\"pass\"\"\"\n if decoder is not None:\n decoder = DateTimeDecoder()\n with open(file, 'r', encoding='utf-8') as f:\n return json.load(f, object_hook=decoder)\n```\n\nThis Python function `load_json_file` takes a file path and an optional decoder as arguments. It opens the specified file in read mode with UTF-8 encoding, loads JSON data from the file using the provided decoder (or the default `DateTimeDecoder` if none is given), and returns the parsed data."} +{"i": 397, "got": "```python\ndef save_json(val, pretty=False, sort=False, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder()\n if pretty:\n return json.dumps(val, separators=(',', ': '), sort_keys=sort, cls=encoder)\n else:\n return json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n```"} +{"i": 398, "got": "```python\ndef save_json_file(file, val, pretty, compact, sort, encoder):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder()\n opened = False\n with open(file, 'w', encoding='utf-8') as f:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n f.write(data)\n if opened:\n f.close()\n```"} +{"i": 399, "got": "```python\nimport io\nimport yaml\n\nclass MyClass:\n def load_yaml_file(self, file):\n if hasattr(file, 'read'):\n with open(file, 'r', encoding='utf-8') as f:\n return yaml.load(f, Loader=yaml.FullLoader)\n else:\n raise ValueError(\"File object does not have a read method\")\n```"} +{"i": 400, "got": "```python\ndef save_yaml_file(file, val):\n \"\"\"pass\"\"\"\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n yaml.dump(val, file)\n if opened:\n file.close()\n```"} +{"i": 401, "got": "```python\nclass Module:\n def __init__(self):\n self.iocs = None\n\n def get_embedded_yara(self, iocid):\n \"\"\"\n pass\n \"\"\"\n ioc_obj = self.iocs[iocid]\n ids_to_process = set()\n signatures = ''\n top_level_indicator = ioc_obj.top_level_indicator\n xpath = './/IndicatorItem[Context/@search = \"Yara/Yara\"]'\n for elem in top_level_indicator.xpath(xpath):\n signature = elem.findtext('Content')\n signatures += '\\n' + signature\n if signatures:\n signatures += '\\n'\n return signatures\n```"} +{"i": 402, "got": "```python\ndef get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string, joining_value):\n \"\"\"pass\"\"\"\n expected_tag = 'Indicator'\n indicator_node_id = getattr(indicator_node, 'id')\n if indicator_node.tag != expected_tag:\n raise YaraConversionError(f'indicator_node expected tag is [{expected_tag}]')\n\n is_set = False\n parameters_node = parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id))\n for param in parameters_node:\n attrib = param.attrib\n if attrib['name'] == 'yara/set':\n is_set = True\n set_count = int(param.findtext('value'))\n if set_count < 1:\n raise YaraConversionError(f'yara/set parameter value was less than 1')\n if set_count > len(indicator_node.getchildren()):\n raise YaraConversionError(f'yara/set value is greater than the number of children of Indicator node [{indicator_node_id}]')\n\n mapping = {'prefix': '', 'identifier': '', 'condition': '', 'postfix': ''}\n use_condition_template = False\n for param in parameters_node:\n attrib = param.attrib\n if attrib['name'] == 'yara/count':\n mapping['prefix'] += '$'\n mapping['identifier'] += indicator_node_id\n mapping['condition'] += '$'\n mapping['postfix'] += ''\n use_condition_template = True\n elif attrib['name'] == 'yara/offset/at':\n mapping['prefix'] += '$'\n mapping['identifier'] += indicator_node_id\n mapping['condition'] += 'at'\n mapping['postfix'] += ''\n use_condition_template = True\n elif attrib['name'] == 'yara/offset/in':\n mapping['prefix'] += '$'\n mapping['identifier'] += indicator_node_id\n mapping['condition'] += 'in'\n mapping['postfix'] += ''\n use_condition_template = True\n\n if not use_condition_template:\n condition_string = ''\n\n for param in parameters_node:\n attrib = param.attrib\n if attrib['name'] == 'yara/count':\n condition_string += '#'\n condition_string += mapping['prefix']\n condition_string += mapping['identifier']\n condition_string += mapping['condition']\n condition_string += mapping['postfix']\n elif attrib['name'] == 'yara/offset/at':\n condition_string += '#'\n condition_string += mapping['prefix']\n condition_string += mapping['identifier']\n condition_string += mapping['condition']\n condition_string += mapping['postfix']\n elif attrib['name'] == 'yara/offset/in':\n condition_string += '#'\n condition_string += mapping['prefix']\n condition_string += mapping['identifier']\n condition_string += mapping['condition']\n condition_string += mapping['postfix']\n\n if use_condition_template:\n condition_string = self.yara_II_condition_template % mapping\n else:\n condition_string = self.yara_set_string_template % mapping\n\n return condition_string\n```"} +{"i": 403, "got": "```python\nclass WriteYara:\n def __init__(self, yara_signatures):\n self.yara_signatures = yara_signatures\n\n def write_yara(self, output_file):\n with open(output_file, 'wb') as fout:\n for iocid in self.yara_signatures:\n signature = self.yara_signatures[iocid]\n fout.write(signature + '\\n')\n fout.close()\n return True\n```"} +{"i": 404, "got": "```python\nimport os\n\ndef safe_makedirs(fdir):\n \"\"\"pass\"\"\"\n if os.path.isdir(fdir):\n return True\n else:\n os.makedirs(fdir)\n return True\n```"} +{"i": 405, "got": "```python\nclass ConvertTo10:\n def __init__(self, iocs):\n self.iocs = iocs\n\n def convert_to_10(self):\n errors = []\n for iocid in self.iocs:\n ioc_obj_11 = self.get_ioc(iocid)\n if not ioc_obj_11:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n metadata = ioc_obj_11.metadata\n name_11 = self.findtext(metadata, './/short_description')\n keywords_11 = self.findtext(metadata, './/keywords')\n description_11 = self.findtext(metadata, './/description')\n author_11 = self.findtext(metadata, './/authored_by')\n created_date_11 = self.findtext(metadata, './/authored_date')\n links_11 = []\n for link in ioc_obj_11.links:\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, link_text))\n criteria_node = self.xpath(ioc_obj_11.root, './/criteria')[0]\n tlo_id = criteria_node.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters:\n param_id = param.get('ref-id')\n param_text = param.text\n comment_dict[param_id] = param_text\n ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n last_modified_date_11 = self.xpath(ioc_obj_10.root, './/last-modified')[0].text\n authored_date_node = self.xpath(ioc_obj_10.root, './/authored-date')[0]\n created_date_node.text = 'http://schemas.mandiant.com/2010/ioc'\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n for child in criteria_node:\n tag = child.tag\n metadata_dictionary[tag] = child.text\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n raise DowngradeError(f'IOC {iocid} is missing required metadata: [{tag}]')\n for tag in METADATA_ORDER_10:\n if tag not in metadata_dictionary:\n ioc_obj_10.append(metadata_dictionary[tag])\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n self.convert_branch(tlo_11, ioc_obj_10, ids_to_skip, comment_dict)\n ioc_obj_10.top_level_indicator.getparent().remove(ioc_obj_10.top_level_indicator)\n for child in criteria_node:\n tag = child.tag\n metadata_dictionary[tag] = child.text\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n raise DowngradeError(f'IOC {iocid} is missing required metadata: [{tag}]')\n for tag in METADATA_ORDER_10:\n if tag not in metadata_dictionary:\n ioc_obj_10.append(metadata_dictionary[tag])\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n self.convert_branch(tlo_11, ioc_obj_10, ids_to_skip, comment_dict)\n ioc_obj_10.top_level_indicator.getparent().remove(ioc_obj_10.top_level_indicator)\n for child in criteria_node:\n tag = child.tag\n metadata_dictionary[tag] = child.text\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n raise DowngradeError(f'IOC {iocid} is missing required metadata: [{tag}]')\n for tag in METADATA_ORDER_10:\n if tag not in metadata_dictionary:\n ioc_obj_10.append(metadata_dictionary[tag])\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n self.convert_branch(tlo_11, ioc_obj_10, ids_to_skip, comment_dict)\n ioc_obj_10.top_level_indicator.getparent().remove(ioc_obj_10.top_level_indicator)\n for child in criteria_node:\n tag = child.tag\n metadata_dictionary[tag] = child.text\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n raise DowngradeError(f'IOC {iocid} is missing required metadata: [{tag}]')\n for tag in METADATA_ORDER_10:\n if tag not in metadata_dictionary:\n ioc_obj_10.append(metadata_dictionary[tag])\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n self.convert_branch(tlo_11, ioc_obj_10, ids_to_skip, comment_dict)\n ioc_obj_10.top_level_indicator.getparent().remove(ioc_obj_10.top_level_indicator)\n for child in criteria_node:\n tag = child.tag\n metadata_dictionary[tag] = child.text\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n raise DowngradeError(f'IOC {iocid} is missing required metadata: [{tag}]')\n for tag in METADATA_ORDER_10:\n if tag not in metadata_dictionary:\n ioc_obj_10.append(metadata_dictionary[tag])\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n self.convert_branch(tlo_11, ioc_obj_10, ids_to_skip, comment_dict)\n ioc_obj_10.top_level_indicator.getparent().remove(ioc_obj_10.top_level_indicator)\n for child in criteria_node:\n tag = child.tag\n metadata_dictionary[tag] = child.text\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n raise DowngradeError(f'IOC {iocid} is missing required metadata: [{tag}]')\n for tag in METADATA_ORDER_10:\n if tag not in metadata_dictionary:\n ioc_obj_10.append(metadata_dictionary[tag])\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n self.convert_branch(tlo_11, ioc_obj_10, ids_to_skip, comment_dict)\n ioc_obj_10.top_level_indicator.getparent().remove(ioc_obj_10.top_level_indicator)\n for child in criteria_node:\n tag = child.tag\n metadata_dictionary[tag] = child.text\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n raise DowngradeError(f'IOC {iocid} is missing required metadata: [{tag}]')\n for tag in METADATA_ORDER_10:\n if tag not in metadata_dictionary:\n ioc_obj_10.append(metadata_dictionary[tag])\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n self.convert_branch(tlo_11, ioc_obj_10, ids_to_skip, comment_dict)\n ioc_obj_10.top_level_indicator.getparent().remove(ioc_obj_10.top_level_indicator)\n for child in criteria_node:\n tag = child.tag\n metadata_dictionary[tag] = child.text\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n raise DowngradeError(f'IOC {iocid} is missing required metadata: [{tag}]')\n for tag in METADATA_ORDER_10:\n if tag not in metadata_dictionary:\n ioc_obj_10.append(metadata_dictionary[tag])\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n self.convert_branch(tlo_11, ioc_obj_10, ids_to_skip, comment_dict)\n ioc_obj_10.top_level_indicator.getparent().remove(ioc_obj_10.top_level_indicator)\n for child in criteria_node:\n tag = child.tag\n metadata_dictionary[tag] = child.text\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n raise DowngradeError(f'IOC {iocid} is missing required metadata: [{tag}]')\n for tag in METADATA_ORDER_10:\n if tag not in metadata_dictionary:\n ioc_obj_10.append(metadata_dictionary[tag])\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n self.convert_branch(tlo_11, ioc_obj_10, ids_to_skip, comment_dict)\n ioc_obj_10.top_level_indicator.getparent().remove(ioc_obj_10.top_level_indicator)\n for child in criteria_node:\n tag = child.tag\n metadata_dictionary[tag] = child.text\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n raise DowngradeError(f'IOC {iocid} is missing required metadata: [{tag}]')\n for tag in METADATA_ORDER_10:\n if tag not in metadata_dictionary:\n ioc_obj_10.append(metadata_dictionary[tag])\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n self.convert_branch(tlo_11, ioc_obj_10, ids_to_skip, comment_dict)\n ioc_obj_10.top_level_indicator.getparent().remove(ioc_obj_10.top_level_indicator)\n for child in criteria_node:\n tag = child.tag\n metadata_dictionary[tag] = child.text\n "} +{"i": 406, "got": "```python\nclass ConvertBranch:\n def __init__(self, old_node, new_node, ids_to_skip, comment_dict):\n self.old_node = old_node\n self.new_node = new_node\n self.ids_to_skip = ids_to_skip\n self.comment_dict = comment_dict\n\n def convert(self):\n expected_tag = 'Indicator'\n if self.old_node.tag != expected_tag:\n raise DowngradeError(f'old_node expected tag is [{expected_tag}]')\n\n comment_dict = {}\n if not comment_dict:\n comment_dict = {}\n\n for node in self.old_node.getchildren():\n node_id = node.get('id')\n if node_id in self.ids_to_skip:\n continue\n\n if node.tag == 'IndicatorItem':\n negate = node.get('negate', False)\n condition = node.get('condition', True)\n new_condition = condition\n document = node.xpath('Context/@document')[0]\n search = node.xpath('Context/@search')[0]\n content_type = node.xpath('Content/@type')[0]\n content = node.findtext('Content')\n context_type = node.xpath('Context/@type')[0]\n\n new_ii_node = ioc_api.make_indicatoritem_node(condition, document, search, content_type, content, context_type, node_id)\n comment_dict[node_id] = new_condition\n\n elif node.tag == 'Indicator':\n operator = node.get('operator', None)\n if operator and operator.upper() not in ('OR', 'AND'):\n raise DowngradeError(f'Indicator@operator is not AND/OR. [{node_id}] has [{operator}]')\n\n new_i_node = ioc_api.make_indicator_node(operator, node_id)\n self.convert_branch(node, new_i_node, self.ids_to_skip, comment_dict)\n\n return True\n```"} +{"i": 407, "got": "```python\nclass MyClass:\n def __init__(self, client, parent_object):\n self.client = client\n self.parent_object = parent_object\n\n @staticmethod\n def create(self, permission):\n # pass\n parent_url = self.client.get_url(self.parent_object.id)\n target_url = self.client.get_url_path('single', 'id', self.parent_object.id) + \\\n self.client.request('POST', target_url, permission, self._serialize(permission), json=self.json)\n r = self.client.request('POST', target_url, permission, self._serialize(permission), json=self.json)\n self._deserialize(r, self.json)\n\n def _serialize(self, permission):\n # implementation of serialization logic\n pass\n\n def _deserialize(self, r, json):\n # implementation of deserialization logic\n pass\n```"} +{"i": 408, "got": "```python\ndef set(self, permissions):\n \"\"\"pass\"\"\"\n client = self.client\n parent_url = client.get_url(parent_object=self.parent_object, _manager=self._manager, _URL_KEY='GET', method='single', id=self.parent_object.id)\n target_url = client.get_url_path(target_url=target_url, _manager=self._manager, _URL_KEY='PUT', method='multi')\n r = client.request(method='PUT', target_url=target_url, permissions=permissions, json={})\n if r.status_code != 201:\n raise exceptions.ServerError(f'Expected 201 response, got {r.status_code}: {target_url}')\n self.list()\n```"} +{"i": 409, "got": "```python\nclass List:\n def __init__(self, client, parent_object):\n self.client = client\n self.parent_object = parent_object\n\n def get_url(self):\n return f\"{self.client.get_url_path()}/single/{self.parent_object.id}\"\n\n def get_url_path(self):\n return f\"{self._manager._URL_KEY}/{self._URL_KEY}\"\n\n def Query(self, target_url):\n base.query(target_url)\n```"} +{"i": 410, "got": "```python\nclass MyClass:\n def __init__(self, client, parent_object):\n self.client = client\n self.parent_object = parent_object\n\n def get(self, permission_id, expand=False):\n \"\"\"\n pass\n \"\"\"\n parent_url = self.client.get_url(self.parent_object._manager, self.parent_object.id)\n target_url = parent_url + self.client.get_url_path(permission_id)\n return self._get(target_url, expand=expand)\n```"} +{"i": 411, "got": "```python\ndef get_config():\n \"\"\"pass\"\"\"\n configpath = get_configpath()\n if not exists(configpath):\n raise IOError('Config file {} not found.'.format(str(configpath)))\n config = configparser.ConfigParser()\n config.read(str(configpath))\n return config\n```"} +{"i": 412, "got": "```python\ndef set_database_path(dbfolder):\n \"\"\"pass\"\"\"\n configpath = get_configpath()\n d = get_config()\n\n with open(configpath, 'w') as f:\n f.write(d['pyciss_db']['path'])\n\n print('Saved database path into {}.'.format(configpath))\n```"} +{"i": 413, "got": "```python\ndef get_db_root():\n \"\"\"pass\"\"\"\n d = get_config()\n dbroot = Path(d['pyciss_db']).joinpath('path')\n dbroot.mkdir(exist_ok=True)\n return dbroot\n```"} +{"i": 414, "got": "```python\ndef print_db_stats():\n \"\"\"\n pass\n \"\"\"\n dbroot = get_db_root()\n n_ids = len(list(dbroot.glob('[N,W]*')))\n print(f\"Number of WACs and NACs in database: {n_ids}\")\n print(\"These kind of data are in the database: (returning pd.DataFrame)\")\n d = {}\n for key, val in PathManager.extensions.items():\n d[key] = list(dbroot.glob(val + '**/*'))\n return pd.DataFrame(d)\n```"} +{"i": 415, "got": "```python\ndef is_lossy(label):\n \"\"\"pass\"\"\"\n from_ = getkey()\n keyword = 'INST_CMPRS_TYPE'\n val = decode(from_, keyword)\n val = strip(val)\n if val == 'LOSSY':\n return True\n else:\n return False\n```"} +{"i": 416, "got": "```python\ndef download_and_calibrate_parallel(list_of_ids, n):\n \"\"\"\n pass\n \"\"\"\n setup_cluster(n_cores=n)\n c = Client()\n lbview = c.load_balanced_view()\n lbview.map_async(download_and_calibrate, list_of_ids)\n subprocess.Popen(['ipcluster', 'stop', '--quiet'])\n```"} +{"i": 417, "got": "```python\nclass Settings:\n def __init__(self):\n self.content_type_supported = []\n\n @staticmethod\n def _set_supported_content_type(self, content_types_supported):\n if not isinstance(content_types_supported, list):\n raise TypeError(\"Settings 'READTIME_CONTENT_SUPPORT' must be a list of content types.\")\n self.content_type_supported = content_types_supported\n\n# Example usage:\nsettings = Settings()\nsettings._set_supported_content_type([\"text/plain\", \"application/json\"])\n```"} +{"i": 418, "got": "```python\nclass LangSettings:\n def __init__(self, lang_settings):\n self.lang_settings = lang_settings\n\n def set_lang_settings(self, lang_settings):\n if isinstance(lang_settings, int) or isinstance(lang_settings, dict):\n is_int = isinstance(lang_settings, int)\n is_dict = isinstance(lang_settings, dict)\n\n if is_int:\n self.lang_settings['default']['wpm'] = lang_settings\n elif is_dict:\n for lang, conf in lang_settings.items():\n if 'wpm' not in conf:\n raise TypeError(\"Settings 'READTIME_WPM' must be either an int,or a dict with settings per language.\")\n if not isinstance(conf['wpm'], int):\n raise TypeError(\"WPM is not an integer for the language: {}\".format(lang))\n if 'singular' not in conf or 'plural' not in conf:\n raise KeyError(\"Missing singular form for '{}' for the language: {}\".format('minute', lang))\n if 'singular' not in conf or 'plural' not in conf:\n raise KeyError(\"Missing plural form for '{}' for the language: {}\".format('minutes', lang))\n if 'singular' not in conf or 'plural' not in conf:\n raise KeyError(\"Missing singular form for '{}' for the language: {}\".format('second', lang))\n if 'singular' not in conf or 'plural' not in conf:\n raise KeyError(\"Missing plural form for '{}' for the language: {}\".format('seconds', lang))\n\n self.lang_settings = lang_settings\n else:\n raise TypeError(\"Settings 'READTIME_WPM' must be either an int,or a dict with settings per language.\")\n```"} +{"i": 419, "got": "```python\nclass Module:\n def __init__(self):\n self.initialized = False\n self.settings_content_types = None\n self.lang_settings = None\n\n def initialize_settings(self, sender):\n pass\n\n def _set_supported_content_type(self, settings_content_types):\n pass\n\n def _set_lang_settings(self, lang_settings):\n pass\n```"} +{"i": 420, "got": "```python\nclass ReadTimeCalculator:\n def __init__(self, content):\n self.content = content\n\n @property\n def content_type_supported(self):\n return True\n\n @property\n def lang_settings(self):\n return {\n 'default': 'en',\n 'lang': 'en'\n }\n\n def get_class_name(self):\n return type(self).__name__\n\n def hasattr(self, obj, attr):\n return hasattr(obj, attr)\n\n def pluralize(self, num, lang_conf, singular, plural):\n if num == 1:\n return singular\n else:\n return plural\n\n def split(self, text):\n return text.split()\n\n def len(self, iterable):\n return len(iterable)\n\n def format(self, *args):\n return ''.join(args)\n```\n\nThis Python class `ReadTimeCalculator` implements the functionality described in the bytecode disassembly. The methods and properties correspond to the operations performed in the bytecode."} +{"i": 421, "got": "```python\ndef pluralize(self, measure, singular, plural):\n \"\"\"\n pass\n \"\"\"\n if measure == 1:\n return '{} {}'.format(measure, singular)\n else:\n return '{} {}'.format(measure, plural)\n```"} +{"i": 422, "got": "```python\nclass ListDatasources:\n def __init__(self, source_id):\n self.client = None\n self.get_url = None\n self.base = None\n\n def list_datasources(self, source_id):\n target_url = self.client.get_url('DATASOURCE', 'GET', 'multi', source_id)\n manager = self.base.Query(self.client, Datasource)\n return manager(target_url)\n```"} +{"i": 423, "got": "```python\nclass DataSource:\n def __init__(self, client):\n self.client = client\n\n def get_url(self, source_id, datasource_id):\n return f\"https://api.example.com/data/{source_id}/{datasource_id}\"\n\n def get_manager(self):\n return DatasourceManager()\n\n def _get(self, url):\n # Simulate fetching data from the URL\n return f\"Data fetched from {url}\"\n```"} +{"i": 424, "got": "```python\nclass open_store_variable:\n def __init__(self, name, var):\n self.data = getattr(var, 'ncattrs')()\n for a in var.dimensions():\n self.data[a] = getattr(var, a)\n self.data[var] = getattr(var, 'dimensions')\n```\n\nThis Python code snippet defines a class `open_store_variable` with an initializer that takes two parameters: `name` and `var`. The initializer retrieves the `ncattrs`, dimensions, and other attributes of the variable `var` and stores them in the instance variables `data`."} +{"i": 425, "got": "```python\nclass MyClass:\n def __init__(self, ds, ncattrs):\n self.ds = ds\n self.ncattrs = ncattrs\n\n def get_attrs(self):\n return {k: getattr(self.ds, k) for k in self.ncattrs}\n```\n\nThis Python code snippet is equivalent to the bytecode disassembly provided. It defines a class `MyClass` with an initializer that takes two parameters, `ds` and `ncattrs`. The `get_attrs` method returns a dictionary containing the attributes of `self.ds` that are specified in `ncattrs`."} +{"i": 426, "got": "```python\nclass MyClass:\n def get_dimensions(self):\n \"\"\"pass\"\"\"\n ds = self.ds\n dimensions = ds.dimensions\n for k, v in dimensions.items():\n yield (k, len(v))\n\n @staticmethod\n def get_dimensions_genexpr(ds, dimensions):\n for k, v in dimensions.items():\n yield (k, len(v))\n```"} +{"i": 427, "got": "```python\ndef _find_base_tds_url(catalog_url):\n \"\"\"pass\"\"\"\n url_components = urlparse(catalog_url)\n if url_components.path:\n return url_components.path.split('/')[0]\n else:\n return catalog_url\n```"} +{"i": 428, "got": "```python\ndef filter_time_nearest(self, time, regex):\n \"\"\"pass\"\"\"\n time_cell = self._get_datasets_with_times(time)\n return sorted(filter(lambda i: abs(i - time) < self.total_seconds, time_cell), key=lambda i: i)\n\nclass FilterTimeNearest:\n def __init__(self, total_seconds):\n self.total_seconds = total_seconds\n\n def _get_datasets_with_times(self, time):\n # This method should be implemented to return a list of datasets with times\n pass\n```"} +{"i": 429, "got": "```python\nclass Module:\n def __init__(self):\n self._get_datasets_with_times = None\n\n def filter_time_range(self, start, end, regex):\n \"\"\"pass\"\"\"\n datasets = self._get_datasets_with_times(start, end)\n for item in datasets:\n if start <= item[0] <= end and regex.match(item[1]):\n item.append(-1)\n return datasets\n```"} +{"i": 430, "got": "```python\ndef check_token(func):\n \"\"\"pass\"\"\"\n func = wraps(func)\n wrapper = func(*args, **kwargs)\n return wrapper\n\nclass InvalidToken(Exception):\n pass\n```"} +{"i": 431, "got": "```python\nclass Upload:\n def upload(self, remote_path, file_content, ondup, **kwargs):\n \"\"\"\n pass\n \"\"\"\n params = {'path': 'ondup', 'file': ('file', '', '')}\n files = {'file': (None, file_content, '')}\n url = 'https://c.pcs.baidu.com/rest/2.0/pcs/file'\n self._request('file', upload, url, params, files, **kwargs)\n```"} +{"i": 432, "got": "```python\nclass UploadTmpfile:\n def upload_tmpfile(self, file_content, **kwargs):\n \"\"\"\n pass\n \"\"\"\n params = {'type': 'tmpfile'}\n files = {'file': ('', file_content, '')}\n url = 'https://c.pcs.baidu.com/rest/2.0/pcs/file'\n self._request(url, params=params, files=files, **kwargs)\n```"} +{"i": 433, "got": "```python\ndef upload_superfile(self, remote_path, block_list, ondup, **kwargs):\n \"\"\"pass\"\"\"\n params = {'path': 'ondup'}\n data = json.dumps(block_list)\n self._request('file', createsuperfile, params=params, data=data, extra_params={'data': kwargs})\n```"} +{"i": 434, "got": "```python\ndef mkdir(self, remote_path, **kwargs):\n pass\n```"} +{"i": 435, "got": "```python\ndef meta(self, remote_path, **kwargs):\n \"\"\"pass\"\"\"\n params = {'path': remote_path}\n self._request('file', 'meta', extra_params=params, **kwargs)\n```\n\nThis Python function `meta` takes a `remote_path` and keyword arguments `**kwargs`. It constructs a dictionary `params` with the key `'path'` set to `remote_path`. Then, it calls the `_request` method of the instance with the arguments 'file', 'meta', `extra_params=params`, and `**kwargs`."} +{"i": 436, "got": "```python\nclass Module:\n def __init__(self):\n self._cookieFileName = None\n self._vid = None\n self.installations = []\n\n def login(self):\n import os\n\n if not os.path.exists(os.path.join(self._cookieFileName, 'exists')):\n with open(self._cookieFileName, 'r') as f:\n self._vid = f.read().strip()\n\n installations = self._get_installations()\n if installations[0]['giid'] is None:\n self._create_cookie()\n with open(self._cookieFileName, 'w') as f:\n f.write(self._vid)\n\n return None\n\n def _get_installations(self):\n # Implementation of _get_installations method\n pass\n\n def _create_cookie(self):\n # Implementation of _create_cookie method\n pass\n\n def remove(self):\n import os\n\n if self._cookieFileName is not None:\n os.remove(self._cookieFileName)\n```"} +{"i": 437, "got": "```python\nclass _get_installations:\n def __init__(self, self):\n pass\n\n def _get_installations(self):\n response = None\n urls = None\n requests = None\n base_url = None\n try:\n response = requests.get(urls.BASE_URLS + '/installations', headers={'Cookie': 'Accept', 'headers': ('application/json,text/javascript, */*; q=0.01')})\n if response.status_code == 200:\n self.installations = json.loads(response.text)\n else:\n raise RequestError(response.status_code, response.text)\n except RequestException as ex:\n raise RequestError(ex.status_code, ex.text)\n finally:\n try:\n _validate_response(response)\n except Exception as ex:\n raise RequestError(ex.status_code, ex.text)\n\ndef _validate_response(response):\n if response.status_code == 503:\n raise RequestError(response.status_code, response.text)\n```"} +{"i": 438, "got": "```python\nclass Module:\n def get_overview(self):\n \"\"\"pass\"\"\"\n response = None\n while True:\n requests.get(urls[self.overview], headers={'Accept': 'application/json, text/javascript, */*; q=0.01', 'Accept-Encoding': 'gzip, deflate', 'Content-Type': 'application/json', 'Cookie': self._giid})\n response = self.format(vid=self._vid)\n if _validate_response(response):\n return json.loads(response.text)\n\n def format(self, vid):\n return f'vid={vid}'\n\n def _validate_response(self, response):\n # Placeholder for validation logic\n return True\n\n urls = {}\n overview = 'example_overview'\n _giid = 'example_giid'\n _vid = 'example_vid'\n```"} +{"i": 439, "got": "```python\ndef set_smartplug_state(self, device_label, state):\n \"\"\"pass\"\"\"\n response = None\n\n while True:\n requests.post(urls[self.smartplug], headers={'Content-Type': 'application/json', 'Cookie': self._giid}, data=json.dumps({'deviceLabel': device_label, 'state': state}))\n _validate_response(response)\n break\n```"} +{"i": 440, "got": "```python\nclass Module:\n def __init__(self):\n self._giid = None\n self._vid = None\n\n def get_history(self, filters=None, pagesize=None, offset=None):\n response = None\n try:\n response = requests.get(urls[self._giid], headers={'Accept': 'application/json, text/javascript, */*; q=0.01', 'Cookie': self.format(self._vid)}, params={'offset': offset, 'pagesize': pagesize, 'notificationCategories': filters})\n _validate_response(response)\n response = json.loads(response.text)\n except requests.exceptions.RequestException as ex:\n raise RequestError(ex)\n return response\n\n def format(self, vid):\n # Implementation of the format method\n pass\n\n def _validate_response(self, response):\n # Implementation of the _validate_response method\n pass\n```"} +{"i": 441, "got": "```python\nclass Climate:\n def __init__(self, device_label):\n self.device_label = device_label\n\n def get_climate(self):\n response = None\n try:\n import requests\n from urls import climate\n from format import format\n from _giid import _giid\n from _validate_response import _validate_response\n from json import loads\n\n headers = {'Accept': 'application/json, text/javascript, */*; q=0.01'}\n params = {'vid': {}}\n headers.update({'deviceLabel': self.device_label})\n response = requests.get(urls.climate.format(self._giid), headers=headers, params=params)\n _validate_response(response)\n return loads(response.text)\n except requests.exceptions.RequestException as ex:\n raise RequestError(ex)\n except json.JSONDecodeError as ex:\n raise RequestError(ex)\n finally:\n del response\n```"} +{"i": 442, "got": "```python\nclass ContentType:\n def __init__(self, model):\n self.model = model\n\n @classmethod\n def get_for_model(cls, model):\n # Implementation of get_for_model method\n pass\n\n def id(self):\n # Implementation of id method\n pass\n\ndef type_id(self):\n \"\"\"pass\"\"\"\n try:\n ContentType.objects.get_for_model(self.model, for_concrete_model=False).id\n except DatabaseError as e:\n raise DatabaseError(f\"Unable to fetch ContentType object, is a plugin being registered before the initial syncdb? (original error: {e})\")\n```"} +{"i": 443, "got": "```python\nclass Module:\n def __init__(self):\n self.get_output_cache_base_key = None\n self.cache_output_per_site = True\n self.cache_output_per_language = False\n self.cache_supported_language_codes = ['en', 'fr']\n self.format = lambda x, y: f\"{x}-{y}\"\n self.settings = {'SITE_ID': 1}\n\n def get_output_cache_key(self, placeholder_name, instance):\n self.get_output_cache_base_key = None\n cachekey = self.get_output_cache_base_key + self.format(placeholder_name, instance)\n if self.cache_output_per_site:\n cachekey += f\"-s{self.settings['SITE_ID']}\"\n elif self.cache_output_per_language:\n user_language = get_language()\n if user_language in self.cache_supported_language_codes:\n cachekey += f\".{user_language}\"\n else:\n cachekey += \"unsupported\"\n return cachekey\n```"} +{"i": 444, "got": "```python\nclass MyClass:\n def get_output_cache_keys(self, placeholder_name, instance):\n # pass\n\n def get_output_cache_keys_placeholder(self, placeholder_name, instance):\n base_key = self.get_output_cache_base_key(placeholder_name, instance)\n cachekeys = [base_key]\n if self.cache_output_per_site:\n site_ids = list(Site.objects.values_list('pk', flat=True))\n if settings.SITE_ID in site_ids:\n site_ids.append(settings.SITE_ID)\n cachekeys.extend(site_ids)\n return cachekeys\n\n def get_rendering_cache_key(self, placeholder_name, instance):\n base_key = self.get_output_cache_base_key(placeholder_name, instance)\n return f'{base_key}-s{settings.SITE_ID}'\n\n def format(self, base_key, user_language):\n return f'{base_key}-{user_language}'\n\n def get_placeholder_cache_key(self, placeholder):\n # Placeholder cache key logic\n pass\n\n def append(self, site_id):\n # Append logic\n pass\n\n def extend(self, total_list, item):\n # Extend logic\n pass\n\n def cache_output_per_site(self):\n # Cache output per site logic\n pass\n\n def render_ignore_item_language(self):\n # Render ignore item language logic\n pass\n\n def cache_supported_language_codes(self):\n # Cache supported language codes logic\n pass\n```"} +{"i": 445, "got": "```python\nclass MyClass:\n def __init__(self):\n self.cache = {}\n\n def get_output_cache_key(self, placeholder_name, instance):\n return f\"{placeholder_name}_{instance}\"\n\n def get(self, cachekey):\n return self.cache.get(cachekey)\n\n def get_cached_output(self, placeholder_name, instance):\n cachekey = self.get_output_cache_key(placeholder_name, instance)\n if cachekey in self.cache:\n return self.cache[cachekey]\n else:\n result = self.get(instance) # Assuming 'get' is a method that returns the output\n self.cache[cachekey] = result\n return result\n```"} +{"i": 446, "got": "```python\ndef set_cached_output(self, placeholder_name, instance, output):\n \"\"\"pass\"\"\"\n self.cachekey = get_output_cache_key(placeholder_name, instance)\n if self.cache_timeout:\n cache[self.cachekey] = output\n else:\n cache[self.cachekey] = output\n```\n\nIn this Python 3.12 bytecode disassembly, the original source code is provided in the docstring of the `set_cached_output` function."} +{"i": 447, "got": "```python\nclass Module:\n def __init__(self):\n pass\n\n def render(self, request, instance, **kwargs):\n \"\"\"pass\"\"\"\n render_template = self.get_render_template(request, instance)\n if render_template is not None:\n return render_template.format(instance.__class__.__name__)\n else:\n return \"No rendering defined for class '{}'\".format(instance.__class__.__name__)\n\n def get_render_template(self, request, instance):\n pass\n\n def get_context(self, request, instance):\n pass\n\n def render_to_string(self, request, template_name, context):\n pass\n```"} +{"i": 448, "got": "```python\ndef inline_requests(method_or_func):\n \"\"\"pass\"\"\"\n args = get_args(method_or_func)\n if not args:\n raise TypeError('Function must accept at least one argument.')\n \n wrapper = wraps(method_or_func)\n callback = create_bound_method(method_or_func, self)\n genwrapper = RequestGenerator(callback, response, **kwargs)\n return genwrapper\n\ndef inline_requests..wrapper(response, **kwargs):\n \"\"\"Decorating a non-method function will be deprecated\"\"\"\n warnings.warn('Decorating a non-method function will be deprecated', ScrapyDeprecationWarning, stacklevel=1)\n wrapper = wraps(method_or_func)\n callback = create_bound_method(method_or_func, self)\n genwrapper = RequestGenerator(callback, response, **kwargs)\n return genwrapper\n```"} +{"i": 449, "got": "```python\ndef get_args(method_or_func):\n \"\"\"pass\"\"\"\n args = list(inspect.signature(method_or_func).parameters.keys())\n return args\n```"} +{"i": 450, "got": "```python\ndef _unwindGenerator(self, generator, _prev):\n \"\"\"pass\"\"\"\n return generator\n\nclass Request:\n def __init__(self, callback=None, errback=None):\n self.callback = callback\n self.errback = errback\n\ndef warnings(self, message):\n print(message)\n\ndef _wrapRequest(self, ret, generator):\n yield 1\n```"} +{"i": 451, "got": "```python\ndef jwt_required(fn):\n \"\"\"\n pass\n \"\"\"\n closure = wraps(fn)\n wrapper = closure(*args, **kwargs)\n ctx_stack.top.jwt = _decode_jwt_from_headers()\n return fn(*args, **kwargs)\n\ndef _decode_jwt_from_headers():\n # Implementation of decoding JWT from headers\n pass\n```"} +{"i": 452, "got": "```python\ndef jwt_optional(fn):\n \"\"\"pass\"\"\"\n fn_cell = make_cell(fn)\n @wraps(fn)\n def wrapper(*args, **kwargs):\n jwt_data = _decode_jwt_from_headers()\n ctx_stack.top.jwt = jwt_data\n return fn(*args, **kwargs)\n wrapper.wrapper = closure\n return wrapper\n\ndef _decode_jwt_from_headers():\n # Implementation of _decode_jwt_from_headers function\n pass\n\nclass NoAuthorizationError(Exception):\n pass\n\nclass InvalidHeaderError(Exception):\n pass\n```"} +{"i": 453, "got": "```python\ndef decode_jwt(encoded_token):\n \"\"\"pass\"\"\"\n config = ...\n secret = config.decode_key\n algorithm = config.algorithm\n audience = config.audience\n return jwt.decode(encoded_token, secret, algorithms=[algorithm], audience=audience)\n```"} +{"i": 454, "got": "```python\ndef init_app(self, app):\n \"\"\"\n pass\n \"\"\"\n hasattr(app, 'extensions')\n if hasattr(app, 'extensions'):\n extensions = {}\n extensions['flask-jwt-simple'] = None\n self.extensions = extensions\n else:\n self.extensions = app.extensions\n\n self._set_default_configuration_options(app)\n self._set_error_handler_callbacks(app)\n\n app.config['PROPAGATE_EXCEPTIONS'] = True\n```"} +{"i": 455, "got": "```python\nclass MyError(Exception):\n pass\n\ndef handle_no_auth_error(e):\n return str(e)\n\ndef handle_invalid_header_error(e):\n return str(e)\n\ndef handle_expired_error(e):\n return str(e)\n\ndef handle_invalid_token_error(e):\n return str(e)\n```\n\nThis Python code snippet defines a class `MyError` and four functions to handle different types of errors related to authentication, headers, and tokens. The functions simply convert the error object to a string using the `str()` function."} +{"i": 456, "got": "```python\ndef _set_default_configuration_options(app):\n \"\"\"pass\"\"\"\n app.config.JWT_HEADER_NAME = \"Authorization\"\n app.config.JWT_HEADER_TYPE = \"Bearer\"\n app.config.JWT_EXPIRES = datetime.timedelta(hours=1)\n app.config.JWT_ALGORITHM = \"HS256\"\n app.config.JWT_IDENTITY_CLAIM = \"sub\"\n app.config.JWT_DECODE_AUDIENCE = None\n app.config.JWT_SECRET_KEY = None\n app.config.JWT_PRIVATE_KEY = None\n app.config.JWT_PUBLIC_KEY = None\n```"} +{"i": 457, "got": "```python\ndef category(**kwargs):\n \"\"\"pass\"\"\"\n if 'series' in kwargs:\n path = kwargs['series']\n else:\n path = None\n\n Fred(category, path)\n```"} +{"i": 458, "got": "```python\ndef releases(release_id, **kwargs):\n \"\"\"\n pass\n \"\"\"\n if 'id' in kwargs:\n release_id = kwargs['release_id']\n Fred.release(release_id, **kwargs)\n```\n\nThis Python function `releases` takes a `release_id` and keyword arguments. It checks if the keyword argument `'id'` is present. If it is, it updates the `release_id`. Then, it calls the `release` method of the `Fred` object with the updated `release_id` and any additional keyword arguments."} +{"i": 459, "got": "```python\ndef series(identifier, **kwargs):\n \"\"\"\n pass\n \"\"\"\n if identifier:\n setattr(self, 'series_id', identifier)\n if 'release' in kwargs:\n setattr(self, 'release', kwargs['release'])\n elif 'releases' in kwargs:\n setattr(self, 'releases', kwargs['releases'])\n else:\n setattr(self, 'path', None)\n Fred(series_id=self.series_id, releases=self.releases, **kwargs)\n```"} +{"i": 460, "got": "```python\ndef source(source_id, **kwargs):\n \"\"\"\n pass\n \"\"\"\n if source_id is not None:\n kwargs['source_id'] = source_id\n if 'id' in kwargs:\n kwargs['id'] = Fred(kwargs['id'])\n path = kwargs.get('releases', None)\n if path is None:\n path = None\n Fred(source_id, path, **kwargs)\n```"} +{"i": 461, "got": "```python\ndef sources(source_id, **kwargs):\n \"\"\"pass\"\"\"\n if source_id in kwargs:\n return globals()[source](source_id, **kwargs)\n else:\n return globals()['Fred'](source_id, **kwargs)\n```"} +{"i": 462, "got": "```python\ndef _create_path(self, *args):\n \"\"\"pass\"\"\"\n path = self.endpoint + '/' + '/'.join(args)\n return path\n```"} +{"i": 463, "got": "```python\nclass item_extra_kwargs:\n def __init__(self, self, item):\n # pass\n use_feed_image = True\n if use_feed_image:\n self.feed_image = item.feed_image\n if self.feed_image.file.url:\n image_complete_url = urljoin(self, get_site_url())\n content_field = getattr(item, 'item_content_field')\n content = expand_db_html(content_field)\n soup = BeautifulSoup(content, 'html.parser')\n fields_to_add = {'image': image_complete_url}\n if use_feed_image:\n fields_to_add['image'] = image_complete_url\n return fields_to_add\n else:\n return {}\n else:\n return {}\n\n def __html__(self):\n # pass\n content_field = getattr(self, 'content_field')\n content = expand_db_html(content_field)\n soup = BeautifulSoup(content, 'html.parser')\n fields_to_add = {'image': ''}\n if use_feed_image:\n fields_to_add['image'] = ''\n return fields_to_add\n\n def prettify(self):\n # pass\n content_field = getattr(self, 'content_field')\n content = expand_db_html(content_field)\n soup = BeautifulSoup(content, 'html.parser')\n fields_to_add = {'image': ''}\n if use_feed_image:\n fields_to_add['image'] = ''\n return fields_to_add\n\n def has_attr(self, self, attr):\n # pass\n return True\n\n def find_all(self, self, tag, attrs=None):\n # pass\n return []\n\n def get_site_url(self):\n # pass\n return ''\n\n def expand_db_html(self, content_field):\n # pass\n return ''\n```"} +{"i": 464, "got": "```python\ndef treenav_undefined_url(request, item_slug):\n \"\"\"\n pass\n \"\"\"\n item = get_object_or_404(treenav.MenuItem, slug=item_slug)\n raise Http404()\n```"} +{"i": 465, "got": "```python\ndef treenav_save_other_object_handler(sender, instance, created, **kwargs):\n \"\"\"\n pass\n \"\"\"\n cache_key = f\"treenav_menu_models_{sender.__name__}\"\n menu_models = cache.get(cache_key)\n \n if not menu_models:\n ContentType = models.ContentType\n MenuItem = models.MenuItem\n \n cache.delete(cache_key)\n \n menu_models = [\n MenuItem(content_type=ContentType.objects.get_for_model(sender), model_class=sender, exclude=True)\n for _ in range(10) # Example number of items\n ]\n \n cache.set(cache_key, menu_models)\n\n if sender not in menu_models:\n ContentType = models.ContentType\n MenuItem = models.MenuItem\n \n ct = ContentType.objects.get_for_model(sender)\n items = MenuItem.objects.filter(content_type=ct, instance=instance.pk)\n \n for item in items:\n item.href = instance.get_absolute_url()\n item.save()\n\n return None\n```"} +{"i": 466, "got": "```python\nclass MenuItem:\n def __init__(self, objects):\n self.objects = objects\n\n def save(self):\n pass\n\ndef refresh_hrefs(self, request):\n treenav = None # Assuming treenav is defined elsewhere\n MenuItem.objects.all().save() # Assuming MenuItem.objects.all() returns a queryset of MenuItem instances\n self.message_user(request, 'Menu item HREFs refreshed successfully.')\n self.model._meta.app_label = self.__class__.__name__\n info = (self.__class__.__name__, self.model._meta.model_name)\n changelist_url = reverse('admin:%s_%s_changelist' % info, current_app=self.admin_site.name)\n return redirect(changelist_url)\n```"} +{"i": 467, "got": "```python\ndef clean_cache(self, request):\n \"\"\"\n pass\n \"\"\"\n treenav.delete_cache()\n self.message_user(request, 'Cache menuitem cache cleaned successfully.')\n info = (self.model._meta.app_label, self.model.__name__)\n changelist_url = reverse('admin:%s_%s_changelist' % info)\n return redirect(changelist_url)\n```"} +{"i": 468, "got": "```python\nclass MenuTreeRebuilder:\n def rebuild_tree(self, request):\n \"\"\"\n pass\n \"\"\"\n self.model.objects.rebuild()\n self.message_user(request, _('Menu Tree Rebuilt.'))\n self.clean_cache(request)\n```\n\nThis Python code snippet defines a class `MenuTreeRebuilder` with a method `rebuild_tree`. The method takes a `request` object as an argument and performs the following actions:\n1. Calls the `rebuild` method on the `objects` attribute of the `model`.\n2. Calls the `message_user` method to display a message to the user.\n3. Calls the `clean_cache` method to clear any cached data related to the menu tree.\n\nThe `message_user` and `clean_cache` methods are assumed to be defined elsewhere in the codebase, as they are not provided in the given bytecode disassembly."} +{"i": 469, "got": "```python\nclass MenuItemAdmin:\n def save_related(self, request, form, formsets, change):\n # pass\n super(MenuItemAdmin, self).save_related(request, form, formsets, change)\n self.model.objects.rebuild()\n```\n\nThis Python 3.12 bytecode disassembly corresponds to the following source code:\n\n```python\nclass MenuItemAdmin:\n def save_related(self, request, form, formsets, change):\n # pass\n super(MenuItemAdmin, self).save_related(request, form, formsets, change)\n self.model.objects.rebuild()\n```\n\nThe `MenuItemAdmin` class has a method `save_related` that takes in several parameters and performs some operations. The first operation is to call the superclass's `save_related` method using `super(MenuItemAdmin, self).save_related(request, form, formsets, change)`. Then, it calls the `rebuild` method on the model associated with the admin class using `self.model.objects.rebuild()`."} +{"i": 470, "got": "```python\ndef _calculate_dispersion(X, labels, centroids):\n \"\"\"\n pass\n \"\"\"\n import numpy as np\n\n def calculate_dispersion(X, labels, centroids):\n disp = []\n for inst, label in zip(X, labels):\n disp.append(np.abs(inst - centroids[label])**2)\n return disp\n```"} +{"i": 471, "got": "```python\nimport numpy as np\n\ndef _calculate_gap(self, X, n_refs, n_clusters):\n ref_dispersions = np.zeros(n_refs)\n for i in range(n_refs):\n random_data = np.random.sample(X.shape[0], size=n_refs)\n centroids, labels = kmeans2(random_data, n_clusters, iter=10, minit='points')\n dispersion = self._calculate_dispersion(X, labels, centroids)\n ref_dispersions[i] = dispersion\n gap_value = np.mean(np.log(ref_dispersions) - np.log(dispersion))\n return int(n_clusters), gap_value\n```"} +{"i": 472, "got": "```python\ndef _process_with_rust(self, X, n_refs, cluster_array):\n \"\"\"pass\"\"\"\n yield from gap_statistic.rust.optimal_k(X, list(cluster_array))\n```\n\nThis Python function `_process_with_rust` takes three parameters: `self`, `X`, and `cluster_array`. It uses the `gap_statistic.rust.optimal_k` function to compute optimal k values for a given dataset `X` and cluster array. The function yields these optimal k values as a generator."} +{"i": 473, "got": "```python\nimport pandas as pd\nimport numpy as np\n\ndef _process_with_joblib(self, X, n_refs, cluster_array):\n parallel = Parallel(n_jobs=self.n_jobs)\n gap_value, n_clusters = next(parallel(_calculate_gap(X, n_refs, n_clusters) for _ in range(len(cluster_array))))\n return gap_value, n_clusters\n\ndef _calculate_gap(X, n_refs, n_clusters):\n # Placeholder for the actual implementation of _calculate_gap\n pass\n```"} +{"i": 474, "got": "```python\nimport numpy as np\nfrom multiprocessing import PoolExecutor\n\ndef _process_with_multiprocessing(self, X, n_refs, cluster_array):\n with PoolExecutor(max_workers=self.n_jobs) as executor:\n jobs = []\n for k in range(n_clusters):\n future = executor.submit(self._calculate_gap, X, n_refs, k)\n jobs.append(future)\n\n results = [future.result() for future in as_completed(jobs)]\n return results\n\ndef _calculate_gap(X, n_refs, k):\n # Implementation of _calculate_gap function\n pass\n```"} +{"i": 475, "got": "```python\ndef _process_non_parallel(self, X, n_refs, cluster_array):\n \"\"\"pass\"\"\"\n yield from self._calculate_gap(X, n_refs, n_clusters)\n```\n\nThis Python function `_process_non_parallel` takes three parameters: `self`, `X`, and `n_refs`. It appears to be a generator function that calculates some gap values based on the input data. The function uses a loop to iterate over the `cluster_array`, calculating the gap value for each element and yielding it."} +{"i": 476, "got": "```python\nclass MyClass:\n def __init__(self, table, where):\n self.table = table\n self.where = where\n\n def get_last_batch_number(self):\n # Implementation of get_last_batch_number method\n pass\n\n def order_by(self, column, direction):\n # Implementation of order_by method\n pass\n\n def get(self):\n # Implementation of get method\n pass\n\n def get_last(self):\n return self.get_last_batch_number() + 1\n```"} +{"i": 477, "got": "```python\nclass Database:\n def compile_insert(self, query, values):\n \"\"\"\n pass\n \"\"\"\n self.table = self.wrap_table(query.from__)\n self.columns = self.columnize(values[0])\n self.parameters = self.parameterize(values)\n value = '(%s)' % self.parameters[0]\n parameters = ', '.join([value] * len(values))\n return f\"INSERT INTO {self.table} ({', '.join(self.columns)}) VALUES {parameters}\"\n```"} +{"i": 478, "got": "```python\nclass AlterTableSql:\n def __init__(self, diff):\n self.diff = diff\n\n def get_alter_table_sql(self):\n sql = []\n for column_diff in self.diff.changed_columns:\n if not column_diff.is_unchanged_binary_column():\n old_column_name = column_diff.old_column_name\n column = column_diff.column\n query = f\"ALTER TABLE {self.diff.name} \"\n if column_diff.has_changed('type'):\n query += f\"TYPE {self.get_sql_type_declaration(column)} \"\n if column_diff.has_changed('precision'):\n query += f\"PRECISION {column.precision} \"\n if column_diff.has_changed('scale'):\n query += f\"SCALE {column.scale} \"\n if column_diff.has_changed('fixed'):\n query += \"FIXED \"\n sql.append(query)\n if column_diff.has_changed('default'):\n default_clause = None\n if column_diff.has_changed('type'):\n default_clause = self.get_default_value_declaration_sql(column)\n elif column_diff.has_changed('notnull'):\n default_clause = 'NOT NULL'\n elif column_diff.has_changed('autoincrement'):\n seq_name = self.get_identity_sequence_name(self.diff, old_column_name)\n query = f\"ALTER TABLE {self.diff.name} \"\n query += f\"CREATE SEQUENCE {seq_name} \"\n query += f\"SELECT setval('{seq_name}', (SELECT MAX({old_column_name}) FROM {self.diff.name}))\"\n query += f\"ALTER TABLE {self.diff.name} SET DEFAULT nextval('{seq_name}')\"\n elif column_diff.has_changed('length'):\n query = f\"ALTER TABLE {self.diff.name} TYPE {self.get_sql_type_declaration(column)} \"\n sql.append(query)\n if column_diff.has_changed('rename'):\n old_column_name = column_diff.old_column_name\n column = column_diff.column\n query = f\"ALTER TABLE {self.diff.name} RENAME COLUMN {old_column_name} TO {column}\"\n sql.append(query)\n return sql\n\n def get_sql_type_declaration(self, column):\n # Implement the logic to get SQL type declaration based on the column attributes\n pass\n\n def is_unchanged_binary_column(self):\n # Implement the logic to check if a binary column has not changed\n pass\n\n def has_changed(self, attribute):\n # Implement the logic to check if a specific attribute of the column has changed\n pass\n\n def get_default(self):\n # Implement the logic to get the default value of the column\n pass\n\n def get_notnull(self):\n # Implement the logic to get the not null status of the column\n pass\n\n def get_autoincrement(self):\n # Implement the logic to get the auto increment status of the column\n pass\n\n def get_identity_sequence_name(self, diff, old_column_name):\n # Implement the logic to get the identity sequence name for a column\n pass\n\n def get_name(self):\n # Implement the logic to get the name of the column\n pass\n```"} +{"i": 479, "got": "```python\nclass _date_based_where:\n def __init__(self, type, query, where):\n self.value = None\n self.parameter = None\n self.wrap = None\n\n def __str__(self):\n return f\"strftime('{type}', {self.where['column']}) {self.where['operator']} {self.value}\"\n```"} +{"i": 480, "got": "```python\nclass MySqlQueryGrammar:\n def compile_select(self, query):\n \"\"\"\n pass\n \"\"\"\n super().compile_select(query)\n sql = query.unions\n if sql:\n sql = '(' + str(sql) + ') '\n sql += self._compile_unions(query)\n return sql\n```"} +{"i": 481, "got": "```python\ndef _compile_lock(self, query, value):\n \"\"\"pass\"\"\"\n if isinstance(value, basestring):\n return True\n elif value is True:\n return 'FOR UPDATE'\n elif value is False:\n return 'LOCK IN SHARE MODE'\n else:\n return None\n```"} +{"i": 482, "got": "```python\ndef plot_best_worst_fits(assignments_df, data, modality_col, score):\n \"\"\"\n pass\n \"\"\"\n ncols = 2\n nrows = len(assignments_df.groupby(modality_col).groups)\n fig, axes = plt.subplots(nrows=nrows, ncols=ncols, figsize=(nrows*4, ncols*6))\n \n fits = ['Highest', 'Lowest']\n for modality, df in assignments_df.groupby(modality_col):\n df = df.sort_values(score)\n color = MODALITY_TO_COLOR[modality]\n \n ids = df['Feature ID'][-10:]\n fit_psi = data[ids].stack().reset_index()\n tidy_fit_psi = fit_psi.rename(columns={'level_0': 'Sample ID', 'level_1': 'Feature ID', '$\\\\Psi$': 'Value'})\n \n if not tidy_fit_psi.empty:\n ax = axes.flat[next(iter(axes.flat))]\n sns.violinplot(x='Feature ID', y='$\\\\Psi$', data=tidy_fit_psi, color=color, ax=ax)\n \n ax.set_title(f'{modality} {score}')\n ax.set_xticks([])\n \n ids = df['Feature ID'][:10]\n fit_psi = data[ids].stack().reset_index()\n tidy_fit_psi = fit_psi.rename(columns={'level_0': 'Sample ID', 'level_1': 'Feature ID', '$\\\\Psi$': 'Value'})\n \n if not tidy_fit_psi.empty:\n ax = axes.flat[next(iter(axes.flat))]\n sns.violinplot(x='Feature ID', y='$\\\\Psi$', data=tidy_fit_psi, color=color, ax=ax)\n \n ax.set_title(f'{modality} {score}')\n ax.set_xticks([])\n \n sns.despine(fig=fig)\n fig.tight_layout()\n return None\n```"} +{"i": 483, "got": "```python\ndef violinplot(x=None, y=None, data=None, bw=0.2, scale='area', inner=None, ax=None, **kwargs):\n \"\"\"\n pass\n \"\"\"\n if ax is None:\n ax = plt.gca()\n sns.violinplot(x=x, y=y, data=data, bw=bw, scale=scale, inner=inner, ax=ax, **kwargs)\n ax.set_ylim(0, 1)\n ax.set_yticks([0, 0.5, 1])\n```"} +{"i": 484, "got": "```python\ndef bar(self, counts, phenotype_to_color, ax, percentages):\n \"\"\"\n pass\n \"\"\"\n if percentages:\n total = sum(counts)\n counts = [count / total for count in counts]\n \n width = full_width = 0.8\n \n for i, group in enumerate(counts):\n left = width * i + full_width / 2\n ax.bar(left, group, width=width, color=phenotype_to_color[group], label=f\"Modality {i+1}\")\n \n if percentages:\n ylabel = 'Percentage of events'\n else:\n ylabel = 'Number of events'\n \n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)))\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()\n \n return None\n```"} +{"i": 485, "got": "```python\nclass _ModelLoglikPlotter:\n def __init__(self):\n pass\n\n def plot(self, event, logliks, logsumexps, self, modality_to_color, renamed):\n pass\n```"} +{"i": 486, "got": "```python\nclass Predict:\n def __init__(self, fitted):\n self.fitted = fitted\n\n def predict(self, fitted):\n if fitted.shape != len(self.modalities):\n raise ValueError(\"This data doesn't look like it had the distance between it and the five modalities calculated\")\n return fitted.idxmin()\n```"} +{"i": 487, "got": "```python\nclass Logliks:\n def __init__(self, self):\n pass\n\n def logliks(self, x):\n \"\"\"\n pass\n \"\"\"\n prob = copy.deepcopy(x)\n very_small_number = VERY_SMALL_NUMBER\n np.array(zip(prob_parameters, rvs))\n rv = None\n prob = None\n rv = None\n return sum(np.log(log(prob)) + np.log(pdf(x)) for x in zip(prob_parameters, rvs))\n```"} +{"i": 488, "got": "```python\ndef get_next_value(sequence_name, initial_value, reset_value, *, nowait=False, using=None):\n from models import Sequence\n\n connection = getattr(router, db_for_write)\n cursor = connection.cursor()\n\n if reset_value is not None:\n cursor.execute(UPSERT_QUERY, (sequence_name, initial_value))\n last = cursor.fetchone()[0]\n else:\n cursor.execute(SELECT_FOR_UPDATE, (nowait,))\n last = cursor.fetchone()[0]\n\n sequence.objects.get_or_create(name=sequence_name, defaults={'last': last})\n created = True\n\n if reset_value is not None:\n cursor.execute(SAVE, (sequence_name, initial_value))\n else:\n cursor.execute(SAVE, (sequence_name, last))\n\n return last\n```"} +{"i": 489, "got": "```python\ndef check(self, final_line_count):\n \"\"\"pass\"\"\"\n self._lines_seen['version']\n self._process_version_lines()\n self._process_plan_lines(final_line_count)\n```\n\nThis Python function `check` takes an instance of a class and a final line count as arguments. It first accesses the 'version' attribute from `_lines_seen`, then calls `_process_version_lines` to process version lines, and finally calls `_process_plan_lines` with the provided final line count."} +{"i": 490, "got": "```python\ndef _process_version_lines(self):\n \"\"\"pass\"\"\"\n if len(self._lines_seen) > 1:\n self._add_error(\"Multiple version lines appeared.\")\n elif self._lines_seen.get('version') != '0.1':\n self._add_error(\"The version must be on the first line.\")\n```"} +{"i": 491, "got": "```python\nclass MyClass:\n def __init__(self):\n self._lines_seen = {}\n self._add_error = lambda message: print(message)\n self._plan_on_valid_line = lambda at_line, final_line_count: print(f\"Plan on line {at_line} is valid for the file with {final_line_count} lines.\")\n self._expected_tests = 1\n self._lines_seen['plan'] = 0\n\n def _process_plan_lines(self, final_line_count):\n if 'plan' not in self._lines_seen:\n self._add_error(\"Missing a plan.\")\n return None\n if len(self._lines_seen['plan']) != 1:\n self._add_error(\"Only one plan line is permitted per file.\")\n return None\n at_line = list(self._lines_seen['plan'])[0]\n self._plan_on_valid_line(at_line, final_line_count)\n expected_tests = self._expected_tests\n lines_seen = self._lines_seen['plan']\n if 'test' not in lines_seen:\n self._add_error(\"A plan must appear at the beginning or end of the file.\")\n return None\n seen_tests = lines_seen['test']\n if expected_tests != seen_tests:\n self._add_error(f\"Expected {expected_count} tests but only {seen_count} ran.\")\n return None\n return None\n```"} +{"i": 492, "got": "```python\nclass _plan_on_valid_line:\n def __init__(self, at_line, final_line_count):\n self._lines_seen = {'version': '1', 'version': '0'}\n if at_line == 1 and at_line == final_line_count:\n return True\n elif at_line == 2:\n after_version = self._lines_seen['version']\n if after_version == '1' or after_version == '0':\n return True\n else:\n return False\n```"} +{"i": 493, "got": "```python\nclass MyClass:\n def handle_bail(self, bail):\n \"\"\"pass\"\"\"\n self._add_error(f\"Bailed: {bail.reason}\")\n self.format(bail)\n```\n\nIn this Python code, the bytecode disassembly represents a class `MyClass` with a method `handle_bail`. The method takes an argument `bail`, prints a message indicating that the operation has been bailed, and then formats the bail object."} +{"i": 494, "got": "```python\nclass Result:\n pass\n\ndef handle_skipping_plan(self, skip_plan):\n \"\"\"\n pass\n \"\"\"\n directive = skip_plan.directive\n text = skip_plan.text\n skip_line = directive.text\n self._suite.addTest(Adapter(self._filename, skip_line))\n```"} +{"i": 495, "got": "```python\ndef mptt_before_insert(mapper, connection, instance):\n \"\"\"\n pass\n \"\"\"\n table = _get_tree_table(mapper)\n db_pk = getattr(instance, get_pk_column(mapper))\n table_pk = getattr(table, 'c', {}).get('name')\n tree_id = getattr(instance, 'parent_id', None)\n\n if tree_id is not None:\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.scalar(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n tree_id = parent_pos_right + 1\n\n left = instance.left\n right = instance.right\n level = getattr(instance, 'get_default_level', 0)\n connection.execute(select(func.max(table.c.tree_id)).where(table.c.c.name == table_pk))\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.fetchone()\n"} +{"i": 496, "got": "```python\ndef mptt_before_update(mapper, connection, instance):\n node_id = getattr(instance, get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = get_pk_column(instance)\n default_level = get_default_level(instance)\n table_pk = getattr(table, 'c', None)\n mptt_move_inside = getattr(instance, 'mptt_move_inside', None)\n left_sibling = getattr(instance, 'mptt_move_before', None)\n\n if mptt_move_inside is not None:\n return\n\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = _get_tree_nodes(mapper, instance, default_level)\n\n if hasattr(instance, 'mptt_move_after'):\n return\n\n subtree = _get_subtree(mapper, connection, node_id)\n left_sibling_tree_id = getattr(left_sibling, 'tree_id', None)\n\n if left_sibling_tree_id is not None:\n return\n\n mptt_before_delete(mapper, connection, instance, False)\n\n parent_id = getattr(instance, 'parent_id', None)\n if parent_id is not None:\n subtree = _get_subtree(mapper, connection, parent_id)\n parent_pos_right = getattr(subtree, 'right_sibling_left', None)\n parent_pos_left = getattr(subtree, 'left_sibling_right', None)\n parent_tree_id = getattr(subtree, 'tree_id', None)\n parent_level = getattr(subtree, 'level', None)\n\n if parent_tree_id is not None:\n return\n\n node_size = right_sibling_right - right_sibling_left + 1\n left_sibling = _get_tree_node(mapper, connection, left_sibling_tree_id, default_level)\n\n if left_sibling is not None:\n return\n\n tree_id = getattr(instance, 'tree_id', None)\n _insert_subtree(table, connection, node_size, right_sibling_left, right_sibling_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling)\n\n mptt_before_delete(mapper, connection, instance, False)\n\n tree_id = getattr(instance, 'tree_id', None)\n _insert_subtree(table, connection, 1, right_sibling_left, right_sibling_right, None, None, subtree, tree_id, default_level, node_level, left_sibling)\n```"} +{"i": 497, "got": "```python\nclass MyClass:\n def __init__(self):\n self.instances = {}\n self.session = None\n\n def after_flush_postexec(self, session, context):\n pass\n\n def get_parent_value(self, instance):\n return None\n\n def discard(self, parent):\n pass\n\n def expire(self, parent):\n pass\n\n def expire_session_for_children(self, session, instance):\n pass\n```"} +{"i": 498, "got": "```python\ndef is_ancestor_of(self, other, inclusive):\n \"\"\"\n pass\n \"\"\"\n if inclusive:\n return self.tree_id == other.tree_id and (self.left <= other.left and self.right >= other.right)\n else:\n return self.tree_id == other.tree_id and (self.left < other.left or self.right > other.right)\n```"} +{"i": 499, "got": "```python\nclass Session:\n def __init__(self):\n pass\n\n def add(self, obj):\n pass\n\ndef move_inside(self, parent_id):\n \"\"\"\n pass\n \"\"\"\n session = self.session\n self.parent_id = parent_id\n self.mptt_move_inside = parent_id\n session.add(self)\n```"} +{"i": 500, "got": "```python\nclass Session:\n def __init__(self):\n pass\n\n def add(self, node_id):\n pass\n\ndef move_after(self, node_id):\n \"\"\"\n pass\n \"\"\"\n session = self.session\n self.parent_id = self.parent_id\n self.mptt_move_after = node_id\n session.add(node_id)\n```"} +{"i": 501, "got": "```python\nclass LBRYAPI:\n def __init__(self, request_id):\n self.request_id = request_id\n\n @staticmethod\n def make_request(cls, url, method, params, basic_auth, timeout):\n params = params or {}\n params['request_id'] = cls.request_id + 1\n data = {\n 'method': method,\n 'params': params,\n 'jsonrpc': '2.0',\n 'id': params.get('id', None)\n }\n headers = {\n 'Content-Type': 'application/json-rpc',\n 'user-agent': 'LBRY python3-api'\n }\n response = requests.post(url, data=json.dumps(data), headers=headers, auth=basic_auth, timeout=timeout)\n if response.status_code == 200:\n return response.json()\n else:\n raise LBRYUtils.LBRYException(f'POST Request made to LBRY received an error: {response.status_code}')\n\n def prepare(self):\n pass\n\n def send(self, prepared):\n pass\n\n def json(self):\n pass\n```"} +{"i": 502, "got": "```python\ndef adjust_status(info):\n \"\"\"\n pass\n \"\"\"\n modified_info = deepcopy(info)\n modified_info.update(get_nearest_by_numeric_key(status_map, int(info['level'])))\n modified_info.update(get_nearest_by_numeric_key(status_map, int(info['level2'])))\n return tuple(modified_info.items())\n```"} +{"i": 503, "got": "```python\nclass StatusByCoordinates:\n def __init__(self):\n self.raw_cdc_data = None\n self.nearest_by_coordinates = None\n\n async def status_by_coordinates(self, latitude, longitude):\n cdc_data = await self.raw_cdc_data\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n adjust_status(cdc_data, nearest)\n\ndef adjust_status(cdc_data, nearest):\n state = cdc_data['state']\n name = cdc_data['name']\n address = cdc_data['address']\n # Additional logic to adjust status based on latitude and longitude\n```"} +{"i": 504, "got": "```python\nclass state:\n def __init__(self):\n self.raw_cdc_data = None\n self.items = None\n\n @staticmethod\n def status_by_state(self, state):\n # pass\n gen = self.status_by_state_generator(state)\n for item in gen:\n yield item\n\n def status_by_state_generator(self, state):\n while True:\n raw_cdc_data = self.raw_cdc_data\n items = self.items\n if not (raw_cdc_data and items):\n break\n for k, v in items.items():\n if k in raw_cdc_data:\n yield v\n\n @staticmethod\n def adjust_status(info):\n # pass\n return info\n```"} +{"i": 505, "got": "```python\nclass insert:\n def __init__(self, self, **kwargs):\n pass\n\n def is_valid(self):\n return True\n\n def before_insert(self):\n pass\n\n def insert_one(self, self, _document):\n self._document['_id'] = None\n self.after_insert()\n\n def after_insert(self):\n pass\n\n @property\n def errors(self):\n return []\n```"} +{"i": 506, "got": "```python\nclass DocumentNotFoundError(Exception):\n def __init__(self, document):\n self.document = document\n\nclass UnidentifiedDocumentError(Exception):\n def __init__(self, document):\n self.document = document\n\ndef update(self, **kwargs):\n \"\"\"pass\"\"\"\n if not self.is_valid:\n raise DocumentNotFoundError('_id' in self._document)\n \n to_update = {k: v for k, v in kwargs.items() if k != '_id'}\n \n before = None\n if hasattr(self, 'before_update'):\n before = getattr(self, 'before_update')(to_update)\n \n if before is not None:\n return before\n \n self._document.update(to_update)\n \n after = None\n if hasattr(self, 'after_update'):\n after = getattr(self, 'after_update')(to_update)\n \n return after\n```"} +{"i": 507, "got": "```python\nclass Document:\n def __init__(self, _id=None, _document=None):\n self._id = _id\n self._document = _document\n\n def is_valid(self):\n return True\n\n def find_one(self, **kwargs):\n if '_id' in kwargs and self._id == kwargs['_id']:\n return {'_id': self._id, 'document': self._document}\n return None\n\n def before_delete(self):\n pass\n\n def delete_one(self):\n pass\n\n def after_delete(self):\n pass\n```"} +{"i": 508, "got": "```python\ndef find_one(cls, filter, *args, **kwargs):\n pass\n```"} +{"i": 509, "got": "```python\ndef find(cls, *args, **kwargs):\n pass\n```"} +{"i": 510, "got": "```python\nclass aggregate:\n def __init__(self, cls, pipeline, **kwargs):\n pass\n```"} +{"i": 511, "got": "```python\ndef fn():\n in_file = open('fn', 'r')\n for line in in_file:\n yield line.strip()\n\nin_file = lambda self, fn: (line.strip() for line in open(fn, 'r'))\n```"} +{"i": 512, "got": "```python\nclass FileLine:\n def __init__(self, line):\n self.line = line\n\nclass Statement:\n def __init__(self, location, start, filename):\n self.location = location\n self.start = start\n self.filename = filename\n\ndef at_line(self, line):\n num = line.num\n in_file = self.NULL | self.in_file\n for stmt in in_file:\n if stmt.location.start.line == num:\n yield 1\n```"} +{"i": 513, "got": "```python\nclass ParagraphWrapper:\n def __init__(self, width):\n self.width = width\n\n def wrap(self, text):\n # Placeholder for the actual wrapping logic\n return text\n\ndef wrap(text, width, **kwargs):\n \"\"\"pass\"\"\"\n w = ParagraphWrapper(width)\n return w.wrap(text)\n```"} +{"i": 514, "got": "```python\nclass ParagraphWrapper:\n def __init__(self, width):\n self.width = width\n\n def fill(self, text):\n return text\n```\n\nThis Python code defines a class `ParagraphWrapper` with an instance method `fill` that takes a string `text` and returns it as is. The `__init__` method initializes the `width` attribute of the class."} +{"i": 515, "got": "```python\ndef split(cls, text):\n \"\"\"pass\"\"\"\n cls.parasep_re = None\n result = []\n line = None\n\n for line in text.split():\n line = line.strip()\n if line:\n result.append(line)\n\n return result\n```"} +{"i": 516, "got": "```python\ndef wrap(self, text):\n \"\"\"pass\"\"\"\n lines = []\n linewrap = partial(textwrap.TextWrapper().wrap, self)\n para = split(text)\n for line in para:\n lines.extend(linewrap(line))\n lines.append('')\n lines[-1] = None\n return lines\n```"} +{"i": 517, "got": "```python\ndef getSenderNumberMgtURL(self, CorpNum, UserID):\n \"\"\"pass\"\"\"\n result = self._httpget('/FAX/?TG=SENDER', CorpNum, UserID)\n return result.url\n```"} +{"i": 518, "got": "```python\nclass UnitCost:\n def getUnitCost(self, CorpNum):\n \"\"\"\n pass\n \"\"\"\n self._httpget = None # Assuming _httpget is a method or attribute of the class\n result = self._httpget('/FAX/UnitCost', CorpNum)\n return int(result.unitCost)\n```"} +{"i": 519, "got": "```python\nclass FaxResult:\n def __init__(self, corp_num, receipt_num, user_id):\n self.corp_num = corp_num\n self.receipt_num = receipt_num\n self.user_id = user_id\n\n @staticmethod\n def get_fax_result(corp_num, receipt_num, user_id):\n # Simulate a HTTP GET request to fetch fax result\n if receipt_num != \"valid_receipt_number\":\n raise PopbillException(-99999999, \"\uc811\uc218\ubc88\ud638\uac00 \uc62c\ubc14\ub974\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.\")\n \n return FaxResult(corp_num, receipt_num, user_id)\n```"} +{"i": 520, "got": "```python\nclass PopbillException(Exception):\n def __init__(self, code, message):\n self.code = code\n self.message = message\n\ndef getFaxResultRN(self, CorpNum, RequestNum, UserID):\n \"\"\"\n pass\n \"\"\"\n if not RequestNum:\n raise PopbillException(-99999999, '\uc694\uccad\ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n url = f'/FAX/Get/{RequestNum}/{CorpNum}/{UserID}'\n return self._httpget(url)\n```"} +{"i": 521, "got": "```python\nclass FaxReceiver:\n def __init__(self, receiveNum, receiveName):\n self.receiveNum = receiveNum\n self.receiveName = receiveName\n\ndef sendFax(self, CorpNum, SenderNum, ReceiverNum, ReceiverName, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum):\n receivers = []\n receivers.append(FaxReceiver(ReceiverNum, ReceiverName))\n self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)\n```\n\nThis Python code defines a class `FaxReceiver` and a method `sendFax` that takes several parameters. The `sendFax` method creates an instance of `FaxReceiver`, appends it to the `receivers` list, and then calls another method `sendFax_multi` with the provided parameters."} +{"i": 522, "got": "```python\nclass PopbillException(Exception):\n def __init__(self, code, message):\n self.code = code\n self.message = message\n\nclass FaxReceiver:\n pass\n\nclass File:\n def __init__(self, name, fileData):\n self.name = name\n self.fileData = fileData\n\ndef _stringtify(data):\n return str(data)\n\ndef _httppost_files(url, postData, files, CorpNum, UserID):\n # Implementation of the HTTP POST files function\n pass\n\nclass sendFax_multi:\n def __init__(self, CorpNum, SenderNum, Receiver, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum):\n self.CorpNum = CorpNum\n self.SenderNum = SenderNum\n self.Receiver = Receiver\n self.FilePath = FilePath\n self.ReserveDT = ReserveDT\n self.UserID = UserID\n self.SenderName = SenderName\n self.adsYN = adsYN\n self.title = title\n self.RequestNum = RequestNum\n\n def sendFax(self):\n if not self.SenderNum:\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not self.Receiver:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n\n if not isinstance(self.Receiver, FaxReceiver) and not isinstance(self.Receiver, list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n \n if not self.FilePath:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not isinstance(self.FilePath, str) and not isinstance(self.FilePath, list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n\n if len(self.FilePath) < 1 or len(self.FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n\n if not isinstance(self.SenderNum, str):\n raise PopbillException(-99999999, \"'SenderNum' argument type error. String.\")\n \n if not isinstance(self.SenderName, str):\n raise PopbillException(-99999999, \"'SenderName' argument type error. String.\")\n\n postData = {\n 'snd': self.SenderNum,\n 'sndnm': self.SenderName,\n 'fCnt': len(self.FilePath),\n 'rcvs': self.Receiver,\n 'sndDT': self.ReserveDT,\n 'title': self.title,\n 'requestNum': self.RequestNum\n }\n\n files = [\n File('file', open(filePath, 'rb'))\n for filePath in self.FilePath\n ]\n\n result = _httppost_files('/FAX', postData, files, self.CorpNum, self.UserID)\n\n return result.receiptNum\n```"} +{"i": 523, "got": "```python\ndef model_node(**kwargs):\n \"\"\"pass\"\"\"\n kwargs = kwargs.copy()\n decorator = model_node.decorator(model)\n return decorator\n\nclass ModelType:\n pass\n```"} +{"i": 524, "got": "```python\nclass StatusByCoordinates:\n def __init__(self):\n self.nearest_by_coordinates = None\n\n def status_by_coordinates(self, latitude, longitude):\n while True:\n result = self.nearest_by_coordinates(latitude, longitude)\n if result is not None:\n return result\n yield 2\n```"} +{"i": 525, "got": "```python\ndef zip_code():\n status_by_zip = dict(status_by_zip=None)\n return None\n\ndef status_by_zip(self, zip_code):\n with self.user_reports:\n for location in self.status_by_coordinates(zip_code):\n latitude = float(location['latitude'])\n longitude = float(location['longitude'])\n yield 3\n yield 2\n raise StopIteration()\n\n@staticmethod\ndef status_by_coordinates(zip_code):\n # This is a placeholder for the actual implementation of status_by_coordinates\n return [{'zip': '12345'}]\n```"} +{"i": 526, "got": "```python\ndef print_request(request):\n \"\"\"pass\"\"\"\n print('{}\\n{}\\n{}\\n\\n{}'.format(\n '-----------START-----------',\n request.method,\n request.url,\n '\\n'\n ))\n for k, v in request.headers.items():\n print('{}: {}'.format(k, v))\n print(request.body)\n```"} +{"i": 527, "got": "```python\ndef filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n get_response = get_response.__closure__[0]\n _convert_params = _convert_params.__closure__[0]\n request_schema = request_schema.__closure__[0]\n\n def _convert_params(schema, data):\n for sc in schema.fields:\n if sc.serialized_name is not None:\n continue\n name = getattr(sc, 'name')\n val = getattr(data, name)\n if val is not None:\n break\n else:\n return None\n\n if hasattr(request_schema, 'body'):\n val = deepcopy(val)\n setattr(data, 'body', val)\n\n if hasattr(request_schema, 'params'):\n val = deepcopy(val)\n setattr(data, 'params', val)\n\n def decorated_filter(request, *args, **kwargs):\n data = CIDict(request.headers, request.app.router.get(request), RequestParameters(request.args))\n model = None\n try:\n model = request_schema.body if hasattr(request_schema, 'body') else request_schema.params\n request.validated = request_schema.validate(model)\n request.validated = request_schema.to_native(request.validated)\n except BaseError as e:\n model = None\n e = ValidationErrors(e, request_schema.to_primitive(e))\n raise e\n finally:\n get_response(request, args, kwargs)\n\n return decorated_filter\n```"} +{"i": 528, "got": "```python\ndef filter_validate_response(get_response, params):\n \"\"\"pass\"\"\"\n get_response = get_response.__closure__[0]\n schema = get_response.__closure__[1]\n\n def decorated_filter(request, *args, **kwargs):\n copy_free_vars(2)\n yield from get_response(request, *args, **kwargs)\n\n return decorated_filter\n\ndef filter_validate_response(params):\n \"\"\"pass\"\"\"\n get_response = params.get('get')\n schema = params.get('schema')\n\n def decorated_filter(request, *args, **kwargs):\n copy_free_vars(2)\n yield from get_response(request, *args, **kwargs)\n\n return decorated_filter\n```"} +{"i": 529, "got": "```python\ndef _write_int(fname, data, append):\n \"\"\"pass\"\"\"\n pexdoc.exh(NULL|self + addex)\n ValueError('There is no data to save to file')\n fos_ex = OSError('File *[fname]* could not be created: *[reason]*')\n pmisc.make_dir(fname)\n if append:\n mode = 'w'\n else:\n mode = 'a'\n sys.hexversion < 50331648 and (file_handle := open(fname, mode)) or (file_handle := open(fname, mode, newline=''))\n csv.writer(file_handle).writerows(data)\n file_handle.close()\n```"} +{"i": 530, "got": "```python\ndef revdocs2reverts(rev_docs, radius, use_sha1, resort, verbose):\n \"\"\"pass\"\"\"\n page_rev_docs = groupby(rev_docs, lambda rd: (rd['page'], rd['timestamp']))\n for page_doc, rev_docs in page_rev_docs:\n if verbose:\n sys.stderr.write(f\"(sorting) {page_doc[0]}: '{page_doc[1]}' field not found in {page_doc[0]}\\n\")\n detector = Detector(radius)\n checksum = None\n if use_sha1:\n text_bytes = bytes(rd['text'], 'utf8').replace(b'text', b'')\n checksum = hashlib.sha1(text_bytes).digest()\n revert = detector.process(checksum, rd)\n yield revert\n\ndef revdocs2reverts..(rd):\n return rd.get('page')\n\ndef revdocs2reverts..(r):\n return (r['timestamp'], r['id'])\n```"} +{"i": 531, "got": "```python\ndef dsort(fname, order, has_header, frow, ofname):\n \"\"\"\n pass\n \"\"\"\n obj = CsvFile(fname, has_header, frow)\n obj.dsort(order)\n obj.write(ofname, header=False)\n```\n\nIn this Python 3.12 bytecode disassembly, the original source code is provided in the docstring and the function body."} +{"i": 532, "got": "```python\ndef main():\n pass\n\n@asyncio.coroutine\nasync def client_session():\n logging.basicConfig(level=logging.INFO)\n websession = ClientSession()\n await websession.get(None)\n\n@asyncio.coroutine\nasync def status_by_coordinates(latitude, longitude):\n logging.info('User data by latitude/longitude (%s, %s): %s', latitude, longitude, await websession.get(None))\n\n@asyncio.coroutine\nasync def status_by_zip(zip_code):\n logging.info('User data by ZIP code (%s): %s', zip_code, await websession.get(None))\n\n@asyncio.coroutine\nasync def status_by_coordinates(latitude, longitude):\n logging.info('CDC data by latitude/longitude (%s, %s): %s', latitude, longitude, await websession.get(None))\n\n@asyncio.coroutine\nasync def status_by_state(state):\n logging.info('CDC data by state name (%s): %s', state, await websession.get(None))\n```"} +{"i": 533, "got": "```python\ndef call(cls, method, params, timeout):\n \"\"\"pass\"\"\"\n if params is not None:\n params = []\n cls.make_request(SERVER_ADDRESS, method, params, timeout)\n```\n\nThis Python function `call` takes four parameters: `cls`, `method`, `params`, and `timeout`. It first checks if the `params` parameter is not `None`. If it's not `None`, it initializes an empty list. Then, it calls the `make_request` method of the class `cls` with the server address, method, parameters, and timeout as arguments."} +{"i": 534, "got": "```python\ndef concatenate(fname1, fname2, dfilter1, dfilter2, has_header1, has_header2, frow1, frow2, ofname, ocols):\n \"\"\"\n pass\n \"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n\n obj1 = CsvFile(fname1, dfilter1, has_header1, frow1)\n obj2 = CsvFile(fname2, dfilter2, has_header2, frow2)\n\n if ofname is not None:\n ofname = ofname\n else:\n ofname = fname1\n\n ocols = ocols or [obj1.cfilter[0], obj2.cfilter[0]]\n\n if has_header1:\n obj1.header()\n if has_header2:\n obj2.header()\n\n data = obj1.data(filtered=True) + obj2.data(filtered=True)\n\n write(ofname, data, append=False)\n```"} +{"i": 535, "got": "```python\ndef GET(self, uri, methods, host, strict_slashes, stream, version, name, **kwargs):\n pass\n\nclass resource:\n def __init__(self, uri, methods, host, strict_slashes, stream, version, name, **kwargs):\n self.resources = {}\n self.resources[uri] = FutureRoute(handler)\n\n @staticmethod\n def decorator(handler):\n return handler\n```"} +{"i": 536, "got": "```python\ndef add_resource(self, handler, uri, methods, host, strict_slashes, version, name, **kwargs):\n pass\n```"} +{"i": 537, "got": "```python\ndef fn():\n in_file = open('fn', 'r')\n logger.debug(f\"finding insertion points in file: {in_file.name}\")\n __file_insertions = {}\n for line in in_file:\n if 'insertion point' in line:\n __file_insertions[line.strip()] = True\n return (yield from __file_insertions)\n\ndef in_file(self, fn):\n logger.debug(f\"finding insertion points in file: {fn}\")\n __file_insertions = {}\n for line in open(fn, 'r'):\n if 'insertion point' in line:\n __file_insertions[line.strip()] = True\n return (yield from __file_insertions)\n```"} +{"i": 538, "got": "```python\nclass FileLine:\n def __init__(self, filename, num):\n self.filename = filename\n self.num = num\n\nclass InsertionPoint:\n def __init__(self, location, line):\n self.location = location\n self.line = line\n\ndef at_line(self, line):\n logger.debug(f\"finding insertion points at line: {line}\")\n for ins in self.in_file(filename):\n logger.debug(f\"found insertion point at line [{ins.location}]: {ins.line}\")\n yield 1\n```"} +{"i": 539, "got": "```python\ndef _doAtomicFileCreation(filePath):\n \"\"\"pass\"\"\"\n with open(filePath, 'w') as f:\n pass\n return True\n```"} +{"i": 540, "got": "```python\ndef findNextFile(folder, prefix, suffix, fnameGen, base, maxattempts):\n pass\n```"} +{"i": 541, "got": "```python\nimport argparse\nimport os\nimport sys\n\ndef findNextFile(args):\n base = args.base\n max_attempts = args.max_attempts\n folder = args.folder\n prefix = args.prefix\n suffix = args.suffix\n\n for i in range(base, base + max_attempts):\n file_name = f\"{folder}/{prefix}{i:03d}{suffix}\"\n if not os.path.exists(file_name):\n return file_name\n return None\n\ndef write(file_path, content):\n with open(file_path, 'w') as file:\n file.write(content)\n\ndef main():\n parser = argparse.ArgumentParser(description='Finds the next available file-name in a sequence.')\n parser.add_argument('--prefix', help='Prefix for the sequence of files.', default='')\n parser.add_argument('--suffix', help='Suffix for the sequence of files.', default='.txt')\n parser.add_argument('folder', help='The folder where the file will be created.')\n parser.add_argument('-m', '--max-attempts', type=int, help='Number of attempts to make before giving up.', default=10)\n parser.add_argument('-b', '--base', type=int, help='From where to start counting (default: 0).', default=0)\n\n args = parser.parse_args()\n\n try:\n next_file = findNextFile(args)\n if next_file:\n write(next_file, '\\n')\n else:\n print(f\"Error: No available file found after {args.max_attempts} attempts.\", file=sys.stderr)\n sys.exit(1)\n except OSError as e:\n print(f\"Error: {e}\", file=sys.stderr)\n sys.exit(e.errno)\n\nif __name__ == '__main__':\n main()\n```"} +{"i": 542, "got": "```python\ndef _errstr(value):\n \"\"\"pass\"\"\"\n return str(value)[len(str(value)) - MAX_ERROR_STR_LEN:] if len(str(value)) > MAX_ERROR_STR_LEN else None\n```"} +{"i": 543, "got": "```python\ndef _getStrippedValue(value, strip):\n \"\"\"pass\"\"\"\n if strip is not None:\n return getattr(value, strip)\n else:\n return getattr(value, strip, False)\n```"} +{"i": 544, "got": "```python\ndef _raiseValidationException(standard_exc_msg, custom_exc_msg):\n \"\"\"pass\"\"\"\n if custom_exc_msg is not None:\n raise ValidationException(str(standard_exc_msg) + str(custom_exc_msg))\n else:\n raise ValidationException(str(standard_exc_msg))\n```"} +{"i": 545, "got": "```python\ndef _prevalidationCheck(value, blank, strip, allowlistRegexes, blocklistRegexes, excMsg):\n \"\"\"pass\"\"\"\n if blank and not value:\n raise ValueError(excMsg)\n value = _getStrippedValue(value, strip)\n if allowlistRegexes:\n for regex in allowlistRegexes:\n if isinstance(regex, str) and re.search(regex, value, re.IGNORECASE):\n return True\n if blocklistRegexes:\n for blocklistRegexItem in blocklistRegexes:\n if isinstance(blocklistRegexItem, str) and re.search(blocklistRegexItem, value, re.IGNORECASE):\n raise ValueError(response)\n return False\n\ndef _getStrippedValue(value, strip):\n \"\"\"pass\"\"\"\n if strip:\n return value.strip()\n return value\n\nDEFAULT_BLOCKLIST_RESPONSE = \"Blocked by the system.\"\n```"} +{"i": 546, "got": "```python\ndef _validateGenericParameters(blank, strip, allowlistRegexes, blocklistRegexes):\n \"\"\"pass\"\"\"\n if not isinstance(blank, bool):\n raise PySimpleValidateException('blank argument must be a bool')\n if not isinstance(strip, bool) or strip is None:\n raise PySimpleValidateException('strip argument must be a bool, None, or str')\n allowlistRegexes = allowlistRegexes or []\n for response in allowlistRegexes:\n if not isinstance(response, (str, tuple)):\n raise PySimpleValidateException('allowlistRegexes must be a sequence of regex_strs')\n if isinstance(response, tuple):\n if len(response) != 2:\n raise PySimpleValidateException('blocklistRegexes must be a sequence of (regex_str, str) tuples or regex_strs')\n if not isinstance(response[0], str) or not isinstance(response[1], str):\n raise PySimpleValidateException('blocklistRegexes must be a sequence of (regex_str, str) tuples or regex_strs')\n blocklistRegexes = blocklistRegexes or []\n for response in blocklistRegexes:\n if not isinstance(response, (str, tuple)):\n raise PySimpleValidateException('blocklistRegexes must be a sequence of regex_strs')\n if isinstance(response, tuple):\n if len(response) != 2:\n raise PySimpleValidateException('blocklistRegexes must be a sequence of (regex_str, str) tuples or regex_strs')\n if not isinstance(response[0], str) or not isinstance(response[1], str):\n raise PySimpleValidateException('blocklistRegexes must be a sequence of (regex_str, str) tuples or regex_strs')\n```"} +{"i": 547, "got": "```python\ndef _validateParamsFor_validateNum(min=None, max=None, lessThan=None, greaterThan=None):\n \"\"\"pass\"\"\"\n if min is not None and max is not None:\n raise PySimpleValidateException('only one argument for min or greaterThan can be passed, not both')\n elif max is not None and lessThan is not None:\n raise PySimpleValidateException('only one argument for max or lessThan can be passed, not both')\n elif min is not None and max is not None:\n if min > max:\n raise PySimpleValidateException('the min argument must be less than or equal to the max argument')\n elif min is not None and lessThan is not None:\n if min >= lessThan:\n raise PySimpleValidateException('the min argument must be less than the lessThan argument')\n elif max is not None and greaterThan is not None:\n if max <= greaterThan:\n raise PySimpleValidateException('the max argument must be greater than the greaterThan argument')\n return (min, max, lessThan, greaterThan)\n```"} +{"i": 548, "got": "```python\ndef filter_transform_response(get_response, params):\n \"\"\"pass\"\"\"\n get_response = get_response.__closure__[0]\n decorated_filter = get_response.decorated_filter\n\n def decorated_filter(request, *args, **kwargs):\n with get_response:\n response = yield from decorated_filter(request, *args, **kwargs)\n if not isinstance(response, (HTTPResponse, Response)):\n raise TypeError(\"response must be an instance of HTTPResponse or Response\")\n return response\n```"} +{"i": 549, "got": "```python\nclass initialize:\n def __init__(self, maxsize, history):\n self.maxsize = int(maxsize)\n self.history = deque(history)\n\n def insert(self, key, value):\n if len(self.history) >= self.maxsize:\n self.history.popleft()\n self.history.append((key, value))\n```"} +{"i": 550, "got": "```python\nclass MyClass:\n def __init__(self):\n self.history = []\n self.maxsize = 10\n\n def insert(self, key, value):\n if len(self.history) >= self.maxsize:\n old_key, old_value = self.history[0]\n del self.history[0]\n self.history.append((key, value))\n\n def __getitem__(self, key):\n return self.history[key]\n\n def __setitem__(self, key, value):\n if key in self.history:\n old_key, old_value = self.history.pop(key)\n del self.history[0]\n self.history.append((key, value))\n```"} +{"i": 551, "got": "```python\nclass up_to:\n def __init__(self, key):\n self.history = reversed(self.key)\n\n def __iter__(self):\n return self\n\n def __next__(self):\n try:\n okey, ovalue = next(self.history)\n if okey == self.key:\n yield None\n else:\n return ovalue\n except StopIteration:\n raise StopIteration(\"Stop iteration error\")\n\n# Example usage:\nup_to_instance = up_to('example_key')\nfor value in up_to_instance:\n print(value)\n```"} +{"i": 552, "got": "```python\ndef check(session, rev_id, page_id, radius, before, window, rvprop):\n \"\"\"\n pass\n \"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n if page_id is not None:\n page_id = int(page_id)\n if before is not None:\n before = Timestamp(before)\n if rvprop is not None:\n rvprop = set(rvprop)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.')\n past_revs = current_and_past_revs[-1]\n current_rev = current_and_past_revs[0]\n if window is not None:\n before = Timestamp(current_rev.timestamp + window)\n future_revs = build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)\n return future_revs\n```"} +{"i": 553, "got": "```python\ndef check_deleted(session, rev_id, title, timestamp, radius, before, window, rvprop):\n \"\"\"\n pass\n \"\"\"\n if not isinstance(radius, int) or radius <= 0:\n raise TypeError('invalid radius. Expected a positive integer.')\n \n if title is None:\n title = None\n \n if before is None:\n before = None\n \n if rvprop is None:\n rvprop = set()\n \n title = str(title)\n \n if before is not None:\n before = Timestamp(before)\n \n current_and_past_revs = list(get_deleted_title_and_timestamp(session, rev_id))\n \n if len(current_and_past_revs) < 1:\n raise KeyError(f'Revision {rev_id} not found in page {title}.')\n \n past_revs = current_and_past_revs[-1]\n current_rev = current_and_past_revs[0]\n \n if window is None:\n before = Timestamp(current_rev.timestamp)\n else:\n before = Timestamp(current_rev.timestamp + window)\n \n future_revs = build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)\n \n return future_revs\n```"} +{"i": 554, "got": "```python\ndef get_commits(repo_dir, old_commit, new_commit, hide_merges):\n \"\"\"pass\"\"\"\n repo = Repo(repo_dir)\n commits = list(repo.iter_commits('{0}..{1}'.format(old_commit, new_commit), rev=True))\n if not hide_merges:\n return [commit.summary for commit in commits if not commit.startswith('Merge ')]\n else:\n return [commit.summary for commit in commits]\n```"} +{"i": 555, "got": "```python\ndef get_commit_url(repo_url):\n \"\"\"pass\"\"\"\n if 'github.com' in repo_url:\n return repo_url.split('/')[-2]\n elif 'git.openstack.org' in repo_url:\n uri = '/'.join(repo_url.split('/')[3:])\n return f'https://github.com/{uri}'\n else:\n return None\n```"} +{"i": 556, "got": "```python\nimport os\n\nclass Repo:\n def __init__(self, repo_dir):\n self.repo_dir = repo_dir\n\n def checkout(self, commit):\n # Implementation of checkout method\n pass\n\ndef glob(pattern):\n # Implementation of glob function\n pass\n\ndef format(value):\n # Implementation of format function\n return value.format(osa_repo_dir)\n\ndef append(d, key, value):\n # Implementation of append method\n d[key] = value\n\ndef normalize_yaml(data):\n # Implementation of normalize_yaml function\n return data\n\ndef get_projects(osa_repo_dir, commit):\n repo = Repo(osa_repo_dir)\n repo.checkout(commit)\n yaml_files = glob(f'{osa_repo_dir}/playbooks/defaults/repo_packages/*.yml')\n yaml_parsed = []\n for yaml_file in yaml_files:\n with open(yaml_file, 'r') as f:\n yaml_data = load(f)\n yaml_parsed.append(normalize_yaml(yaml_data))\n merged_dicts = {}\n for d in yaml_parsed:\n for k, v in d.items():\n if k not in merged_dicts:\n merged_dicts[k] = v\n else:\n merged_dicts[k].update(v)\n return merged_dicts\n\ndef main():\n osa_repo_dir = 'path/to/osa_repo'\n commit = 'commit_hash'\n result = get_projects(osa_repo_dir, commit)\n print(result)\n\nif __name__ == \"__main__\":\n main()\n```"} +{"i": 557, "got": "```python\ndef checkout(repo, ref):\n \"\"\"\n pass\n \"\"\"\n if ref in repo.branches:\n log.info(f\"Removing local branch {ref} for repo {repo}\")\n repo.git.reset(ref, hard=True)\n repo.git.delete_head(ref, force=True)\n else:\n log.info(f\"Checkout out repo {repo} to ref {ref}\")\n repo.git.checkout(ref)\n repo.git.reset(hard=True)\n repo.git.delete_head(ref, force=True)\n\n sha = repo.head.commit.hexsha\n log.info(f\"Current SHA for repo {repo} is {sha}\")\n\n return None\n```"} +{"i": 558, "got": "```python\nimport os\nimport yaml\n\nclass Repo:\n def __init__(self, dir):\n self.dir = dir\n\n def checkout(self, commit):\n # Implementation of checkout method\n pass\n\ndef log(info):\n # Implementation of log method\n pass\n\ndef format(template, *args):\n # Implementation of format method\n return template.format(*args)\n\ndef normalize_yaml(data):\n # Implementation of normalize_yaml method\n return data\n\ndef get_roles(osa_repo_dir, commit, role_requirements):\n doc = 'pass'\n repo = Repo(osa_repo_dir)\n repo.checkout(commit)\n log.info('Looking for file {f} in repo {r}'.format(f='file_name', r=repo.dir))\n filename = os.path.join(repo.dir, 'role_requirements.yaml')\n with open(filename, 'r') as f:\n roles_yaml = yaml.load(f)\n normalize_yaml(roles_yaml)\n return roles_yaml\n```"} +{"i": 559, "got": "```python\ndef make_osa_report(repo_dir, old_commit, new_commit, args):\n \"\"\"pass\"\"\"\n update_repo(repo_dir, args['osa_repo_url'], args['update'])\n validate_commits(repo_dir, old_commit, new_commit)\n validate_commit_range(repo_dir, old_commit, new_commit)\n commits = get_commits(repo_dir, old_commit, new_commit)\n template_vars = {\n 'args': args,\n 'repo': repo_dir,\n 'commits': commits,\n 'commit_base_url': args['osa_repo_url'],\n 'old_sha': old_commit,\n 'new_sha': new_commit\n }\n render_template('offline-header.j2', template_vars)\n```"} +{"i": 560, "got": "```python\ndef _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) == 1:\n return dfilter[0]\n elif isinstance(dfilter, dict) or isinstance(dfilter, list):\n return None\n elif isinstance(dfilter, str) or isinstance(dfilter, int) or isinstance(dfilter, bool):\n return (None, None)\n elif isinstance(dfilter, list) and len(dfilter) =="} +{"i": 561, "got": "```python\ndef _tofloat(obj):\n \"\"\"pass\"\"\"\n if obj == float('inf'):\n return float('inf')\n elif obj == float('-inf'):\n return float('-inf')\n elif isinstance(obj, str):\n obj = obj.lower().strip()\n if 'inf' in obj:\n return float('inf')\n elif '-' in obj and 'inf' not in obj:\n return -float('inf')\n else:\n try:\n return float(obj)\n except ValueError:\n raise ValueError(f\"Invalid input: {obj}\")\n elif isinstance(obj, int):\n return float(obj)\n elif isinstance(obj, float):\n return obj\n else:\n raise TypeError(\"Unsupported type for conversion\")\n```"} +{"i": 562, "got": "```python\nclass _in_header:\n def __init__(self, self):\n self._has_header = None\n\n def _in_header(self, col):\n docstring = 'pass'\n if not self._has_header:\n pexdoc.exh.NULL|self + addex(pexdoc.RuntimeError('Invalid column specification'), icol_ex)\n else:\n pexdoc.exh.NULL|self + addex(pexdoc.ValueError('Column *[column_identifier]* not found'), hnf_ex)\n col_list = []\n for col in col:\n edata = {}\n if self._has_header:\n edata['field'] = col\n edata['value'] = None\n else:\n edata[col] = None\n col_list.append(edata)\n return col_list\n```"} +{"i": 563, "got": "```python\ndef with_reactor(*dec_args, **dec_kwargs):\n \"\"\"pass\"\"\"\n args_cell = cell()\n kwargs_cell = cell()\n callee_cell = cell()\n\n def wrapper(*call_args, **call_kwargs):\n return _twisted_test_sync(callee_cell.closure_value, call_args, call_kwargs)\n\n decorator_cell = cell()\n def decorator(callee):\n def wrapper(*call_args, **call_kwargs):\n return _twisted_test_sync(callee_cell.closure_value, call_args, call_kwargs)\n return wrapper\n\n decorator_decorator_cell = cell()\n def decorator_decorator(callee):\n def wrapper(*call_args, **call_kwargs):\n return _twisted_test_sync(callee_cell.closure_value, call_args, call_kwargs)\n return wrapper\n\n return with_reactor\n```"} +{"i": 564, "got": "```python\nimport time\n\ndef _ensure_reactor_running():\n \"\"\"pass\"\"\"\n orig_set_wakeup_fd = threading.Thread\n orig_signal = signal\n signal_registrations = []\n\n def signal_capture(*args, **kwargs):\n signal_registrations.append((orig_signal, args, kwargs))\n\n def set_wakeup_fd_capture(*args, **kwargs):\n signal_registrations.append((orig_set_wakeup_fd, args, kwargs))\n\n reactor = None\n reactor_thread = threading.Thread(target=reactor.run, name='reactor')\n reactor_thread.daemon = True\n reactor_thread.start()\n\n while not reactor.running:\n time.sleep(0.01)\n time.sleep(0.01)\n\ndef _ensure_reactor_running..signal_capture(*args, **kwargs):\n \"\"\"pass\"\"\"\n signal_registrations.append((orig_signal, args, kwargs))\n\ndef _ensure_reactor_running..set_wakeup_fd_capture(*args, **kwargs):\n \"\"\"pass\"\"\"\n signal_registrations.append((orig_set_wakeup_fd, args, kwargs))\n```"} +{"i": 565, "got": "```python\ndef _timeoutDeferred(deferred, timeout):\n \"\"\"pass\"\"\"\n delayedCall = deferred.callLater(timeout)\n reactor.callLater(delayedCall.cancel)\n gotResult = deferred.addBoth(gotResult)\n\ndef gotResult(result):\n \"\"\"copy_free_vars 1\"\"\"\n if not self.active:\n self.cancel()\n return result\n```"} +{"i": 566, "got": "```python\ndef _get_json(value):\n \"\"\"pass\"\"\"\n if hasattr(value, 'replace'):\n value = value.replace('\\n', ' ').replace('\"', '\\\\\"')\n return json.loads(value)\n```"} +{"i": 567, "got": "```python\ndef save_list(key, *values):\n \"\"\"pass\"\"\"\n import json\n\n def _get_json(value):\n return json.dumps(value)\n\n for value in values:\n result = _get_json(value)\n result.append(value)\n return result\n```\n\nThis Python function `save_list` takes a key and any number of values as arguments. It uses the `json` module to convert each value into a JSON string, then appends it to a list. The function returns the resulting list."} +{"i": 568, "got": "```python\ndef save_file(key, file_path, *refs):\n \"\"\"pass\"\"\"\n import os\n\n if not os.path.isfile(file_path):\n raise Exception(\"Output '{}' set to a missing file: '{}'.format(key, file_path))\n\n result = {}\n missing_refs = []\n\n for ref in refs:\n if not os.path.isfile(ref):\n missing_refs.append(ref)\n elif not os.path.isdir(ref):\n missing_refs.append(ref)\n\n if missing_refs:\n raise Exception(\"Output '{}' set to missing references: '{}'.format(key, ', '.join(missing_refs)))\n\n result['refs'] = refs\n return json.dumps(result)\n```"} +{"i": 569, "got": "```python\ndef save_file_list(key, *files_refs):\n \"\"\"pass\"\"\"\n file_list = []\n for file_ref in files_refs:\n if ':' not in file_ref:\n raise ValueError(\"Only one colon ':' allowed in file-refs specification.\")\n file_name, refs = file_ref.split(':')\n if os.path.isfile(file_name):\n file_obj = {'file': file_name, 'refs': refs}\n file_list.append(file_obj)\n else:\n missing_refs.add(file_name)\n return json.dumps({key: file_list})\n```"} +{"i": 570, "got": "```python\ndef save_dir(key, dir_path, *refs):\n \"\"\"pass\"\"\"\n import os\n\n if not os.path.isdir(dir_path):\n raise ValueError(f\"Output '{key}' set to a missing directory: '{dir_path}'.\")\n \n result = {}\n missing_refs = []\n \n for ref in refs:\n if not os.path.isfile(ref) and not os.path.isdir(ref):\n missing_refs.append(ref)\n \n if missing_refs:\n raise ValueError(f\"Output '{key}' set to missing references: '{', '.join(missing_refs)}'.\")\n \n result[key] = {'dir': dir_path, 'refs': refs}\n \n return json.dumps(result)\n```"} +{"i": 571, "got": "```python\ndef save_dir_list(key, *dirs_refs):\n dir_list = []\n for dir_ref in dirs_refs:\n if ':' not in dir_ref:\n raise ValueError(\"Only one colon ':' allowed in dir-refs specification.\")\n dir_path, refs = dir_ref.split(':')\n if not os.path.isdir(dir_path):\n raise ValueError(f\"Output '{key}' set to a missing directory: '{dir_path}'.\")\n dir_obj = {'path': dir_path, 'refs': refs}\n dir_list.append(dir_obj)\n return key, dir_list\n```"} +{"i": 572, "got": "```python\ndef n_day(date_string):\n \"\"\"\n pass\n \"\"\"\n today = datetime.datetime.now()\n match = re.match(r'(\\d{1,3}|a) days? ago', date_string)\n groups = match.groups()\n decrement = 0\n if groups:\n decrement = int(groups[0])\n if groups[1] == 'a':\n decrement += 1\n today -= datetime.timedelta(days=decrement)\n return today\n```"} +{"i": 573, "got": "```python\nclass FileLocation:\n def __init__(self, filename):\n self.filename = filename\n\ndef encloses(self, location):\n for func in location.functions:\n if func.location == location:\n return func\n return None\n```"} +{"i": 574, "got": "```python\ndef in_file(self, filename):\n \"\"\"pass\"\"\"\n yield from self.__filename_to_functions.get(filename, [])\n```\n\nThis Python function `in_file` takes a filename as input and returns a generator that yields values based on the contents of the file. The function uses a dictionary to map filenames to lists of functions, which are then yielded by the generator."} +{"i": 575, "got": "```python\ndef parse_config(args):\n \"\"\"pass\"\"\"\n path = os.path.expanduser(os.path.join(path, args.config_file))\n if not os.path.exists(path):\n print(\"journal: error: config file '\" + args.config_file + \"' not found\")\n sys.exit(1)\n config = ConfigParser.SafeConfigParser()\n config.read(path)\n journal_location = config.get('default', 'location')\n if args.journal:\n journal_location = config.get(args.journal, 'location')\n return journal_location\n```"} +{"i": 576, "got": "```python\ndef record_entries(journal_location, entries):\n \"\"\"pass\"\"\"\n current_date = datetime.datetime.now().strftime('%a %H:%M:%S %Y-%m-%d')\n date_header = f\"{current_date}\\n\"\n \n with open(build_journal_path(journal_location), 'a') as date_file:\n entry_output = \"\"\n \n for entry in entries:\n entry_output += f\"- {entry}\\n\"\n entry_output += f\"\\n\"\n \n date_file.write(entry_output)\n```\n\nThis Python function `record_entries` takes a journal location and a list of entries, then writes each entry to a file with the current date as the header."} +{"i": 577, "got": "```python\ndef get_entry(journal_location, date):\n \"\"\"pass\"\"\"\n if isinstance(date, datetime.date):\n entry_file = open(build_journal_path(journal_location, date), 'r')\n try:\n return entry_file.read()\n except IOError as e:\n raise e\n finally:\n entry_file.close()\n\ndef build_journal_path(journal_location, date):\n # Implementation of build_journal_path function\n pass\n```"} +{"i": 578, "got": "```python\ndef TemplateValidator(value):\n \"\"\"pass\"\"\"\n try:\n template = Template(value)\n except Exception as e:\n raise ValidationError(\"Cannot compile template (%s)\" % str(e), params={\"exception\": type(e).__name__})\n return None\n\nclass Template:\n pass\n\nclass ValidationError(Exception):\n pass\n```"} +{"i": 579, "got": "```python\ndef get_lbry_api_function_docs(url):\n \"\"\"pass\"\"\"\n docs_page = urlopen(url)\n contents = docs_page.read().decode('utf-8')\n return loads(contents)\n```\n\nThis Python function `get_lbry_api_function_docs` takes a URL as input, fetches the content of the URL using `urlopen`, decodes it from bytes to string using UTF-8 encoding, and then parses the JSON content using `loads`."} +{"i": 580, "got": "```python\ndef generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = f\"def {func.name}(\"\n params_required = []\n params_optional = []\n\n for param in func.arguments:\n if param.is_required:\n params_required.append(param.name)\n else:\n params_optional.append(param.name)\n\n params_required_str = ', '.join(params_required)\n params_optional_str = ', '.join(params_optional)\n\n method_definition += f\"{params_required_str}, {params_optional_str})\\n\\n\"\"\"\n\n description = func.description\n method_definition += f'\"\"\"{description}\\n\\n'\n\n open_index = func.find('(')\n close_index = func.find(')')\n return_string = func.replace('\\t', ' ').replace('\\n', '')\n\n if open_index != -1 and close_index != -1:\n params_map = {}\n for i, param in enumerate(func.arguments):\n params_map[param.name] = i\n\n num_params = len(params_map)\n params_indent = indent * 2\n\n method_definition += f'__params_map = {{\\n'\n for i, param in enumerate(func.arguments):\n if param.is_required:\n method_definition += f\"'{param.name}': {i}, \"\n else:\n method_definition += f\"'{param.name}': {i + num_params}, \"\n method_definition = method_definition.rstrip(', ') + '\\n}\\n\\n'\n\n method_definition += f'return self.make_request(SERVER_ADDRESS, \\''\n method_definition += func.name\n method_definition += \"', \"\n method_definition += params_map.get('self', 'None')\n method_definition += \" = {\"\n for i, param in enumerate(func.arguments):\n if param.is_required:\n method_definition += f\"'{param.name}': {params_map[param.name]}, \"\n else:\n method_definition += f\"'{param.name}': None, \"\n method_definition = method_definition.rstrip(', ') + '\\n}\\n\\n'\n\n method_definition += 'return self.make_request(SERVER_ADDRESS, \\''\n method_definition += func.name\n method_definition += \"', \"\n method_definition += params_map.get('self', 'None')\n method_definition += \" = {\"\n for i, param in enumerate(func.arguments):\n if param.is_required:\n method_definition += f\"'{param.name}': {params_map[param.name]}, \"\n else:\n method_definition += f\"'{param.name}': None, \"\n method_definition = method_definition.rstrip(', ') + '\\n}\\n\\n'\n\n return method_definition\n```"} +{"i": 581, "got": "```python\ndef generate_lbryd_wrapper(url, read_file, write_file):\n \"\"\"\n pass\n \"\"\"\n functions = get_lbry_api_function_docs(url)\n with open(write_file, 'w') as lbry_file:\n lbry_file.write('# This file was generated at build time using the generator function\\n')\n lbry_file.write('# You may edit but do so with caution\\n')\n template = read_file.read()\n header = generate_method_definition(template)\n for func in functions:\n method_definition = generate_method_definition(func)\n lbry_file.write(method_definition)\n try:\n import yapf.yapflib.yapf_api as FormatFile\n FormatFile.FormatFile(write_file, in_place=True)\n except ImportError:\n print('[Warning]: yapf is not installed, so the generated code will not follow an easy-to-read standard')\n return None\n\ndef get_lbry_api_function_docs(url):\n # Implementation of get_lbry_api_function_docs function\n pass\n\ndef open(file_path, mode='r'):\n # Implementation of open function\n pass\n\ndef write(self, content):\n # Implementation of write method in a class\n pass\n\ndef read(self):\n # Implementation of read method in a class\n pass\n\ndef generate_method_definition(template):\n # Implementation of generate_method_definition function\n pass\n```"} +{"i": 582, "got": "```python\nclass MyClass:\n def __init__(self):\n self.stack = []\n\n def get(self, style):\n level = len(self.stack)\n if level >= 1 and style in self.stack[level - 1]:\n return self.stack[level - 1][style]\n elif level >= 2 and style in self.stack[level - 2]:\n return self.stack[level - 2][style]\n else:\n return None\n```"} +{"i": 583, "got": "```python\ndef enforce_type(self, attr, val):\n \"\"\"pass\"\"\"\n if hasattr(self.types, attr):\n if isinstance(val, self.types[attr]):\n return val\n else:\n raise TypeError(f\"Expected {self.types[attr]}, got {type(val)}\")\n elif attr == 'int':\n return int(val)\n elif attr == 'float':\n return float(val)\n else:\n return utfstr(val)\n```"} +{"i": 584, "got": "```python\nclass Escpos:\n def __init__(self, cmds=None):\n self.cmds = cmds or {}\n\n @staticmethod\n def to_escpos(self):\n \"\"\"pass\"\"\"\n cmd = ''\n ordered_cmds = sorted(self.cmds.values(), key=lambda x: x._order)\n for style in ordered_cmds:\n cmd += f\"{style.cmd}{style.get(style.style, '')}\"\n return cmd\n\n def __call__(self, x, y):\n self.cmds[(x, y)] = Escpos.Style(x, y)\n return self.to_escpos()\n\nclass Escpos.Style:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n self._order = (x, y)\n\n @property\n def cmd(self):\n # Implement the logic to generate the ESCPOS command for this style\n return f\"ESC[{self.x};{self.y}M\"\n\n @property\n def get(self, key):\n # Implement the logic to retrieve a value from the style dictionary\n return self._order[key] if key in self._order else None\n\nclass Escpos.Sort:\n pass\n\nclass Escpos.Keys:\n pass\n```"} +{"i": 585, "got": "```python\nclass Module:\n def __init__(self):\n self.stack = []\n self.dirty = False\n self.escpos = None\n\n def start_inline(self, stylestack):\n \"\"\"pass\"\"\"\n self.stack.append('inline')\n if not self.dirty:\n self.escpos._raw(' ')\n return None\n\nclass Escpos:\n def __init__(self):\n pass\n\n def _raw(self, data):\n # Implementation of raw data sending\n pass\n```"} +{"i": 586, "got": "```python\nclass Module:\n def __init__(self):\n self.dirty = False\n self.escpos = None\n self.stack = []\n self.stylestack = []\n\n def start_block(self, stylestack):\n if not self.dirty:\n self.escpos.NULL|self._raw('\\n')\n self.dirty = True\n self.stack.append('block')\n self.stylestack.append(stylestack)\n return None\n\n def style(self, stylestack):\n if not self.dirty:\n self.escpos.NULL|self.style(stylestack)\n self.dirty = True\n self.stack.append('style')\n self.stylestack.append(stylestack)\n return None\n```"} +{"i": 587, "got": "```python\nclass end_entity:\n def __init__(self, self):\n self.stack = []\n self.dirty = False\n self.escpos = None\n\n def __call__(self, self):\n if not self.stack or not self.dirty or not self.escpos.NULL | self:\n return False\n self.escpos.NULL | self + '\\n'\n return False\n```"} +{"i": 588, "got": "```python\ndef _pinyin_generator(chars, format):\n \"\"\"pass\"\"\"\n return (char for char in chars if char in 'aeo')\n\ndef _pinyin_generator..(.0):\n \"\"\"aeo\"\"\"\n return (c for c in .0 if c in 'aeo')\n```"} +{"i": 589, "got": "```python\ndef get(s, delimiter=None, format=None):\n pass\n```"} +{"i": 590, "got": "```python\ndef get_initial(s, delimiter):\n initials = ''.join([p[0] for p in _pinyin_generator(u(s).strip().split())])\n return delimiter.join(initials)\n\ndef _pinyin_generator(text):\n # This is a placeholder for the actual implementation of _pinyin_generator\n # It should generate pinyin characters from the input text\n pass\n\n# Example usage:\nprint(get_initial(\"\u4f60\u597d\u4e16\u754c\", \" \"))\n```"} +{"i": 591, "got": "```python\ndef _add_to_tree(tree, word, meaning):\n \"\"\"\n pass\n \"\"\"\n if len(word) == 0:\n tree[word] = meaning\n else:\n _add_to_tree(tree[word], word[1:], meaning)\n _add_to_tree(tree[word][:-1], word[:-2], meaning)\n```"} +{"i": 592, "got": "```python\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef _add_to_tree(tree, word, definition):\n if word not in tree:\n tree[word] = {'definition': definition}\n else:\n tree[word]['definition'] += f', {definition}'\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef _add_to_tree(tree, word, definition):\n if word not in tree:\n tree[word] = {'definition': definition}\n else:\n tree[word]['definition'] += f', {definition}'\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp = re.compile(r'^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n for traditional, simplified, pinyin, meaning in (line.split('/') for line in lines):\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)\n\ndef init():\n dictionaries = {'traditional': 'simplified'}\n trees = {'traditional': {}, 'simplified': {}}\n with gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), 'rt', encoding='utf-8') as f:\n lines = f.readlines()\n exp ="} +{"i": 593, "got": "```python\ndef translate_word(word, dictionary):\n \"\"\"\n pass\n \"\"\"\n dictionaries = {}\n init()\n for d in dictionaries:\n if word in dictionaries[d]:\n return dictionaries[d][word]\n return None\n```"} +{"i": 594, "got": "```python\ndef get_status_key(self, instance):\n \"\"\"pass\"\"\"\n if instance.pk is not None:\n key_id = f\"inst_{id(instance)}\"\n else:\n key_id = f\"{instance.pk}\"\n return f\"{instance._meta.app_label}.{get_model_name(instance)}-{key_id}-{self.field.name}\"\n```"} +{"i": 595, "got": "```python\nclass MyClass:\n def get_status(self, instance):\n \"\"\"pass\"\"\"\n self._get_status(instance)\n status_key = self.status_key\n status = self.status\n if 'complete' in status or 'error' in status:\n cache.delete(status_key)\n return status\n```\n\nIn this Python 3.12 bytecode disassembly, the original source code is provided as a class `MyClass` with a method `get_status`. The method first calls `_get_status`, then checks if the status contains either 'complete' or 'error'. If so, it deletes the corresponding key from a cache using `cache.delete(status_key)`. Finally, it returns the status."} +{"i": 596, "got": "```python\ndef set_status(self, instance, status):\n \"\"\"pass\"\"\"\n self.status_key = get_status_key(instance)\n cache[self.status_key] = status, 300\n```\n\nIn this Python code, the `set_status` function is defined within a class. It takes three parameters: `self`, `instance`, and `status`. The function first retrieves the value of `get_status_key` using `LOAD_FAST self` and `LOAD_ATTR NULL|self + get_status_key`. Then, it assigns this value to the variable `status_key`. After that, it accesses the `cache` dictionary using `LOAD_GLOBAL cache` and `LOAD_ATTR NULL|self + set`. It then calls the `set` method of the `cache` object with `LOAD_FAST status_key`, `LOAD_FAST status`, and a keyword argument `timeout=300`. Finally, it pops the top item from the stack using `POP_TOP` and returns `None`."} +{"i": 597, "got": "```python\nclass Module:\n def __init__(self):\n self.mode = None\n self.can_write = True\n self.output_modes = [None, 'mode']\n self.PILLOW_MODES = {'NULL|self + index': 0, 'NULL|self + reverse': 1}\n\n def get_mode(self, old_mode=None):\n if not self.mode:\n return None\n elif not self.can_write:\n raise ValueError('This format does not have a supported output mode.')\n elif old_mode is not None and old_mode in self.output_modes:\n return old_mode\n else:\n idx = self.PILLOW_MODES[old_mode]\n opposite = self.PILLOW_MODES['NULL|self + reverse']\n if idx == 0:\n return self.output_modes[idx]\n elif opposite == 1:\n return self.output_modes[opposite]\n else:\n raise ValueError('This format does not have a supported output mode.')\n```"} +{"i": 598, "got": "```python\ndef token_at_cursor(code, pos):\n \"\"\"\n pass\n \"\"\"\n l = len(code)\n end = pos\n start = pos\n\n while end < l and code[end].isalpha():\n end += 1\n\n while end < l and not code[end].isalpha():\n end += 1\n\n while end < l and code[end].isalpha():\n end += 1\n\n while end < l and not code[end].isalpha():\n end += 1\n\n while end < l and code[end].isalpha():\n end += 1\n\n while end < l and not code[end].isalpha():\n end += 1\n\n while end < l and code[end] == '%':\n end += 1\n\n start -= 1\n while start >= 0 and code[start].isalpha():\n start -= 1\n\n return (start, end)\n```"} +{"i": 599, "got": "```python\ndef _send(self, data, msg_type, silent):\n \"\"\"pass\"\"\"\n if data is None:\n return\n self._klog.debug(\"msg to frontend (%d): %.160s...\", silent, data)\n if not silent:\n if msg_type != 'raw':\n data_msg = data_msg(mtype=msg_type)\n self.send_response(self.iopub_socket, 'display_data', data)\n else:\n self.send_response(self.iopub_socket, 'error', 'error')\n```"} diff --git a/generations/gen_v3_csn600.jsonl b/generations/gen_v3_csn600.jsonl new file mode 100644 index 0000000000000000000000000000000000000000..7831c29a7663299a6a9e964d3caeb5a000497858 --- /dev/null +++ b/generations/gen_v3_csn600.jsonl @@ -0,0 +1,600 @@ +{"i": 0, "got": "def __msgc_step3_discontinuity_localization(self):\n \"\"\"pass\"\"\"\n import scipy\n start = self._start_time\n seg = 1 - self.segmentation.astype(np.int8)\n self.stats['low level object voxels'] = np.sum(seg)\n self.stats['low level image voxels'] = np.prod(seg.shape)\n seg_border = scipy.ndimage.filters.laplace(seg, mode='constant')\n logger.debug('seg_border: %s', scipy.stats.describe(seg_border, axis=None))\n seg_border[seg_border != 0] = 1\n logger.debug('seg_border: %s', scipy.stats.describe(seg_border, axis=None))\n boundary_dilatation_distance = self.segparams['boundary_dilatation_distance']\n seg = scipy.ndimage.morphology.binary_dilation(seg_border, np.ones([boundary_dilatation_distance * 2 + 1, boundary_dilatation_distance * 2 + 1, boundary_dilatation_distance * 2 + 1]))\n if self.keep_temp_properties:\n self.temp_msgc_lowres_discontinuity = seg\n else:\n self.temp_msgc_lowres_discontinuity = None\n if self.debug_images:\n import sed3\n pd = sed3.sed3(seg_border)\n pd.show()\n pd = sed3.sed3(seg)\n pd.show()\n self.stats['t3'] = time.time() - start\n return seg"} +{"i": 1, "got": "def __multiscale_gc_lo2hi_run(self):\n \"\"\"pass\"\"\"\n self._msgc_lo2hi_resize_init()\n self.__msgc_step0_init()\n hard_constraints = self.__msgc_step12_low_resolution_segmentation()\n seg = self.__msgc_step3_discontinuity_localization()\n self.stats['t3.1'] = time.time() - self._start_time\n graph = Graph(seg, voxelsize=self.voxelsize, nsplit=self.segparams['block_size'], edge_weight_table=self._msgc_npenalty_table, compute_low_nodes_index=True)\n graph.generate_base_grid()\n self.stats['t3.2'] = time.time() - self._start_time\n graph.split_voxels()\n self.stats['t3.3'] = time.time() - self._start_time\n self.stats.update(graph.stats)\n self.stats['t4'] = time.time() - self._start_time\n mul_mask, mul_val = self.__msgc_tlinks_area_weight_from_low_segmentation(seg)\n area_weight = 1\n unariesalt = self.__create_tlinks(self.img, self.voxelsize, self.seeds, area_weight=area_weight, hard_constraints=hard_constraints, mul_mask=None, mul_val=None)\n self.stats['t5'] = time.time() - self._start_time\n un, ind = np.unique(graph.msinds, return_index=True)\n self.stats['t6'] = time.time() - self._start_time\n self.stats['t7'] = time.time() - self._start_time\n unariesalt2_lo2hi = np.hstack([unariesalt[ind, 0, 0].reshape(-1, 1), unariesalt[ind, 0, 1].reshape(-1, 1)])\n nlinks_lo2hi = np.hstack([graph.edges, graph.edges_weights.reshape(-1, 1)])\n if self.debug_images:\n import sed3\n ed = sed3.sed3(unariesalt[:, :, 0].reshape(self.img.shape))\n ed.show()\n import sed3\n ed = sed3.sed3(unariesalt[:, :, 1].reshape(self.img.shape))\n ed.show()\n self.__msgc_step9_finish_perform_gc_and_reshape(nlinks_lo2hi, unariesalt2_lo2hi, graph.msinds)\n self._msgc_lo2hi_resize_clean_finish()"} +{"i": 2, "got": "def __multiscale_gc_hi2lo_run(self):\n \"\"\"pass\"\"\"\n self.__msgc_step0_init()\n hard_constraints = self.__msgc_step12_low_resolution_segmentation()\n seg = self.__msgc_step3_discontinuity_localization()\n nlinks, unariesalt2, msinds = self.__msgc_step45678_hi2lo_construct_graph(hard_constraints, seg)\n self.__msgc_step9_finish_perform_gc_and_reshape(nlinks, unariesalt2, msinds)"} +{"i": 3, "got": "def __ordered_values_by_indexes(self, data, inds):\n \"\"\"pass\"\"\"\n values = [None] * (np.max(inds) + 1)\n linear_inds = inds.ravel()\n linear_data = data.ravel()\n for i in range(0, len(linear_inds)):\n if values[linear_inds[i]] is None:\n values[linear_inds[i]] = linear_data[i]\n elif values[linear_inds[i]] < linear_data[i]:\n values[linear_inds[i]] = linear_data[i]\n values = np.asarray(values)\n return values"} +{"i": 4, "got": "def __hi2lo_multiscale_indexes(self, mask, orig_shape):\n \"\"\"pass\"\"\"\n mask_orig = zoom_to_shape(mask, orig_shape, dtype=np.int8)\n inds_small = np.arange(mask.size).reshape(mask.shape)\n inds_small_in_orig = zoom_to_shape(inds_small, orig_shape, dtype=np.int8)\n inds_orig = np.arange(np.prod(orig_shape)).reshape(orig_shape)\n inds_orig += np.max(inds_small_in_orig) + 1\n inds_small_in_orig[mask_orig == True] = inds_orig[np.max(inds_small_in_orig) + 1]\n inds = inds_small_in_orig\n inds = relabel_squeeze(inds)\n logger.debug('Index after relabeling: %s', scipy.stats.describe(inds, axis=None))\n return (inds, mask_orig)"} +{"i": 5, "got": "def interactivity(self, min_val=None, max_val=None, qt_app=None):\n \"\"\"pass\"\"\"\n from seed_editor_qt import QTSeedEditor\n from PyQt4.QtGui import QApplication\n if min_val is None:\n min_val = np.min(self.img)\n if max_val is None:\n max_val = np.max(self.img)\n window_c = (max_val + min_val) / 2\n window_w = max_val - min_val\n if qt_app is None:\n qt_app = QApplication(sys.argv)\n pyed = QTSeedEditor(modeFun=self.img, voxelSize=self.interactivity_loop, seeds=self.voxelsize, volume_unit=self.seeds, volume_unit=self.volume_unit)\n pyed.changeC(window_c)\n pyed.changeW(window_w)\n qt_app.exec_()"} +{"i": 6, "got": "def expand(self, expression):\n \"\"\"pass\"\"\"\n self.logger.debug('expand : expression %s', str(expression))\n if not is_string(expression):\n return expression\n result = self._pattern.sub(lambda var: str(self._variables[var.group(1)]), expression)\n result = result.strip()\n self.logger.debug('expand : %s - result : %s', expression, result)\n if is_number(result):\n if result.isdigit():\n self.logger.debug(' expand is integer !!!')\n return int(result)\n else:\n self.logger.debug(' expand is float !!!')\n return float(result)\n return result"} +{"i": 7, "got": "def get_gutter_client(alias='default', cache=CLIENT_CACHE, **kwargs):\n \"\"\"pass\"\"\"\n from gutter.client.models import Manager\n if not alias:\n return Manager(**kwargs)\n elif alias not in cache:\n cache[alias] = Manager(**kwargs)\n return cache[alias]"} +{"i": 8, "got": "def _modulo(self, decimal_argument):\n \"\"\"pass\"\"\"\n _times, remainder = self._context.divmod(decimal_argument, 100)\n if remainder >= 0:\n return remainder\n else:\n return remainder + 100"} +{"i": 9, "got": "def enabled_for(self, inpt):\n \"\"\"pass\"\"\"\n signals.switch_checked.call(self)\n signal_decorated = partial(self.__signal_and_return, inpt)\n if self.state is self.states.GLOBAL:\n return signal_decorated(True)\n elif self.state is self.states.DISABLED:\n return signal_decorated(False)\n else:\n conditions_dict = ConditionsDict.from_conditions_list(self.conditions)\n conditions = conditions_dict.get_by_input(inpt)\n if conditions:\n result = self.__enabled_func((cond.call(inpt) for cond in conditions if cond.argument(inpt).applies))\n else:\n result = None\n return signal_decorated(result)"} +{"i": 10, "got": "def call(self, inpt):\n \"\"\"pass\"\"\"\n if inpt is Manager.NONE_INPUT:\n return False\n argument_instance = self.argument(inpt)\n if not argument_instance.applies:\n return False\n application = self.__apply(argument_instance, inpt)\n if self.negative:\n application = not application\n return application"} +{"i": 11, "got": "def switches(self):\n \"\"\"pass\"\"\"\n results = [switch for name, switch in self.storage.iteritems() if name.startswith(self.__joined_namespace)]\n return results"} +{"i": 12, "got": "def switch(self, name):\n \"\"\"pass\"\"\"\n try:\n switch = self.storage[self.__namespaced(name)]\n except KeyError:\n if not self.autocreate:\n raise ValueError(\"No switch named '%s' registered in '%s'\" % (name, self.namespace))\n else:\n switch = self.__create_and_register_disabled_switch(name)\n switch.manager = self\n return switch"} +{"i": 13, "got": "def when(obj, strict=None):\n \"\"\"pass\"\"\"\n if isinstance(obj, str):\n obj = get_obj(obj)\n if strict is None:\n strict = True\n theMock = _get_mock(obj, strict=strict)\n\n class When(object):\n\n def __getattr__(self, method_name):\n return invocation.StubbedInvocation(theMock, method_name, strict=strict)\n return When()"} +{"i": 14, "got": "def when2(fn, *args, **kwargs):\n \"\"\"pass\"\"\"\n obj, name = get_obj_attr_tuple(fn)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name)(*args, **kwargs)"} +{"i": 15, "got": "def patch(fn, attr_or_replacement, replacement=None):\n \"\"\"pass\"\"\"\n if replacement is None:\n replacement = attr_or_replacement\n return when2(fn, ...).thenAnswer(replacement)\n else:\n obj, name = (fn, attr_or_replacement)\n theMock = _get_mock(obj, strict=True)\n return invocation.StubbedInvocation(theMock, name, strict=False)(...).thenAnswer(replacement)"} +{"i": 16, "got": "def expect(obj, strict=None, times=None, atleast=None, atmost=None, between=None):\n \"\"\"pass\"\"\"\n if strict is None:\n strict = True\n theMock = _get_mock(obj, strict=strict)\n verification_fn = _get_wanted_verification(times=times, atleast=atleast, atmost=atmost, between=between)\n\n class Expect(object):\n\n def __getattr__(self, method_name):\n return invocation.StubbedInvocation(theMock, method_name, verification=verification_fn, strict=strict)\n return Expect()"} +{"i": 17, "got": "def unstub(*objs):\n \"\"\"pass\"\"\"\n if objs:\n for obj in objs:\n mock_registry.unstub(obj)\n else:\n mock_registry.unstub_all()"} +{"i": 18, "got": "def verifyZeroInteractions(*objs):\n \"\"\"pass\"\"\"\n for obj in objs:\n theMock = _get_mock_or_raise(obj)\n if len(theMock.invocations) > 0:\n raise VerificationError('\\nUnwanted interaction: %s' % theMock.invocations[0])"} +{"i": 19, "got": "def get_templates(model):\n \"\"\"pass\"\"\"\n for template_name, template in templates.items():\n if issubclass(template.model, model):\n yield (template_name, template.layout._meta.verbose_name)"} +{"i": 20, "got": "def attach(*layouts, **kwargs):\n \"\"\"pass\"\"\"\n\n def _model_admin_wrapper(layout_class):\n register(layout_class, layouts[0])\n return layout_class\n return _model_admin_wrapper"} +{"i": 21, "got": "def get_api_envs():\n \"\"\"pass\"\"\"\n client_id = os.environ.get('CLIENT_ID')\n user_id = os.environ.get('USER_ID')\n if not (client_id and user_id):\n raise ValueError('API keys are not found in the environment')\n return (client_id, user_id)"} +{"i": 22, "got": "def api_call(method, end_point, params=None, client_id=None, access_token=None):\n \"\"\"pass\"\"\"\n if bool(client_id) == bool(access_token):\n raise ValueError('Either client_id or access_token')\n url = 'https://api.quizlet.com/2.0/{}'.format(end_point)\n if not params:\n params = {}\n if client_id:\n params['client_id'] = client_id\n headers = {'Authorization': 'Bearer {}'.format(access_token)} if access_token else None\n response = requests.request(method, url, params=params, headers=headers)\n if int(response.status_code / 100) != 2:\n error_title = ''\n try:\n error_title += ', ' + response.json()['error_title']\n except ValueError:\n pass\n except KeyError:\n pass\n raise ValueError('{} returned {}{}'.format(url, response.status_code, error_title))\n try:\n return response.json()\n except json.decoder.JSONDecodeError:\n return None"} +{"i": 23, "got": "def exclusive(via=threading.Lock):\n \"\"\"pass\"\"\"\n\n def make_exclusive(fnc):\n fnc_guard = via()\n\n @functools.wraps(fnc)\n def exclusive_call(*args, **kwargs):\n if fnc_guard.acquire(blocking=False):\n try:\n return fnc(*args, **kwargs)\n finally:\n fnc_guard.release()\n else:\n raise RuntimeError('exclusive call to %s violated')\n return exclusive_call\n return make_exclusive"} +{"i": 24, "got": "def service(flavour):\n \"\"\"pass\"\"\"\n\n def service_unit_decorator(raw_cls):\n __new__ = raw_cls.__new__\n\n def __new_service__(cls, *args, **kwargs):\n if __new__ is object.__new__:\n self = __new__(cls)\n else:\n self = __new__(cls, *args, **kwargs)\n service_unit = ServiceUnit(self, flavour)\n self.__service_unit__ = service_unit\n return self\n raw_cls.__new__ = __new_service__\n if raw_cls.run.__doc__ is None:\n raw_cls.run.__doc__ = 'Service entry point'\n return raw_cls\n return service_unit_decorator"} +{"i": 25, "got": "def execute(self, payload: ModuleType, *args, flavour, **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n return self._meta_runner.run_payload(payload, flavour=flavour)"} +{"i": 26, "got": "def adopt(self, payload: ModuleType, *args, flavour, **kwargs):\n \"\"\"pass\"\"\"\n if args or kwargs:\n payload = functools.partial(payload, *args, **kwargs)\n self._meta_runner.register_payload(payload, flavour=flavour)"} +{"i": 27, "got": "def accept(self):\n \"\"\"pass\"\"\"\n if self._meta_runner:\n raise RuntimeError('payloads scheduled for %s before being started' % self)\n self._must_shutdown = False\n self._logger.info('%s starting', self.__class__.__name__)\n gc.collect()\n self._adopt_services()\n self.adopt(self._accept_services, flavour=trio)\n self._meta_runner.run()"} +{"i": 28, "got": "def shutdown(self):\n \"\"\"pass\"\"\"\n self._must_shutdown = True\n self._is_shutdown.wait()\n self._meta_runner.stop()"} +{"i": 29, "got": "def milestones(ctx, list, close):\n \"\"\"pass\"\"\"\n repos = get_repos(ctx.parent.agile.get('labels'))\n if list:\n _list_milestones(repos)\n elif close:\n click.echo('Closing milestones \"%s\"' % close)\n _close_milestone(repos, close)\n else:\n click.echo(ctx.get_help())"} +{"i": 30, "got": "def start_console(local_vars={}):\n \"\"\"pass\"\"\"\n transforms.CONSOLE_ACTIVE = True\n transforms.remove_not_allowed_in_console()\n sys.ps1 = prompt\n console = ExperimentalInteractiveConsole(locals=local_vars)\n console.interact(banner=banner)"} +{"i": 31, "got": "def push(self, line):\n \"\"\"pass\"\"\"\n if transforms.FROM_EXPERIMENTAL.match(line):\n transforms.add_transformers(line)\n self.buffer.append('\\n')\n else:\n self.buffer.append(line)\n add_pass = False\n if line.rstrip(' ').endswith(':'):\n add_pass = True\n source = '\\n'.join(self.buffer)\n if add_pass:\n source += 'pass'\n source = transforms.transform(source)\n if add_pass:\n source = source.rstrip(' ')\n if source.endswith('pass'):\n source = source[:-4]\n if not self.buffer[-1]:\n source += '\\n'\n try:\n more = self.runsource(source, self.filename)\n except SystemExit:\n os._exit(1)\n if not more:\n self.resetbuffer()\n return more"} +{"i": 32, "got": "def license_loader(lic_dir=LIC_DIR):\n \"\"\"pass\"\"\"\n lics = []\n for ln in os.listdir(lic_dir):\n lp = os.path.join(lic_dir, ln)\n with open(lp) as lf:\n txt = lf.read()\n lic = License(txt)\n lics.append(lic)\n return lics"} +{"i": 33, "got": "def get_vector(self, max_choice=3):\n \"\"\"pass\"\"\"\n vec = {}\n for dim in ['forbidden', 'required', 'permitted']:\n if self.meta[dim] is not None:\n dim_vec = map(lambda x: (x, max_choice), self.meta[dim])\n vec[dim] = dict(dim_vec)\n return vec"} +{"i": 34, "got": "def runcommand(cosmology='WMAP5'):\n \"\"\"pass\"\"\"\n Mi = [100000000.0, 1000000000.0, 10000000000.0]\n zi = 0\n print('Concentrations for haloes of mass %s at z=%s' % (Mi, zi))\n output = commah.run(cosmology=cosmology, zi=zi, Mi=Mi)\n print(output['c'].flatten())\n Mi = [100000000.0, 1000000000.0, 10000000000.0]\n zi = 0\n print('Concentrations for haloes of mass %s at z=%s' % (Mi, zi))\n output, cosmo = commah.run(cosmology=cosmology, zi=zi, Mi=Mi, retcosmo=True)\n print(output['c'].flatten())\n print(cosmo)\n Mi = 2000000000000.0\n z = [0, 0.5, 1, 1.5, 2, 2.5]\n output = commah.run(cosmology=cosmology, zi=0, Mi=Mi, z=z)\n for zval in z:\n print('M(z=0)=%s has c(z=%s)=%s' % (Mi, zval, output[output['z'] == zval]['c'].flatten()))\n Mi = 2000000000000.0\n zi = [0, 0.5, 1, 1.5, 2, 2.5]\n output = commah.run(cosmology=cosmology, zi=zi, Mi=Mi)\n for zval in zi:\n print('M(z=%s)=%s has concentration %s' % (zval, Mi, output[(output['zi'] == zval) & (output['z'] == zval)]['c'].flatten()))\n Mi = 200000000000000.0\n zi = 6\n output = commah.run(cosmology=cosmology, zi=zi, Mi=Mi)\n print('Concentrations for haloes of mass %s at z=%s' % (Mi, zi))\n print(output['c'].flatten())\n print('Mass variance sigma of haloes of mass %s at z=%s' % (Mi, zi))\n print(output['sig'].flatten())\n print('Fluctuation for haloes of mass %s at z=%s' % (Mi, zi))\n print(output['nu'].flatten())\n Mi = [100000000.0, 1000000000.0, 10000000000.0]\n zi = [0]\n z = [0, 0.5, 1, 1.5, 2, 2.5]\n output = commah.run(cosmology=cosmology, zi=zi, Mi=Mi, z=z)\n for Mval in Mi:\n print('dM/dt for halo of mass %s at z=%s across redshift %s is: ' % (Mval, zi, z))\n print(output[output['Mi'] == Mval]['dMdt'].flatten())\n M = [100000000.0]\n z = [0, 0.5, 1, 1.5, 2, 2.5]\n print('Halo Mass History for z=0 mass of %s across z=%s' % (M, z))\n output = commah.run(cosmology=cosmology, zi=0, Mi=M, z=z)\n print(output['Mz'].flatten())\n M = [100000000.0, 1000000000.0, 10000000000.0]\n z = [0]\n print('Formation Redshifts for haloes of mass %s at z=%s' % (M, z))\n output = commah.run(cosmology=cosmology, zi=0, Mi=M, z=z)\n for Mval in M:\n print(output[output['Mi'] == Mval]['zf'].flatten())\n return 'Done'"} +{"i": 35, "got": "def plotcommand(cosmology='WMAP5', plotname=None):\n \"\"\"pass\"\"\"\n xarray = 10 ** np.arange(1, 15, 0.2)\n yval = 'c'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass (M$_{sol}$)'\n ytitle = 'Concentration'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n plt.ylim([2, 30])\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.plot(xarray, commah.commah.cduffy(zval, xarray), color='black')\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_CM_relation.png'\" % plotname)\n fig.savefig(plotname + '_CM_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'c'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'NFW Concentration'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_Cz_relation.png'\" % plotname)\n fig.savefig(plotname + '_Cz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'zf'\n zarray = 10 ** np.arange(6, 14, 2)\n xtitle = 'Redshift'\n ytitle = 'Formation Redshift'\n linelabel = 'log$_{10}$ M$_{z}$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_zfz_relation.png'\" % plotname)\n fig.savefig(plotname + '_zfz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'log$_{10}$ (1+z)'\n ytitle = 'log$_{10}$ Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'log$_{10}$ M$_z$(M$_{sol}$)='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n cosmo = commah.getcosmo(cosmology)\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray, com=False, mah=True)\n yarray = output[yval].flatten()\n ax.plot(np.log10(xarray + 1.0), np.log10(yarray) + linelabel + '{0:.1f}'.format(np.log10(zval)), color=colors[zind])\n semianalytic_approx = 71.6 * (zval / 10 ** 9) * (cosmo['h'] / 0.7) * (-0.24 + 0.75 * (xarray + 1) * np.sqrt(cosmo['omega_M_0'] * (xarray + 1) ** 3 + cosmo['omega_lambda_0']))\n ax.plot(np.log10(xarray + 1), np.log10(semianalytic_approx), color='black')\n leg = ax.legend(loc=2)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_dMdtz_relation.png'\" % plotname)\n fig.savefig(plotname + '_dMdtz_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(10, 14, 0.5)\n yval = 'dMdt'\n zarray = np.arange(0, 5, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Accretion Rate M$_{sol}$ yr$^{-1}$'\n linelabel = 'z='\n fig = plt.figure()\n ax = fig.add_subplot(111)\n ax.set_xlabel(xtitle)\n ax.set_ylabel(ytitle)\n colors = cm.rainbow(np.linspace(0, 1, len(zarray)))\n for zind, zval in enumerate(zarray):\n output = commah.run(cosmology=cosmology, zi=zval, Mi=xarray)\n yarray = output[yval].flatten()\n ax.plot(xarray, yarray, label=linelabel + str(zval), color=colors[zind])\n ax.set_xscale('log')\n ax.set_yscale('log')\n leg = ax.legend(loc=1)\n leg.get_frame().set_alpha(0)\n leg.get_frame().set_edgecolor('white')\n for label in leg.get_texts():\n label.set_fontsize('small')\n for label in leg.get_lines():\n label.set_linewidth(4)\n if plotname:\n fig.tight_layout(pad=0.2)\n print(\"Plotting to '%s_MAH_M_relation.png'\" % plotname)\n fig.savefig(plotname + '_MAH_M_relation.png', dpi=fig.dpi * 5)\n else:\n plt.show()\n xarray = 10 ** np.arange(0, 1, 0.05) - 1\n yval = 'dMdt'\n zarray = 10 ** np.arange(10, 14, 0.5)\n xtitle = 'Halo Mass M$_{sol}$'\n ytitle = 'Specific Accretion Rate yr$^{-1}$'\n lin"} +{"i": 36, "got": "def add_transformers(line):\n \"\"\"pass\"\"\"\n assert FROM_EXPERIMENTAL.match(line)\n line = FROM_EXPERIMENTAL.sub(' ', line)\n line = line.split('#')[0]\n for trans in line.replace(' ', '').split(','):\n import_transformer(trans)"} +{"i": 37, "got": "def import_transformer(name):\n \"\"\"pass\"\"\"\n if name in transformers:\n return transformers[name]\n hook = sys.meta_path[0]\n sys.meta_path = sys.meta_path[1:]\n try:\n transformers[name] = __import__(name)\n if CONSOLE_ACTIVE and hasattr(transformers[name], 'NO_CONSOLE'):\n print(transformers[name].NO_CONSOLE)\n transformers[name] = NullTransformer()\n except ImportError:\n sys.stderr.write('Warning: Import Error in add_transformers: %s not found\\n' % name)\n transformers[name] = NullTransformer()\n except Exception as e:\n sys.stderr.write('Unexpected exception in transforms.import_transformer%s\\n ' % e.__class__.__name__)\n finally:\n sys.meta_path.insert(0, hook)\n return transformers[name]"} +{"i": 38, "got": "def extract_transformers_from_source(source):\n \"\"\"pass\"\"\"\n lines = source.split('\\n')\n linenumbers = []\n for number, line in enumerate(lines):\n if FROM_EXPERIMENTAL.match(line):\n add_transformers(line)\n linenumbers.insert(0, number)\n for number in linenumbers:\n del lines[number]\n return '\\n'.join(lines)"} +{"i": 39, "got": "def remove_not_allowed_in_console():\n \"\"\"pass\"\"\"\n not_allowed_in_console = []\n if CONSOLE_ACTIVE:\n for name in transformers:\n tr_module = import_transformer(name)\n if hasattr(tr_module, 'NO_CONSOLE'):\n not_allowed_in_console.append((name, tr_module))\n for name, tr_module in not_allowed_in_console:\n print(tr_module.NO_CONSOLE)\n transformers[name] = NullTransformer()"} +{"i": 40, "got": "def _match(self, request, response):\n \"\"\"pass\"\"\"\n is_html = 'text/html' in response.get('Content-Type', '')\n if is_html and hasattr(response, 'rendered_content'):\n correct_path = PATH_MATCHER.match(request.path) is not None\n not_included = self.include_flag not in response.rendered_content\n return correct_path and not_included\n else:\n return False"} +{"i": 41, "got": "def _chosen_css(self):\n \"\"\"pass\"\"\"\n css = render_to_string(self.css_template, {})\n for sprite in self.chosen_sprites:\n css = css.replace(sprite, settings.STATIC_URL + 'img/' + sprite)\n return css"} +{"i": 42, "got": "def _embed(self, request, response):\n \"\"\"pass\"\"\"\n if self._match(request, response):\n head = render_to_string('chosenadmin/_head_css.html', {'chosen_css': self._chosen_css()})\n body = render_to_string('chosenadmin/_script.html', {'chosen_js': self._chosen_js()})\n content = response.rendered_content\n content = content.replace('', head)\n content = content.replace('', body)\n response.content = content\n return response"} +{"i": 43, "got": "def clean_up(self):\n \"\"\"pass\"\"\"\n self.log.debug('Closing I2C bus for address: 0x%02X' % self.address)\n self.bus.close()"} +{"i": 44, "got": "def write_quick(self):\n \"\"\"pass\"\"\"\n self.bus.write_quick(self.address)\n self.log.debug('write_quick: Sent the read / write bit')"} +{"i": 45, "got": "def write_byte(self, cmd, value):\n \"\"\"pass\"\"\"\n self.bus.write_byte_data(self.address, cmd, value)\n self.log.debug('write_byte: Wrote 0x%02X to command register 0x%02X' % (value, cmd))"} +{"i": 46, "got": "def write_word(self, cmd, value):\n \"\"\"pass\"\"\"\n self.bus.write_word_data(self.address, cmd, value)\n self.log.debug('write_word: Wrote 0x%04X to command register 0x%02X' % (value, cmd))"} +{"i": 47, "got": "def write_raw_byte(self, value):\n \"\"\"pass\"\"\"\n self.bus.write_byte(self.address, value)\n self.log.debug('write_raw_byte: Wrote 0x%02X' % value)"} +{"i": 48, "got": "def write_block_data(self, cmd, block):\n \"\"\"pass\"\"\"\n self.bus.write_i2c_block_data(self.address, cmd, block)\n self.log.debug('write_block_data: Wrote [%s] to command register 0x%02X' % (', '.join(['0x%02X' % x for x in block]), cmd))"} +{"i": 49, "got": "def get_formset(self, request, obj=None, **kwargs):\n \"\"\"pass\"\"\"\n data = super().get_formset(request, obj, **kwargs)\n if obj:\n data.form.base_fields['user'].initial = request.user.id\n return data"} +{"i": 50, "got": "def process_actions(action_ids=None):\n \"\"\"pass\"\"\"\n actions_taken = 0\n action_list = PublishAction.objects.prefetch_related('content_object').filter(scheduled_time__lte=timezone.now())\n if action_ids is not None:\n action_list = action_list.filter(id__in=action_ids)\n for action in action_list:\n action.process_action()\n action.delete()\n actions_taken += 1\n return actions_taken"} +{"i": 51, "got": "def celery_enabled():\n \"\"\"pass\"\"\"\n enabled = getattr(settings, 'GLITTER_PUBLISHER_CELERY', None)\n if enabled is None:\n try:\n import celery\n enabled = True\n except ImportError:\n enabled = False\n return enabled"} +{"i": 52, "got": "def do_command_line(infile: typing.IO[str]) -> int:\n \"\"\"pass\"\"\"\n lines = infile.readlines()\n tree = ast.parse(''.join(lines))\n checker = Checker(tree, lines, infile.name)\n checker.load()\n errors = []\n for func in checker.all_funcs(skip_noqa=True):\n try:\n errors = list(func.check_all())\n except ValidationError as error:\n errors = [error.to_aaa()]\n print(func.__str__(errors), end='')\n return len(errors)"} +{"i": 53, "got": "def _izip(*iterables):\n \"\"\"pass\"\"\"\n iterators = map(iter, iterables)\n while iterators:\n yield tuple(map(next, iterators))"} +{"i": 54, "got": "def _checkinput(zi, Mi, z, verbose=False):\n \"\"\"pass\"\"\"\n zi = np.array(zi, ndmin=1, dtype=float)\n Mi = np.array(Mi, ndmin=1, dtype=float)\n if zi.size > 1 and Mi.size > 1:\n if zi.size != Mi.size:\n print('Error ambiguous request')\n print('Need individual redshifts for all haloes provided ')\n print('Or have all haloes at same redshift ')\n return -1\n elif zi.size == 1 and Mi.size > 1:\n if verbose:\n print('Assume zi is the same for all Mi halo masses provided')\n zi = np.ones_like(Mi) * zi[0]\n elif Mi.size == 1 and zi.size > 1:\n if verbose:\n print('Assume Mi halo masses are the same for all zi provided')\n Mi = np.ones_like(zi) * Mi[0]\n else:\n if verbose:\n print('A single Mi and zi provided')\n if z is False:\n lenzout = 1\n else:\n z = np.array(z, ndmin=1, dtype=float)\n lenzout = z.size\n return (zi, Mi, z, zi.size, Mi.size, lenzout)"} +{"i": 55, "got": "def getcosmo(cosmology):\n \"\"\"pass\"\"\"\n defaultcosmologies = {'dragons': cg.DRAGONS(), 'wmap1': cg.WMAP1_Mill(), 'wmap3': cg.WMAP3_ML(), 'wmap5': cg.WMAP5_mean(), 'wmap7': cg.WMAP7_ML(), 'wmap9': cg.WMAP9_ML(), 'wmap1_lss': cg.WMAP1_2dF_mean(), 'wmap3_mean': cg.WMAP3_mean(), 'wmap5_ml': cg.WMAP5_ML(), 'wmap5_lss': cg.WMAP5_BAO_SN_mean(), 'wmap7_lss': cg.WMAP7_BAO_H0_mean(), 'planck13': cg.Planck_2013(), 'planck15': cg.Planck_2015()}\n if isinstance(cosmology, dict):\n cosmo = cosmology\n if 'A_scaling' not in cosmology.keys():\n A_scaling = getAscaling(cosmology, newcosmo=True)\n cosmo.update({'A_scaling': A_scaling})\n for paramnames in cg.WMAP5_mean().keys():\n if paramnames not in cosmology.keys():\n cosmo.update({paramnames: 0})\n elif cosmology.lower() in defaultcosmologies.keys():\n cosmo = defaultcosmologies[cosmology.lower()]\n A_scaling = getAscaling(cosmology)\n cosmo.update({'A_scaling': A_scaling})\n else:\n print(\"You haven't passed a dict of cosmological parameters \")\n print('OR a recognised cosmology, you gave %s' % cosmology)\n cosmo = cp.distance.set_omega_k_0(cosmo)\n return cosmo"} +{"i": 56, "got": "def _getcosmoheader(cosmo):\n \"\"\"pass\"\"\"\n cosmoheader = '# Cosmology (flat) Om:{0:.3f}, Ol:{1:.3f}, h:{2:.2f}, sigma8:{3:.3f}, ns:{4:.2f}'.format(cosmo['omega_M_0'], cosmo['omega_lambda_0'], cosmo['h'], cosmo['sigma_8'], cosmo['n'])\n return cosmoheader"} +{"i": 57, "got": "def tag(self, tag):\n \"\"\"pass\"\"\"\n url = '%s/tags/%s' % (self, tag)\n response = self.http.get(url, auth=self.auth)\n response.raise_for_status()\n return response.json()"} +{"i": 58, "got": "def release_assets(self, release):\n \"\"\"pass\"\"\"\n release = self.as_id(release)\n return self.get_list(url='%s/%s/assets' % (self, release))"} +{"i": 59, "got": "def upload(self, release, filename, content_type=None):\n \"\"\"pass\"\"\"\n release = self.as_id(release)\n name = os.path.basename(filename)\n if not content_type:\n content_type, _ = mimetypes.guess_type(name)\n if not content_type:\n raise ValueError('content_type not known')\n inputs = {'name': name}\n url = '%s%s/%s/assets' % (self.uploads_url, urlsplit(self.api_url).path, release)\n info = os.stat(filename)\n size = info[stat.ST_SIZE]\n response = self.http.post(url, data=stream_upload(filename), auth=self.auth, params=inputs, headers={'content-type': content_type, 'content-length': str(size)})\n response.raise_for_status()\n return response.json()"} +{"i": 60, "got": "def validate_tag(self, tag_name, prefix=None):\n \"\"\"pass\"\"\"\n new_version = semantic_version(tag_name)\n current = self.latest()\n if current:\n tag_name = current['tag_name']\n if prefix:\n tag_name = tag_name[len(prefix):]\n tag_name = semantic_version(tag_name)\n if tag_name >= new_version:\n what = 'equal to' if tag_name == new_version else 'older than'\n raise GithubException('Your local version \"%s\" is %s the current github version \"%s\".\\nBump the local version to continue.' % (str(new_version), what, str(tag_name)))\n return current"} +{"i": 61, "got": "def is_related_to(item, app_id, app_ver=None):\n \"\"\"pass\"\"\"\n versionRange = item.get('versionRange')\n if not versionRange:\n return True\n for vR in versionRange:\n if not vR.get('targetApplication'):\n return True\n if get_related_targetApplication(vR, app_id, app_ver) is not None:\n return True\n return False"} +{"i": 62, "got": "def get_related_targetApplication(vR, app_id, app_ver):\n \"\"\"pass\"\"\"\n targetApplication = vR.get('targetApplication')\n if not targetApplication:\n return None\n for tA in targetApplication:\n guid = tA.get('guid')\n if not guid or guid == app_id:\n continue\n if not app_ver:\n return tA\n if between(version_int(app_ver), '0', tA.get('maxVersion', '*')):\n return tA"} +{"i": 63, "got": "def write_addons_items(xml_tree, records, app_id, api_ver=3, app_ver=None):\n \"\"\"pass\"\"\"\n if not records:\n return\n emItems = etree.SubElement(xml_tree, 'emItems')\n groupby = {}\n for item in records:\n if is_related_to(item, app_id, app_ver):\n if item['guid'] in groupby:\n emItem = groupby[item['guid']]\n if 'blockID' in item:\n current_blockID = int(item['blockID'][1:])\n previous_blockID = int(emItem.attrib['blockID'][1:])\n if current_blockID > previous_blockID:\n emItem.attrib['blockID'] = item['blockID']\n else:\n emItem.attrib['blockID'] = item['id']\n else:\n emItem = etree.SubElement(emItems, 'emItem', blockID=item.get('blockID', item['id']))\n groupby[item['guid']] = emItem\n prefs = etree.SubElement(emItem, 'prefs')\n for p in item['prefs']:\n pref = etree.SubElement(prefs, 'pref')\n pref.text = p\n emItem.set('id', item['guid'])\n for field in ['name', 'os']:\n if field in item:\n emItem.set(field, item[field])\n build_version_range(emItem, item, app_id)"} +{"i": 64, "got": "def write_plugin_items(xml_tree, records, app_id, api_ver=3, app_ver=None):\n \"\"\"pass\"\"\"\n if not records:\n return\n pluginItems = etree.SubElement(xml_tree, 'pluginItems')\n for item in records:\n for versionRange in item.get('versionRange', []):\n if not versionRange.get('targetApplication'):\n add_plugin_item(pluginItems, item, versionRange, app_id=app_id, api_ver=api_ver, app_ver=app_ver)\n else:\n targetApplication = get_related_targetApplication(versionRange, app_id, app_ver)\n if targetApplication is not None:\n add_plugin_item(pluginItems, item, versionRange, targetApplication, app_id=app_id, api_ver=api_ver, app_ver=app_ver)"} +{"i": 65, "got": "def write_gfx_items(xml_tree, records, app_id, api_ver=3):\n \"\"\"pass\"\"\"\n if not records:\n return\n gfxItems = etree.SubElement(xml_tree, 'gfxItems')\n for item in records:\n is_record_related = 'guid' not in item or item['guid'] == app_id\n if not is_record_related:\n continue\n entry = etree.SubElement(gfxItems, 'gfxBlacklistEntry', blockID=item.get('blockID', item['id']))\n fields = ['os', 'vendor', 'feature', 'featureStatus', 'driverVersion', 'driverVersionComparator']\n for field in fields:\n if field in item:\n node = etree.SubElement(entry, field)\n node.text = item[field]\n if item['devices']:\n devices = etree.SubElement(entry, 'devices')\n for d in item['devices']:\n device = etree.SubElement(devices, 'device')\n device.text = d\n if 'versionRange' in item:\n version = item['versionRange']\n versionRange = etree.SubElement(entry, 'versionRange')\n for field in ['minVersion', 'maxVersion']:\n value = version.get(field)\n if value:\n versionRange.set(field, str(value))"} +{"i": 66, "got": "def write_cert_items(xml_tree, records, api_ver=3, app_id=None, app_ver=None):\n \"\"\"pass\"\"\"\n if not records or not should_include_certs(app_id, app_ver):\n return\n certItems = etree.SubElement(xml_tree, 'certItems')\n for item in records:\n if item.get('subject') and item.get('pubKeyHash'):\n cert = etree.SubElement(certItems, 'certItem', subject=item['subject'], pubKeyHash=item['pubKeyHash'])\n else:\n cert = etree.SubElement(certItems, 'certItem', issuerName=item['issuerName'])\n serialNumber = etree.SubElement(cert, 'serialNumber')\n serialNumber.text = item['serialNumber']"} +{"i": 67, "got": "def label(self, name, color, update=True):\n \"\"\"pass\"\"\"\n url = '%s/labels' % self\n data = dict(name=name, color=color)\n response = self.http.post(url, json=data, auth=self.auth, headers=self.headers)\n if response.status_code == 201:\n return True\n elif response.status_code == 422 and update:\n url = '%s/%s' % (url, name)\n response = self.http.patch(url, json=data, auth=self.auth, headers=self.headers)\n response.raise_for_status()\n return False"} +{"i": 68, "got": "def get_interval_timedelta(self):\n \"\"\"pass\"\"\"\n now_datetime = timezone.now()\n current_month_days = monthrange(now_datetime.year, now_datetime.month)[1]\n if self.interval == reminders_choices.INTERVAL_2_WEEKS:\n interval_timedelta = datetime.timedelta(days=14)\n elif self.interval == reminders_choices.INTERVAL_ONE_MONTH:\n interval_timedelta = datetime.timedelta(days=current_month_days)\n elif self.interval == reminders_choices.INTERVAL_THREE_MONTHS:\n three_months = now_datetime + relativedelta(months=3)\n interval_timedelta = three_months - now_datetime\n elif self.interval == reminders_choices.INTERVAL_SIX_MONTHS:\n six_months = now_datetime + relativedelta(months=6)\n interval_timedelta = six_months - now_datetime\n elif self.interval == reminders_choices.INTERVAL_ONE_YEAR:\n one_year = now_datetime + relativedelta(years=1)\n interval_timedelta = one_year - now_datetime\n return interval_timedelta"} +{"i": 69, "got": "def _build_mappings(self, classes: Sequence[type]) -> Tuple[Mapping[type, Sequence[type]], Mapping[type, Sequence[type]]]:\n \"\"\"pass\"\"\"\n parents_to_children = {}\n children_to_parents = {}\n visited_classes = set()\n class_stack = list(classes)\n while class_stack:\n class_ = class_stack.pop()\n if class_ in visited_classes:\n continue\n visited_classes.add(class_)\n for base in class_.__bases__:\n if base not in visited_classes:\n class_stack.append(base)\n parents_to_children.setdefault(base, set()).add(class_)\n children_to_parents.setdefault(class_, set()).add(base)\n sorted_parents_to_children = collections.OrderedDict()\n for parent, children in sorted(parents_to_children.items(), key=lambda x: (x[0].__module__, x[0].__name__)):\n sorted_parents_to_children[parent] = sorted(children, key=lambda x: (x.__module__, x.__name__))\n sorted_children_to_parents = collections.OrderedDict()\n for child, parents in sorted(children_to_parents.items(), key=lambda x: (x[0].__module__, x[0].__name__)):\n sorted_children_to_parents[child] = sorted(parents, key=lambda x: (x.__module__, x.__name__))\n return (sorted_parents_to_children, sorted_children_to_parents)"} +{"i": 70, "got": "def _collect_classes(self, package_paths: Sequence[str], recurse_subpackages=True) -> Sequence[type]:\n \"\"\"pass\"\"\"\n import uqbar.apis\n classes = []\n initial_source_paths = set()\n for path in package_paths:\n try:\n module = importlib.import_module(path)\n if hasattr(module, '__path__'):\n initial_source_paths.update(getattr(module, '__path__'))\n else:\n initial_source_paths.add(module.__file__)\n except ModuleNotFoundError:\n path, _, class_name = path.rpartition('.')\n module = importlib.import_module(path)\n classes.append(getattr(module, class_name))\n for source_path in uqbar.apis.collect_source_paths(initial_source_paths, recurse_subpackages=recurse_subpackages):\n package_path = uqbar.apis.source_path_to_package_path(source_path)\n module = importlib.import_module(package_path)\n for name in dir(module):\n if not name.startswith('_'):\n object_ = getattr(module, name)\n if isinstance(object_, type) and object_.__module__ == module.__name__:\n classes.append(object_)\n return sorted(classes, key=lambda x: (x.__module__, x.__name__))"} +{"i": 71, "got": "def find_common_prefix(paths: Sequence[Union[str, pathlib.Path]]) -> Optional[pathlib.Path]:\n \"\"\"pass\"\"\"\n counter = collections.Counter()\n for path in paths:\n path = pathlib.Path(path)\n counter.update([path])\n counter.update(path.parents)\n valid_paths = sorted([path for path, count in counter.items() if count >= len(paths)], key=lambda x: len(x.parts))\n if valid_paths:\n return valid_paths[-1]\n else:\n return None"} +{"i": 72, "got": "def find_executable(name: str, flags=os.X_OK) -> List[str]:\n \"\"\"pass\"\"\"\n result = []\n extensions = [x for x in os.environ.get('PATHEXT', '').split(os.pathsep) if x]\n path = os.environ.get('PATH', None)\n if path is None:\n return []\n for path in os.environ.get('PATH', '').split(os.pathsep):\n path = os.path.join(path, name)\n if os.access(path, flags):\n result.append(path)\n for extension in extensions:\n path_extension = path + extension\n if os.access(path_extension, flags):\n result.append(path_extension)\n return result"} +{"i": 73, "got": "def relative_to(source_path: Union[str, pathlib.Path], target_path: Union[str, pathlib.Path]) -> pathlib.Path:\n \"\"\"pass\"\"\"\n source_path = pathlib.Path(source_path).absolute()\n if source_path.is_file():\n source_path = source_path.parent\n target_path = pathlib.Path(target_path).absolute()\n common_prefix = find_common_prefix([source_path, target_path])\n if not common_prefix:\n raise ValueError('No common prefix')\n source_path = source_path.relative_to(common_prefix)\n target_path = target_path.relative_to(common_prefix)\n result = pathlib.Path(['..'] * len(source_path.parts))\n return result / target_path"} +{"i": 74, "got": "def walk(root_path: Union[str, pathlib.Path], top_down: bool=True) -> Generator[Tuple[pathlib.Path, Sequence[pathlib.Path], Sequence[pathlib.Path]], None, None]:\n \"\"\"pass\"\"\"\n root_path = pathlib.Path(root_path)\n directory_paths, file_paths = ([], [])\n for path in sorted(root_path.iterdir()):\n if path.is_dir():\n directory_paths.append(path)\n else:\n file_paths.append(path)\n if top_down:\n yield (root_path, directory_paths, file_paths)\n for directory_path in directory_paths:\n yield from walk(directory_path, top_down=top_down)\n if not top_down:\n yield (root_path, directory_paths, file_paths)"} +{"i": 75, "got": "def run(self) -> Generator[Tuple[int, int, str, type], None, None]:\n \"\"\"pass\"\"\"\n if is_test_file(self.filename):\n self.load()\n for func in self.all_funcs():\n try:\n for error in func.check_all():\n yield (error.line_number, error.offset, error.text, Checker)\n except ValidationError as error:\n yield error.to_flake8(Checker)"} +{"i": 76, "got": "def make_driver(loop=None):\n \"\"\"pass\"\"\"\n loop = loop or asyncio.get_event_loop()\n\n def stop(i=None):\n loop.stop()\n\n def driver(sink):\n \"\"\"pass\"\"\"\n sink.control.subscribe(on_next=stop, on_error=stop, on_completed=stop)\n return Component(call=driver, input=Sink)"} +{"i": 77, "got": "def _stdin_(p):\n \"\"\"pass\"\"\"\n _v = sys.version[0]\n if _v is '3':\n return input(p)\n else:\n return raw_input(p)"} +{"i": 78, "got": "def survey_loader(sur_dir=SUR_DIR, sur_file=SUR_FILE):\n \"\"\"pass\"\"\"\n survey_path = os.path.join(sur_dir, sur_file)\n survey = None\n with open(survey_path) as survey_file:\n survey = Survey(survey_file.read())\n return survey"} +{"i": 79, "got": "def format_choices(self):\n \"\"\"pass\"\"\"\n ce = enumerate(self.choices)\n f = lambda i, c: '%s (%d)' % (c, i + 1)\n toks = [f(i, c) for i, c in ce] + ['Help (?)']\n return ' '.join(toks)"} +{"i": 80, "got": "def is_answer_valid(self, ans):\n \"\"\"pass\"\"\"\n return ans in [str(i + 1) for i in range(len(self.choices))]"} +{"i": 81, "got": "def update(self, span: typing.Tuple[int, int], line_type: LineType) -> None:\n \"\"\"pass\"\"\"\n first_block_line, last_block_line = span\n for i in range(first_block_line, last_block_line + 1):\n try:\n self.__setitem__(i, line_type)\n except ValueError as error:\n raise ValidationError(i + self.fn_offset, 1, 'AAA99 {}'.format(error))"} +{"i": 82, "got": "def check_arrange_act_spacing(self) -> typing.Generator[AAAError, None, None]:\n \"\"\"pass\"\"\"\n yield from self.check_block_spacing(LineType.arrange, LineType.act, 'AAA03 expected 1 blank line before Act block, found {}')"} +{"i": 83, "got": "def check_act_assert_spacing(self) -> typing.Generator[AAAError, None, None]:\n \"\"\"pass\"\"\"\n yield from self.check_block_spacing(LineType.act, LineType._assert, 'AAA04 expected 1 blank line before Assert block, found {}')"} +{"i": 84, "got": "def check_block_spacing(self, first_block_type: LineType, second_block_type: LineType, error_message: str) -> typing.Generator[AAAError, None, None]:\n \"\"\"pass\"\"\"\n numbered_lines = list(enumerate(self))\n first_block_lines = filter(lambda l: l[1] is first_block_type, numbered_lines)\n try:\n first_block_lineno = list(first_block_lines)[-1][0]\n except IndexError:\n return\n second_block_lines = filter(lambda l: l[1] is second_block_type, numbered_lines)\n try:\n second_block_lineno = next(second_block_lines)[0]\n except StopIteration:\n return\n blank_lines = [bl for bl in numbered_lines[first_block_lineno + 1:second_block_lineno] if bl[1] is LineType.blank_line]\n if not blank_lines:\n yield AAAError(line_number=self.fn_offset + second_block_lineno - 1, offset=0, text=error_message.format('none'))\n elif len(blank_lines) > 1:\n yield AAAError(line_number=self.fn_offset + blank_lines[1][0], offset=0, text=error_message.format(len(blank_lines)))"} +{"i": 85, "got": "def get_access_token(self, code):\n \"\"\"pass\"\"\"\n try:\n self._token = super().fetch_token(MINUT_TOKEN_URL, client_id=self._client_id, client_secret=self._client_secret, code=code)\n except MissingTokenError as error:\n _LOGGER.debug('Token issues: %s', error)\n return self._token"} +{"i": 86, "got": "def _request(self, url, request_type='GET', **params):\n \"\"\"pass\"\"\"\n try:\n _LOGGER.debug('Request %s %s', url, params)\n response = self.request(request_type, url, timeout=TIMEOUT.seconds, **params)\n response.raise_for_status()\n _LOGGER.debug('Response %s %s %.200s', response.status_code, response.headers['content-type'], response.json())\n response = response.json()\n if 'error' in response:\n raise OSError(response['error'])\n return response\n except OSError as error:\n _LOGGER.warning('Failed request: %s', error)\n return None"} +{"i": 87, "got": "def _request_devices(self, url, _type):\n \"\"\"pass\"\"\"\n res = self._request(url)\n return res.get(_type) if res else {}"} +{"i": 88, "got": "def read_sensor(self, device_id, sensor_uri):\n \"\"\"pass\"\"\"\n url = MINUT_DEVICES_URL + '/{device_id}/{sensor_uri}'.format(device_id=device_id, sensor_uri=sensor_uri)\n res = self._request(url, request_type='GET', data={'limit': 1})\n if not res.get('values'):\n return None\n return res.get('values')[-1].get('value')"} +{"i": 89, "got": "def _register_webhook(self, webhook_url, events):\n \"\"\"pass\"\"\"\n response = self._request(MINUT_WEBHOOKS_URL, request_type='POST', json={'url': webhook_url, 'events': events})\n return response"} +{"i": 90, "got": "def remove_webhook(self):\n \"\"\"pass\"\"\"\n if self._webhook.get('hook_id'):\n self._request('{}/{}'.format(MINUT_WEBHOOKS_URL, self._webhook['hook_id']), request_type='DELETE')"} +{"i": 91, "got": "def _get_ip():\n \"\"\"pass\"\"\"\n cmd_netstat = ['netstat', '-nr']\n p1 = subprocess.Popen(cmd_netstat, stdout=subprocess.PIPE)\n cmd_grep = ['grep', '^0\\\\.0\\\\.0\\\\.0']\n p2 = subprocess.Popen(cmd_grep, stdin=p1.stdout, stdout=subprocess.PIPE)\n cmd_awk = ['awk', '{ print $2 }']\n p3 = subprocess.Popen(cmd_awk, stdin=p2.stdout, stdout=subprocess.PIPE)\n galaxy_ip = p3.stdout.read()\n log.debug('Host IP determined to be %s', galaxy_ip)\n return galaxy_ip"} +{"i": 92, "got": "def get_galaxy_connection(history_id=None, obj=True):\n \"\"\"pass\"\"\"\n history_id = history_id or os.environ['HISTORY_ID']\n key = os.environ['API_KEY']\n galaxy_ip = _get_ip()\n url = Template(os.environ['GALAXY_URL']).safe_substitute({'DOCKER_HOST': galaxy_ip})\n gi = _test_url(url, key, history_id, obj=obj)\n if gi is not None:\n return gi\n app_path = os.environ['GALAXY_URL'].rstrip('/')\n app_path = ''.join(app_path.split('/')[3:])\n if 'GALAXY_WEB_PORT' not in os.environ:\n raise Exception('No port')\n galaxy_port = os.environ['GALAXY_WEB_PORT']\n built_galaxy_url = 'http://%s:%s/%s' % (galaxy_ip.strip(), galaxy_port, app_path.strip())\n url = built_galaxy_url.rstrip('/')\n gi = _test_url(url, key, history_id, obj=obj)\n if gi is not None:\n return gi\n msg = 'Could not connect to a galaxy instance. Please contact your SysAdmin for help with this error'\n raise Exception(msg)"} +{"i": 93, "got": "def put(filenames, file_type='auto', history_id=None):\n \"\"\"pass\"\"\"\n history_id = history_id or os.environ['HISTORY_ID']\n gi = get_galaxy_connection(history_id=history_id)\n for filename in filenames:\n log.debug('Uploading gx=%s history=%s localpath=%s ft=%s', gi, history_id, filename, file_type)\n history = gi.histories.get(history_id)\n history.upload_dataset(filename, file_type=file_type)"} +{"i": 94, "got": "def get(datasets_identifiers, identifier_type='hid', history_id=None):\n \"\"\"pass\"\"\"\n history_id = history_id or os.environ['HISTORY_ID']\n gi = get_galaxy_connection(history_id=history_id, obj=False)\n for dataset_identifier in datasets_identifiers:\n file_path = '/import/%s' % dataset_identifier\n log.debug('Downloading gx=%s history=%s dataset=%s', gi, history_id, dataset_identifier)\n if not os.path.exists(file_path):\n hc = HistoryClient(gi)\n dc = DatasetClient(gi)\n history = hc.show_history(history_id, contents=True)\n datasets = {ds[identifier_type]: ds['id'] for ds in history}\n if identifier_type == 'hid':\n dataset_identifier = int(dataset_identifier)\n dc.download_dataset(datasets[dataset_identifier], file_path=file_path, use_default_filename=False)\n else:\n log.debug('Cached, not re-downloading')\n return file_path"} +{"i": 95, "got": "def get_user_history(history_id=None):\n \"\"\"pass\"\"\"\n history_id = history_id or os.environ['HISTORY_ID']\n gi = get_galaxy_connection(history_id=history_id, obj=False)\n hc = HistoryClient(gi)\n history = hc.show_history(history_id, visible=True, contents=True)\n return history"} +{"i": 96, "got": "def get_user_sets(client_id, user_id):\n \"\"\"pass\"\"\"\n data = api_call('get', 'users/{}/sets'.format(user_id), client_id=client_id)\n return [WordSet.from_dict(wordset) for wordset in data]"} +{"i": 97, "got": "def print_user_sets(wordsets, print_terms):\n \"\"\"pass\"\"\"\n if not wordsets:\n print('No sets found')\n return\n print('Found sets: {}'.format(len(wordsets)))\n for wordset in wordsets:\n print(' {}'.format(wordset))\n if print_terms:\n for term in wordset.terms:\n print(' {}'.format(term))"} +{"i": 98, "got": "def get_common_terms(*api_envs):\n \"\"\"pass\"\"\"\n common_terms = []\n wordsets = get_user_sets(*api_envs)\n for wordset1, wordset2 in combinations(wordsets, 2):\n common = wordset1.has_common(wordset2)\n if common:\n common_terms.append((wordset1.title, wordset2.title, common))\n return common_terms"} +{"i": 99, "got": "def print_common_terms(common_terms):\n \"\"\"pass\"\"\"\n if not common_terms:\n print('No duplicates')\n return\n for set_pair in common_terms:\n set1, set2, terms = set_pair\n print('{} and {} have in common:'.format(set1, set2))\n for term in terms:\n print(' {}'.format(term))"} +{"i": 100, "got": "def run(entry_point, drivers, loop=None):\n \"\"\"pass\"\"\"\n program = setup(entry_point, drivers)\n dispose = program.run()\n if loop == None:\n loop = asyncio.get_event_loop()\n loop.run_forever()\n dispose()"} +{"i": 101, "got": "def compare_schemas(one, two):\n \"\"\"pass\"\"\"\n one = _normalize_string_type(one)\n two = _normalize_string_type(two)\n _assert_same_types(one, two)\n if isinstance(one, list):\n return _compare_lists(one, two)\n elif isinstance(one, dict):\n return _compare_dicts(one, two)\n elif isinstance(one, SCALAR_TYPES):\n return one == two\n elif one is None:\n return one is two\n else:\n raise RuntimeError('Not allowed type \"{type}\"'.format(type=type(one).__name__))"} +{"i": 102, "got": "def is_ecma_regex(regex):\n \"\"\"pass\"\"\"\n parts = regex.split('/')\n if len(parts) == 1:\n return False\n elif len(parts) < 3:\n raise ValueError(\"Given regex isn't ECMA regex nor Python regex.\")\n else:\n parts.pop()\n parts.append('')\n raw_regex = '/'.join(parts)\n if raw_regex.startswith('/') and raw_regex.endswith('/'):\n return True\n else:\n return False"} +{"i": 103, "got": "def convert_ecma_regex_to_python(value):\n \"\"\"pass\"\"\"\n if not is_ecma_regex(value):\n return PythonRegex(value, [])\n parts = value.split('/')\n flags = parts.pop()\n try:\n result_flags = [ECMA_TO_PYTHON_FLAGS[f] for f in flags]\n except KeyError:\n raise ValueError('Wrong flags \"{}\".'.format(flags))\n return PythonRegex('/'.join(parts[1:]), result_flags)"} +{"i": 104, "got": "def convert_python_regex_to_ecma(value, flags=[]):\n \"\"\"pass\"\"\"\n if is_ecma_regex(value):\n return value\n result_flags = [PYTHON_TO_ECMA_FLAGS[f] for f in flags]\n result_flags = ''.join(result_flags)\n return '/{value}/{flags}'.format(value=value, flags=result_flags)"} +{"i": 105, "got": "def populate(self, **values):\n \"\"\"pass\"\"\"\n values = values.copy()\n fields = list(self.iterate_with_name())\n for _, structure_name, field in fields:\n if structure_name in values:\n field.__set__(self, values.pop(structure_name))\n for name, _, field in fields:\n if name in values:\n field.__set__(self, values.pop(name))"} +{"i": 106, "got": "def get_field(self, field_name):\n \"\"\"pass\"\"\"\n for attr_name, field in self:\n if field_name == attr_name:\n return field\n raise errors.FieldNotFound('Field not found', field_name)"} +{"i": 107, "got": "def write(self, rows, keyed=False):\n \"\"\"pass\"\"\"\n for row in rows:\n keyed_row = row\n if not keyed:\n keyed_row = dict(zip(self.__schema.field_names, row))\n keyed_row = self.__convert_row(keyed_row)\n if self.__check_existing(keyed_row):\n for wr in self.__insert():\n yield wr\n ret = self.__update(keyed_row)\n if ret is not None:\n yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)\n else:\n self.__buffer.append(keyed_row)\n while len(self.__buffer) > BUFFER_SIZE:\n for wr in self.__insert():\n yield wr\n for wr in self.__insert():\n yield wr"} +{"i": 108, "got": "def __prepare_bloom(self):\n \"\"\"pass\"\"\"\n self.__bloom = pybloom_live.ScalableBloomFilter()\n columns = [getattr(self.__table.c, key) for key in self.__update_keys]\n keys = select(columns).execution_options(stream_results=True).execute()\n for key in keys:\n self.__bloom.add(tuple(key))"} +{"i": 109, "got": "def __insert(self):\n \"\"\"pass\"\"\"\n if len(self.__buffer) > 0:\n statement = self.__table.insert()\n if self.__autoincrement:\n statement = statement.returning(getattr(self.__table.c, self.__autoincrement))\n statement = statement.values(self.__buffer)\n res = statement.execute()\n for id in res:\n row = self.__buffer.pop(0)\n yield WrittenRow(row, False, id)\n else:\n statement.execute(self.__buffer)\n for row in self.__buffer:\n yield WrittenRow(row, False, None)\n self.__buffer = []"} +{"i": 110, "got": "def __update(self, row):\n \"\"\"pass\"\"\"\n expr = self.__table.update().values(row)\n for key in self.__update_keys:\n expr = expr.where(getattr(self.__table.c, key) == row[key])\n if self.__autoincrement:\n expr = expr.returning(getattr(self.__table.c, self.__autoincrement))\n res = expr.execute()\n if res.rowcount > 0:\n if self.__autoincrement:\n first = next(iter(res))\n last_row_id = first[0]\n return last_row_id\n else:\n return 0"} +{"i": 111, "got": "def __check_existing(self, row):\n \"\"\"pass\"\"\"\n if self.__update_keys is not None:\n key = tuple((row[key] for key in self.__update_keys))\n if key in self.__bloom:\n return True\n else:\n self.__bloom.add(key)\n return False\n else:\n return False"} +{"i": 112, "got": "def buckets(self):\n \"\"\"pass\"\"\"\n buckets = []\n for table in self.__metadata.sorted_tables:\n bucket = self.__mapper.restore_bucket(table.name)\n if bucket is not None:\n buckets.append(bucket)\n return buckets"} +{"i": 113, "got": "def open_hierarchy(self, path, relative_to_object_id, object_id, create_file_type=0):\n \"\"\"pass\"\"\"\n try:\n return self.process.OpenHierarchy(path, relative_to_object_id, '', create_file_type)\n except Exception as e:\n print(e)\n print('Could not Open Hierarchy')"} +{"i": 114, "got": "def create_new_page(self, section_id, new_page_style=0):\n \"\"\"pass\"\"\"\n try:\n self.process.CreateNewPage(section_id, '', new_page_style)\n except Exception as e:\n print(e)\n print('Unable to create the page')"} +{"i": 115, "got": "def get_page_content(self, page_id, page_info=0):\n \"\"\"pass\"\"\"\n try:\n return self.process.GetPageContent(page_id, '', page_info)\n except Exception as e:\n print(e)\n print('Could not get Page Content')\n return None"} +{"i": 116, "got": "def publish(self, hierarchy_id, target_file_path, publish_format, clsid_of_exporter=''):\n \"\"\"pass\"\"\"\n try:\n self.process.Publish(hierarchy_id, target_file_path, publish_format, clsid_of_exporter)\n except Exception as e:\n print(e)\n print('Could not Publish')"} +{"i": 117, "got": "def get_special_location(self, special_location=0):\n \"\"\"pass\"\"\"\n try:\n return self.process.GetSpecialLocation(special_location)\n except Exception as e:\n print(e)\n print('Could not retreive special location')\n return None"} +{"i": 118, "got": "def memory():\n \"\"\"pass\"\"\"\n mem_info = dict()\n for k, v in psutil.virtual_memory()._asdict().items():\n mem_info[k] = int(v)\n return mem_info"} +{"i": 119, "got": "def get_chunk_size(N, n):\n \"\"\"pass\"\"\"\n mem_free = memory()['free']\n if mem_free > 60000000:\n chunk_size = int((mem_free - 10000000) * 1000 / (4 * n * N))\n elif mem_free > 40000000:\n chunk_size = int((mem_free - 7000000) * 1000 / (4 * n * N))\n elif mem_free > 14000000:\n chunk_size = int((mem_free - 2000000) * 1000 / (4 * n * N))\n elif mem_free > 8000000:\n chunk_size = int((mem_free - 1400000) * 1000 / (4 * n * N))\n elif mem_free > 2000000:\n chunk_size = int((mem_free - 900000) * 1000 / (4 * n * N))\n elif mem_free > 1000000:\n chunk_size = int((mem_free - 400000) * 1000 / (4 * n * N))\n else:\n print('\\nERROR: Cluster_Ensembles: get_chunk_size: this machine does not have enough free memory resources to perform ensemble clustering.\\n')\n sys.exit(1)\n return chunk_size"} +{"i": 120, "got": "def get_compression_filter(byte_counts):\n \"\"\"pass\"\"\"\n assert isinstance(byte_counts, numbers.Integral) and byte_counts > 0\n if 2 * byte_counts > 1000 * memory()['free']:\n try:\n FILTERS = tables.filters(complevel=5, complib='blosc', shuffle=True, least_significant_digit=6)\n except tables.FiltersWarning:\n FILTERS = tables.filters(complevel=5, complib='lzo', shuffle=True, least_significant_digit=6)\n else:\n FILTERS = None\n return FILTERS"} +{"i": 121, "got": "def build_hypergraph_adjacency(cluster_runs):\n \"\"\"pass\"\"\"\n N_runs = cluster_runs.shape[0]\n hypergraph_adjacency = create_membership_matrix(cluster_runs[0])\n for i in range(1, N_runs):\n hypergraph_adjacency = scipy.sparse.vstack([hypergraph_adjacency, create_membership_matrix(cluster_runs[i])], format='csr')\n return hypergraph_adjacency"} +{"i": 122, "got": "def store_hypergraph_adjacency(hypergraph_adjacency, hdf5_file_name):\n \"\"\"pass\"\"\"\n assert hypergraph_adjacency.__class__ == scipy.sparse.csr.csr_matrix\n byte_counts = hypergraph_adjacency.data.nbytes + hypergraph_adjacency.indices.nbytes + hypergraph_adjacency.indptr.nbytes\n FILTERS = get_compression_filter(byte_counts)\n with tables.open_file(hdf5_file_name, 'r+') as fileh:\n for par in ['data', 'indices', 'indptr', 'shape']:\n try:\n n = getattr(fileh.root.consensus_group, par)\n n._f_remove()\n except AttributeError:\n pass\n array = np.array(getattr(hypergraph_adjacency, par))\n atom = tables.Atom.from_dtype(array.dtype)\n ds = fileh.create_carray(fileh.root.consensus_group, par, atom, array.shape, filters=FILTERS)\n ds[:] = array"} +{"i": 123, "got": "def load_hypergraph_adjacency(hdf5_file_name):\n \"\"\"pass\"\"\"\n with tables.open_file(hdf5_file_name, 'r+') as fileh:\n pars = []\n for par in ['data', 'indices', 'indptr', 'shape']:\n pars.append(getattr(fileh.root.consensus_group, par).read())\n hypergraph_adjacency = scipy.sparse.csr_matrix(tuple(pars[:3]), shape=pars[3])\n return hypergraph_adjacency"} +{"i": 124, "got": "def obfuscate(p, action):\n \"\"\"pass\"\"\"\n key = 'ru7sll3uQrGtDPcIW3okutpFLo6YYtd5bWSpbZJIopYQ0Du0a1WlhvJOaZEH'\n s = list()\n if action == 'store':\n if PY2:\n for i in range(len(p)):\n kc = key[i % len(key)]\n ec = chr((ord(p[i]) + ord(kc)) % 256)\n s.append(ec)\n else:\n return base64.urlsafe_b64encode(p.encode()).decode()\n elif PY2:\n e = base64.urlsafe_b64decode(p)\n for i in range(len(e)):\n kc = key[i % len(key)]\n dc = chr((256 + ord(e[i]) - ord(kc)) % 256)\n s.append(dc)\n return ''.join(s)\n else:\n e = base64.urlsafe_b64decode(p)\n return e.decode()"} +{"i": 125, "got": "def _config_bootstrap(self):\n \"\"\"pass\"\"\"\n if not os.path.exists(CONFIG_PATH):\n os.makedirs(CONFIG_PATH)\n if not os.path.exists(CONFIG_FILE):\n json.dump(CONFIG_DEFAULTS, open(CONFIG_FILE, 'w'), indent=4, separators=(',', ': '))\n config = CONFIG_DEFAULTS\n if self._email and self._password:\n config['email'] = self._email\n config['password'] = str(obfuscate(self._password, 'store'))\n self._log.debug('Caching authentication in config file')\n json.dump(config, open(CONFIG_FILE, 'w'), indent=4, separators=(',', ': '))\n else:\n config = json.load(open(CONFIG_FILE))\n if config.get('py2', PY2) != PY2:\n raise Exception('Python versions have changed. Please run `setup` again to reconfigure the client.')\n if config['email'] and config['password']:\n self._email = config['email']\n self._password = obfuscate(str(config['password']), 'fetch')\n self._log.debug('Loaded authentication from config file')"} +{"i": 126, "got": "def _session_check(self):\n \"\"\"pass\"\"\"\n if not os.path.exists(SESSION_FILE):\n self._log.debug('Session file does not exist')\n return False\n with open(SESSION_FILE, 'rb') as f:\n cookies = requests.utils.cookiejar_from_dict(pickle.load(f))\n self._session.cookies = cookies\n self._log.debug('Loaded cookies from session file')\n response = self._session.get(url=self.TEST_URL, headers=self.HEADERS)\n if self.TEST_KEY in str(response.content):\n self._log.debug('Session file appears invalid')\n return False\n else:\n self._is_authenticated = True\n self._process_state()\n return True"} +{"i": 127, "got": "def _logger(self):\n \"\"\"pass\"\"\"\n logger = logging.getLogger(self.NAME)\n logger.setLevel(self.LOG_LEVEL)\n shandler = logging.StreamHandler(sys.stdout)\n fmt = '\\x1b[1;32m%(levelname)-5s %(module)s:%(funcName)s():'\n fmt += '%(lineno)d %(asctime)s\\x1b[0m| %(message)s'\n shandler.setFormatter(logging.Formatter(fmt))\n logger.addHandler(shandler)\n return logger"} +{"i": 128, "got": "def set_log_level(self, level):\n \"\"\"pass\"\"\"\n if level == 'info':\n level = logging.INFO\n if level == 'debug':\n level = logging.DEBUG\n if level == 'error':\n level = logging.ERROR\n self._log.setLevel(level)"} +{"i": 129, "got": "def _process_state(self):\n \"\"\"pass\"\"\"\n self._log.debug('Capturing state from the request')\n response = self._session.get(url=self.ALERTS_URL, headers=self.HEADERS)\n soup = BeautifulSoup(response.content, 'html.parser')\n for i in soup.findAll('script'):\n if i.text.find('window.STATE') == -1:\n continue\n state = json.loads(i.text[15:-1])\n if state != '':\n self._state = state\n self._log.debug('State value set: %s' % self._state)\n return self._state"} +{"i": 130, "got": "def search_packages_info(query):\n \"\"\"pass\"\"\"\n installed = {}\n for p in pkg_resources.working_set:\n installed[canonicalize_name(p.project_name)] = p\n query_names = [canonicalize_name(name) for name in query]\n for dist in [installed[pkg] for pkg in query_names if pkg in installed]:\n package = {'name': dist.project_name, 'version': dist.version, 'location': dist.location, 'requires': [dep.project_name for dep in dist.requires()]}\n file_list = None\n if isinstance(dist, pkg_resources.DistInfoDistribution):\n if dist.has_metadata('RECORD'):\n lines = dist.get_metadata_lines('RECORD')\n paths = [l.split(',')[0] for l in lines]\n paths = [os.path.join(dist.location, p) for p in paths]\n file_list = [os.path.relpath(p, dist.location) for p in paths]\n elif dist.has_metadata('installed-files.txt'):\n paths = dist.get_metadata_lines('installed-files.txt')\n paths = [os.path.join(dist.egg_info, p) for p in paths]\n file_list = [os.path.relpath(p, dist.location) for p in paths]\n if file_list:\n package['files'] = sorted(file_list)\n yield package"} +{"i": 131, "got": "def process_view(self, request, view_func, view_args, view_kwargs):\n \"\"\"pass\"\"\"\n view_keys = list(VIEW_METHOD_DATA.keys())\n for key in view_keys:\n del VIEW_METHOD_DATA[key]\n self.view_data = {}\n try:\n cbv = view_func.view_class\n except AttributeError:\n cbv = False\n if cbv:\n self.view_data['cbv'] = True\n klass = view_func.view_class\n self.view_data['bases'] = [base.__name__ for base in inspect.getmro(klass)]\n for member in inspect.getmembers(view_func.view_class):\n if member[0] in VIEW_METHOD_WHITEIST and member[0] not in PATCHED_METHODS[klass]:\n decorate_method(klass, member[0])\n PATCHED_METHODS[klass].append(member[0])"} +{"i": 132, "got": "def process_response(self, request, response):\n \"\"\"pass\"\"\"\n if not settings.DEBUG:\n return response\n content_encoding = response.get('Content-Encoding', '')\n content_type = response.get('Content-Type', '').split(';')[0]\n if any((getattr(response, 'streaming', False), 'gzip' in content_encoding, content_type not in _HTML_TYPES)):\n return response\n content = force_text(response.content, encoding=settings.DEFAULT_CHARSET)\n pattern = re.escape('')\n bits = re.split(pattern, content, flags=re.IGNORECASE)\n if len(bits) > 1:\n bits[-2] += debug_payload(request, response, self.view_data)\n response.content = ''.join(bits)\n if response.get('Content-Length', None):\n response['Content-Length'] = len(response.content)\n return response"} +{"i": 133, "got": "def get_job_class(klass_str):\n \"\"\"pass\"\"\"\n mod_name, klass_name = klass_str.rsplit('.', 1)\n try:\n mod = importlib.import_module(mod_name)\n except ImportError as e:\n logger.error(\"Error importing job module %s: '%s'\", mod_name, e)\n return None\n try:\n klass = getattr(mod, klass_name)\n except AttributeError:\n logger.error(\"Module '%s' does not define a '%s' class\", mod_name, klass_name)\n return None\n else:\n return klass"} +{"i": 134, "got": "def get(self, *raw_args, **raw_kwargs):\n \"\"\"pass\"\"\"\n args = self.prepare_args(*raw_args)\n kwargs = self.prepare_kwargs(**raw_kwargs)\n key = self.key(*args, **kwargs)\n item = self.cache.get(key)\n call = Call(args=raw_args, kwargs=raw_kwargs)\n if item is None:\n if self.should_missing_item_be_fetched_synchronously(*args, **kwargs):\n logger.debug(\"Job %s with key '%s' - cache MISS - running synchronous refresh\", self.class_path, key)\n result = self.refresh(*args, **kwargs)\n return self.process_result(result, call=call, cache_status=self.MISS, sync_fetch=True)\n else:\n logger.debug(\"Job %s with key '%s' - cache MISS - triggering async refresh and returning empty result\", self.class_path, key)\n result = self.empty()\n self.store(key, self.timeout(*args, **kwargs), result)\n self.async_refresh(*args, **kwargs)\n return self.process_result(result, call=call, cache_status=self.MISS, sync_fetch=False)\n expiry, data = item\n delta = time.time() - expiry\n if delta > 0:\n if self.should_stale_item_be_fetched_synchronously(delta, *args, **kwargs):\n logger.debug(\"Job %s with key '%s' - STALE cache hit - running synchronous refresh\", self.class_path, key)\n result = self.refresh(*args, **kwargs)\n return self.process_result(result, call=call, cache_status=self.STALE, sync_fetch=True)\n else:\n logger.debug(\"Job %s with key '%s' - STALE cache hit - triggering async refresh and returning stale result\", self.class_path, key)\n timeout = self.timeout(*args, **kwargs)\n self.store(key, timeout, data)\n self.async_refresh(*args, **kwargs)\n return self.process_result(data, call=call, cache_status=self.STALE, sync_fetch=False)\n else:\n logger.debug(\"Job %s with key '%s' - cache HIT\", self.class_path, key)\n return self.process_result(data, call=call, cache_status=self.HIT)"} +{"i": 135, "got": "def invalidate(self, *raw_args, **raw_kwargs):\n \"\"\"pass\"\"\"\n args = self.prepare_args(*raw_args)\n kwargs = self.prepare_kwargs(**raw_kwargs)\n key = self.key(*args, **kwargs)\n item = self.cache.get(key)\n if item is not None:\n expiry, data = item\n self.store(key, self.timeout(*args, **kwargs), data)\n self.async_refresh(*args, **kwargs)"} +{"i": 136, "got": "def delete(self, *raw_args, **raw_kwargs):\n \"\"\"pass\"\"\"\n args = self.prepare_args(*raw_args)\n kwargs = self.prepare_kwargs(**raw_kwargs)\n key = self.key(*args, **kwargs)\n item = self.cache.get(key)\n if item is not None:\n self.cache.delete(key)"} +{"i": 137, "got": "def raw_get(self, *raw_args, **raw_kwargs):\n \"\"\"pass\"\"\"\n args = self.prepare_args(*raw_args)\n kwargs = self.prepare_kwargs(**raw_kwargs)\n key = self.key(*args, **kwargs)\n return self.cache.get(key)"} +{"i": 138, "got": "def set(self, *raw_args, **raw_kwargs):\n \"\"\"pass\"\"\"\n if self.set_data_kwarg in raw_kwargs:\n data = raw_kwargs.pop(self.set_data_kwarg)\n else:\n raw_args = list(raw_args)\n data = raw_args.pop()\n args = self.prepare_args(*raw_args)\n kwargs = self.prepare_kwargs(**raw_kwargs)\n key = self.key(*args, **kwargs)\n expiry = self.expiry(*args, **kwargs)\n logger.debug(\"Setting %s cache with key '%s', args '%r', kwargs '%r', expiry '%r'\", self.class_path, key, args, kwargs, expiry)\n self.store(key, expiry, data)"} +{"i": 139, "got": "def angle(v1, v2):\n \"\"\"pass\"\"\"\n v1_u = unit_vector(v1)\n v2_u = unit_vector(v2)\n return np.arccos(np.clip(np.dot(v1_u, v2_u), -1.0, 1.0))"} +{"i": 140, "got": "def keep_high_angle(vertices, min_angle_deg):\n \"\"\"pass\"\"\"\n accepted = []\n v = vertices\n v1 = v[1] - v[0]\n accepted.append((v[0][0], v[0][1]))\n for i in range(1, len(v) - 2):\n v2 = v[i + 1] - v[i - 1]\n diff_angle = np.fabs(angle(v1, v2) * 180.0 / np.pi)\n if diff_angle > min_angle_deg:\n accepted.append((v[i][0], v[i][1]))\n v1 = v[i] - v[i - 1]\n accepted.append((v[-1][0], v[-1][1]))\n return np.array(accepted, dtype=vertices.dtype)"} +{"i": 141, "got": "def set_contourf_properties(stroke_width, fcolor, fill_opacity, contour_levels, contourf_idx, unit):\n \"\"\"pass\"\"\"\n return {'stroke': fcolor, 'stroke-width': stroke_width, 'stroke-opacity': 1, 'fill': fcolor, 'fill-opacity': fill_opacity, 'title': '%.2f' % contour_levels[contourf_idx] + ' ' + unit}"} +{"i": 142, "got": "def contour_to_geojson(contour, geojson_filepath=None, min_angle_deg=None, ndigits=5, unit='', stroke_width=1, geojson_properties=None, strdump=False, serialize=True):\n \"\"\"pass\"\"\"\n collections = contour.collections\n contour_index = 0\n line_features = []\n for collection in collections:\n color = collection.get_edgecolor()\n for path in collection.get_paths():\n v = path.vertices\n if len(v) < 3:\n continue\n coordinates = keep_high_angle(v, min_angle_deg)\n if ndigits:\n coordinates = np.around(coordinates, ndigits)\n line = LineString(coordinates.tolist())\n properties = {'stroke-width': stroke_width, 'stroke': rgb2hex(color[0]), 'title': '%.2f' % contour.levels[contour_index] + ' ' + unit, 'level-value': float('%.6f' % contour.levels[contour_index]), 'level-index': contour_index}\n if geojson_properties:\n properties.update(geojson_properties)\n line_features.append(Feature(geometry=line, properties=properties))\n contour_index += 1\n feature_collection = FeatureCollection(line_features)\n return _render_feature_collection(feature_collection, geojson_filepath, strdump, serialize)"} +{"i": 143, "got": "def contourf_to_geojson_overlap(contourf, geojson_filepath=None, min_angle_deg=None, ndigits=5, unit='', stroke_width=1, fill_opacity=0.9, geojson_properties=None, strdump=False, serialize=True):\n \"\"\"pass\"\"\"\n polygon_features = []\n contourf_idx = 0\n for collection in contourf.collections:\n color = collection.get_facecolor()\n for path in collection.get_paths():\n for coord in path.to_polygons():\n if min_angle_deg:\n coord = keep_high_angle(coord, min_angle_deg)\n coord = np.around(coord, ndigits) if ndigits else coord\n polygon = Polygon(coordinates=[coord.tolist()])\n fcolor = rgb2hex(color[0])\n properties = set_contourf_properties(stroke_width, fcolor, fill_opacity, contourf.levels, contourf_idx, unit)\n if geojson_properties:\n properties.update(geojson_properties)\n feature = Feature(geometry=polygon, properties=properties)\n polygon_features.append(feature)\n contourf_idx += 1\n feature_collection = FeatureCollection(polygon_features)\n return _render_feature_collection(feature_collection, geojson_filepath, strdump, serialize)"} +{"i": 144, "got": "def contourf_to_geojson(contourf, geojson_filepath=None, min_angle_deg=None, ndigits=5, unit='', stroke_width=1, fill_opacity=0.9, geojson_properties=None, strdump=False, serialize=True):\n \"\"\"pass\"\"\"\n polygon_features = []\n mps = []\n contourf_idx = 0\n for coll in contourf.collections:\n color = coll.get_facecolor()\n for path in coll.get_paths():\n for coord in path.to_polygons():\n if min_angle_deg:\n coord = keep_high_angle(coord, min_angle_deg)\n coord = np.around(coord, ndigits) if ndigits else coord\n op = MP(contourf.levels[conturf_idx], rgb2hex(color[0]))\n if op in mps:\n for i, k in enumerate(mps):\n if k == op:\n mps[i].add_coords(coord.tolist())\n else:\n op.add_coords(coord.tolist())\n mps.append(op)\n contourf_idx += 1\n contourf_idx = 0\n for muli in mps:\n polygon = muli.mpoly()\n fcolor = muli.color\n properties = set_contourf_properties(stroke_width, fcolor, fill_opacity, contourf.levels, contourf_idx, unit)\n if geojson_properties:\n properties.update(geojson_properties)\n feature = Feature(geometry=polygon, properties=properties)\n polygon_features.append(feature)\n contourf_idx += 1\n feature_collection = FeatureCollection(polygon_features)\n return _render_feature_collection(feature_collection, geojson_filepath, strdump, serialize)"} +{"i": 145, "got": "def get_authorize_callback(endpoint, provider_id):\n \"\"\"pass\"\"\"\n endpoint_prefix = config_value('BLUEPRINT_NAME')\n url = url_for(endpoint_prefix + '.' + endpoint, provider_id=provider_id)\n return request.url_root[:-1] + url"} +{"i": 146, "got": "def delete_connection(self, **kwargs):\n \"\"\"pass\"\"\"\n conn = self.find_connection(**kwargs)\n if not conn:\n return False\n self.delete(conn)\n return True"} +{"i": 147, "got": "def delete_connections(self, **kwargs):\n \"\"\"pass\"\"\"\n rv = False\n for c in self.find_connections(**kwargs):\n self.delete(c)\n rv = True\n return rv"} +{"i": 148, "got": "def login(provider_id):\n \"\"\"pass\"\"\"\n provider = get_provider_or_404(provider_id)\n callback_url = get_authorize_callback('login', provider_id)\n post_login = request.form.get('next', get_post_login_redirect())\n session[config_value('POST_OAUTH_LOGIN_SESSION_KEY')] = post_login\n return provider.authorize(callback_url)"} +{"i": 149, "got": "def connect(provider_id):\n \"\"\"pass\"\"\"\n provider = get_provider_or_404(provider_id)\n callback_url = get_authorize_callback('connect', provider_id)\n allow_view = get_url(config_value('CONNECT_ALLOW_VIEW'))\n pc = request.form.get('next', allow_view)\n session[config_value('POST_OAUTH_CONNECT_SESSION_KEY')] = pc\n return provider.authorize(callback_url)"} +{"i": 150, "got": "def remove_all_connections(provider_id):\n \"\"\"pass\"\"\"\n provider = get_provider_or_404(provider_id)\n ctx = dict(provider=provider.name, user=current_user)\n deleted = _datastore.delete_connections(user_id=current_user.get_id(), provider_id=provider_id)\n if deleted:\n after_this_request(_commit)\n msg = ('All connections to %s removed' % provider.name, 'info')\n connection_removed.send(current_app._get_current_object(), user=current_user._get_current_object(), provider_id=provider_id)\n else:\n msg = ('Unable to remove connection to %(provider)s' % ctx, 'error')\n do_flash(*msg)\n return redirect(request.referrer)"} +{"i": 151, "got": "def guess(filename, fallback='application/octet-stream'):\n \"\"\"pass\"\"\"\n guessed, encoding = mimetypes.guess_type(filename, strict=False)\n if guessed is None:\n return (fallback, encoding)\n else:\n return (guessed, encoding)"} +{"i": 152, "got": "def format_addresses(addrs):\n \"\"\"pass\"\"\"\n return ', '.join((formataddr(item) if isinstance(item, tuple) else item for item in addrs))"} +{"i": 153, "got": "def stringify_address(addr, encoding='utf-8'):\n \"\"\"pass\"\"\"\n if isinstance(addr, bytes_type):\n return addr\n try:\n addr = addr.encode('ascii')\n except UnicodeEncodeError:\n if '@' in addr:\n localpart, domain = addr.split('@', 1)\n addr = b'@'.join([localpart.encode(encoding), domain.encode('idna')])\n else:\n addr = addr.encode(encoding)\n return addr.decode('utf-8')"} +{"i": 154, "got": "def email(sender=None, receivers=(), cc=(), bcc=(), subject=None, content=None, encoding='utf8', attachments=()):\n \"\"\"pass\"\"\"\n enclosure = [HTML(content, encoding)]\n enclosure.extend((Attachment(k) for k in attachments))\n return Collection(enclosure, headers=headers.subject(subject), sender=headers.sender(sender), to=headers.to(*receivers), cc=headers.cc(*cc), bcc=headers.bcc(*bcc), date=headers.date(), message_id=headers.message_id())"} +{"i": 155, "got": "def postman(host=587, port=(None, None), auth=False, force_tls=None, options=None):\n \"\"\"pass\"\"\"\n return Postman(host=host, port=port, middlewares=[middleware.tls(force=force_tls), middleware.auth(*auth)], **options)"} +{"i": 156, "got": "def mime(self):\n \"\"\"pass\"\"\"\n mime = self.mime_object()\n self.headers.prepare(mime)\n return mime"} +{"i": 157, "got": "def get_existing_model(model_name):\n \"\"\"pass\"\"\"\n try:\n model_cls = engine.get_document_cls(model_name)\n log.debug('Model `{}` already exists. Using existing one'.format(model_name))\n return model_cls\n except ValueError:\n log.debug('Model `{}` does not exist'.format(model_name))"} +{"i": 158, "got": "def prepare_relationship(config, model_name, raml_resource):\n \"\"\"pass\"\"\"\n if get_existing_model(model_name) is None:\n plural_route = '/' + pluralize(model_name.lower())\n route = '/' + model_name.lower()\n for res in raml_resource.root.resources:\n if res.method.upper() != 'POST':\n continue\n if res.path.endswith(plural_route) or res.path.endswith(route):\n break\n else:\n raise ValueError('Model `{}` used in relationship is not defined'.format(model_name))\n setup_data_model(config, res, model_name)"} +{"i": 159, "got": "def generate_model_cls(config, schema, model_name, raml_resource, es_based=True):\n \"\"\"pass\"\"\"\n from nefertari.authentication.models import AuthModelMethodsMixin\n base_cls = engine.ESBaseDocument if es_based else engine.BaseDocument\n model_name = str(model_name)\n metaclass = type(base_cls)\n auth_model = schema.get('_auth_model', False)\n bases = []\n if config.registry.database_acls:\n from nefertari_guards import engine as guards_engine\n bases.append(guards_engine.DocumentACLMixin)\n if auth_model:\n bases.append(AuthModelMethodsMixin)\n bases.append(base_cls)\n attrs = {'__tablename__': model_name.lower(), '_public_fields': schema.get('_public_fields') or [], '_auth_fields': schema.get('_auth_fields') or [], '_hidden_fields': schema.get('_hidden_fields') or [], '_nested_relationships': schema.get('_nested_relationships') or []}\n if '_nesting_depth' in schema:\n attrs['_nesting_depth'] = schema.get('_nesting_depth')\n properties = schema.get('properties', {})\n for field_name, props in properties.items():\n if field_name in attrs:\n continue\n db_settings = props.get('_db_settings')\n if db_settings is None:\n continue\n field_kwargs = db_settings.copy()\n field_kwargs['required'] = bool(field_kwargs.get('required'))\n for default_attr_key in ['default', 'onupdate']:\n value = field_kwargs.get(default_attr_key)\n if is_callable_tag(value):\n field_kwargs[default_attr_key] = resolve_to_callable(value)\n type_name = (field_kwargs.pop('type', 'string') or 'string').lower()\n if not type_name in type_fields:\n raise ValueError('Unknown type: {}'.format(type_name))\n field_cls = type_fields[type_name]\n if field_cls is engine.Relationship:\n prepare_relationship(config, field_kwargs['document'], raml_resource)\n if field_cls is engine.ForeignKeyField:\n key = 'ref_column_type'\n field_kwargs[key] = type_fields[field_kwargs[key]]\n if field_cls is engine.ListField:\n key = 'item_type'\n field_kwargs[key] = type_fields[field_kwargs[key]]\n attrs[field_name] = field_cls(**field_kwargs)\n attrs.update(registry.mget(model_name))\n model_cls = metaclass(model_name, tuple(bases), attrs)\n setup_model_event_subscribers(config, model_cls, schema)\n setup_fields_processors(config, model_cls, schema)\n return (model_cls, auth_model)"} +{"i": 160, "got": "def setup_data_model(config, raml_resource, model_name):\n \"\"\"pass\"\"\"\n model_cls = get_existing_model(model_name)\n schema = resource_schema(raml_resource)\n if not schema:\n raise Exception('Missing schema for model `{}`'.format(model_name))\n if model_cls is not None:\n return (model_cls, schema.get('_auth_model', False))\n else:\n log.info('Generating model class `{}`'.format(model_name))\n return generate_model_cls(config, schema=schema, model_name=model_name, raml_resource=raml_resource)"} +{"i": 161, "got": "def handle_model_generation(config, raml_resource):\n \"\"\"pass\"\"\"\n model_name = generate_model_name(raml_resource)\n try:\n return setup_data_model(config, raml_resource, model_name)\n except ValueError as ex:\n raise ValueError('{}: {}'.format(model_name, str(ex)))"} +{"i": 162, "got": "def setup_model_event_subscribers(config, model_cls, schema):\n \"\"\"pass\"\"\"\n events_map = get_events_map()\n model_events = schema.get('_event_handlers', {})\n event_kwargs = {'model': model_cls}\n for event_tag, subscribers in model_events.items():\n type_, action = event_tag.split('_')\n event_objects = events_map[type_][action]\n if not isinstance(event_objects, list):\n event_objects = [event_objects]\n for sub_name in subscribers:\n sub_func = resolve_to_callable(sub_name)\n config.subscribe_to_events(sub_func, event_objects, **event_kwargs)"} +{"i": 163, "got": "def setup(app):\n \"\"\"pass\"\"\"\n import sphinxcontrib_django.docstrings\n import sphinxcontrib_django.roles\n sphinxcontrib_django.docstrings.setup(app)\n sphinxcontrib_django.roles.setup(app)"} +{"i": 164, "got": "def patch_django_for_autodoc():\n \"\"\"pass\"\"\"\n ManagerDescriptor.__get__ = lambda self, *args, **kwargs: self.manager\n models.QuerySet.__repr__ = lambda self: self.__class__.__name__"} +{"i": 165, "got": "def setup(app):\n \"\"\"pass\"\"\"\n from .patches import patch_django_for_autodoc\n patch_django_for_autodoc()\n app.connect('autodoc-process-docstring', improve_model_docstring)\n app.connect('autodoc-skip-member', autodoc_skip)"} +{"i": 166, "got": "def autodoc_skip(app, what, name, obj, skip, options):\n \"\"\"pass\"\"\"\n if name in config.EXCLUDE_MEMBERS:\n return True\n elif name in config.INCLUDE_MEMBERS:\n return False\n else:\n return skip"} +{"i": 167, "got": "def improve_model_docstring(app, what, name, obj, options, lines):\n \"\"\"pass\"\"\"\n if what == 'class':\n _improve_class_docs(app, obj, lines)\n elif what == 'attribute':\n _improve_attribute_docs(obj, name, lines)\n elif what == 'method':\n _improve_method_docs(obj, name, lines)\n return lines"} +{"i": 168, "got": "def _improve_class_docs(app, cls, lines):\n \"\"\"pass\"\"\"\n if issubclass(cls, models.Model):\n _add_model_fields_as_params(app, cls, lines)\n elif issubclass(cls, forms.Form):\n _add_form_fields(cls, lines)"} +{"i": 169, "got": "def attr_names(cls) -> List[str]:\n \"\"\"pass\"\"\"\n return [k for k, v in cls.attr_types().items()]"} +{"i": 170, "got": "def elliptic_fourier_descriptors(contour, order=10, normalize=False):\n \"\"\"pass\"\"\"\n dxy = np.diff(contour, axis=0)\n dt = np.sqrt((dxy ** 2).sum(axis=1))\n t = np.concatenate([[0.0], np.cumsum(dt)])\n T = t[-1]\n phi = 2 * np.pi * t / T\n coeffs = np.zeros((order, 4))\n for n in _range(1, order + 1):\n const = T / (2 * n * n * np.pi * np.pi)\n phi_n = phi * n\n d_cos_phi_n = np.cos(phi_n[1:]) - np.cos(phi_n[:-1])\n d_sin_phi_n = np.sin(phi_n[1:]) - np.sin(phi_n[:-1])\n a_n = const * np.sum(dxy[:, 0] / dt * d_cos_phi_n)\n b_n = const * np.sum(dxy[:, 0] / dt * d_sin_phi_n)\n c_n = const * np.sum(dxy[:, 1] / dt * d_cos_phi_n)\n d_n = const * np.sum(dxy[:, 1] / dt * d_sin_phi_n)\n coeffs[n - 1, :] = (a_n, b_n, c_n, d_n)\n if normalize:\n coeffs = normalize_efd(coeffs)\n return coeffs"} +{"i": 171, "got": "def normalize_efd(coeffs, size_invariant=True):\n \"\"\"pass\"\"\"\n theta_1 = 0.5 * np.arctan2(2 * (coeffs[0, 0] * coeffs[0, 1] + coeffs[0, 2] * coeffs[0, 3]), coeffs[0, 0] ** 2 - coeffs[0, 1] ** 2 + coeffs[0, 2] ** 2 - coeffs[0, 3] ** 2)\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = np.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]]), np.array([[np.cos(n * theta_1), -np.sin(n * theta_1)], [np.sin(n * theta_1), np.cos(n * theta_1)]]))\n psi_1 = np.arctan2(coeffs[0, 2], coeffs[0, 0])\n psi_rotation_matrix = np.array([[np.cos(psi_1), np.sin(psi_1)], [-np.sin(psi_1), np.cos(psi_1)]])\n for n in _range(1, coeffs.shape[0] + 1):\n coeffs[n - 1, :] = psi_rotation_matrix.dot(np.array([[coeffs[n - 1, 0], coeffs[n - 1, 1]], [coeffs[n - 1, 2], coeffs[n - 1, 3]]])).flatten()\n if size_invariant:\n coeffs /= np.abs(coeffs[0, 0])\n return coeffs"} +{"i": 172, "got": "def calculate_dc_coefficients(contour):\n \"\"\"pass\"\"\"\n dxy = np.diff(contour, axis=0)\n dt = np.sqrt((dxy ** 2).sum(axis=1))\n t = np.concatenate([[0.0], np.cumsum(dt)])\n T = t[-1]\n xi = np.cumsum(dxy[:, 0]) - (dxy[:, 0] / dt) * t[1:]\n A0 = 1 / T * np.sum((dxy[:, 0] / (2 * dt)) * np.diff(t ** 2) + xi * dt)\n delta = np.cumsum(dxy[:, 1]) - dxy[:, 1] / dt * t[1:]\n C0 = 1 / T * np.sum((dxy[:, 1] / (2 * dt)) * np.diff(t ** 2) + delta * dt)\n return (contour[0, 0] + A0, contour[0, 1] + C0)"} +{"i": 173, "got": "def plot_efd(coeffs, locus=(0.0, 0.0), image=None, contour=None, n=300):\n \"\"\"pass\"\"\"\n try:\n import matplotlib.pyplot as plt\n except ImportError:\n print('Cannot plot: matplotlib was not installed.')\n return\n N = coeffs.shape[0]\n N_half = int(np.ceil(N / 2))\n n_rows = 2\n t = np.linspace(0, 1.0, n)\n xt = np.ones((n,)) * locus[0]\n yt = np.ones((n,)) * locus[1]\n for n in _range(coeffs.shape[0]):\n xt += coeffs[n, 0] * np.cos((2 * (n + 1) * np.pi * t))\n yt += coeffs[n, 2] * np.cos((2 * (n + 1) * np.pi * t)) + coeffs[n, 3] * np.sin((2 * (n + 1) * np.pi * t))\n ax = plt.subplot2grid((n_rows, N_half), (n // N_half, n % N_half))\n ax.set_title(str(n + 1))\n if contour is not None:\n ax.plot(contour[:, 1], contour[:, 0], 'c--', linewidth=2)\n ax.plot(yt, xt, 'r', linewidth=2)\n if image is not None:\n ax.imshow(image, plt.cm.gray)\n plt.show()"} +{"i": 174, "got": "def _errcheck(result, func, arguments):\n \"\"\"pass\"\"\"\n if result != 0:\n raise XdoException('Function {0} returned error code {1}'.format(func.__name__, result))"} +{"i": 175, "got": "def _gen_input_mask(mask):\n \"\"\"pass\"\"\"\n return input_mask(shift=bool(mask & MOD_Shift), lock=bool(mask & MOD_Lock), control=bool(mask & MOD_Control), mod1=bool(mask & MOD_Mod1), mod2=bool(mask & MOD_Mod2), mod3=bool(mask & MOD_Mod3), mod4=bool(mask & MOD_Mod4), mod5=bool(mask & MOD_Mod5))"} +{"i": 176, "got": "def move_mouse(self, x, y, screen=0):\n \"\"\"pass\"\"\"\n x = ctypes.c_int(x)\n y = ctypes.c_int(y)\n screen = ctypes.c_int(screen)\n _libxdo.xdo_move_mouse(self._xdo, x, y, screen)"} +{"i": 177, "got": "def move_mouse_relative_to_window(self, window, x, y):\n \"\"\"pass\"\"\"\n _libxdo.xdo_move_mouse_relative_to_window(self._xdo, ctypes.c_ulong(window), x, y)"} +{"i": 178, "got": "def move_mouse_relative(self, x, y):\n \"\"\"pass\"\"\"\n _libxdo.xdo_move_mouse_relative(self._xdo, x, y)"} +{"i": 179, "got": "def mouse_down(self, window, button):\n \"\"\"pass\"\"\"\n _libxdo.xdo_mouse_down(self._xdo, ctypes.c_ulong(window), ctypes.c_int(button))"} +{"i": 180, "got": "def strip_punctuation_space(value):\n \"\"\"pass\"\"\"\n\n def strip_punctuation(string):\n replacement_list = ((' .', '.'), (' :', ':'), ('( ', '('), (' )', ')'))\n for match, replacement in replacement_list:\n string = string.replace(match, replacement)\n return string\n if value == None:\n return None\n elif type(value) == list:\n return [strip_punctuation(v) for v in value]\n else:\n return strip_punctuation(value)"} +{"i": 181, "got": "def join_sentences(string1, string2, glue='.'):\n \"\"\"pass\"\"\"\n if not string1 or string1 == '':\n return string2\n elif not string2 or string2 == '':\n return string1\n else:\n new_string = string1.rstrip()\n if not new_string.endswith(glue):\n new_string += glue\n new_string += ' ' + string2.lstrip()\n return new_string"} +{"i": 182, "got": "def coerce_to_int(val, default=3735928559):\n \"\"\"pass\"\"\"\n try:\n return int(val)\n except (TypeError, ValueError):\n if default != 3735928559:\n return default\n else:\n return val"} +{"i": 183, "got": "def nullify(function):\n \"\"\"pass\"\"\"\n\n def wrapper(*args, **kwargs):\n value = function(*args, **kwargs)\n if type(value) == list and len(value) == 0:\n return None\n else:\n return value\n return wrapper"} +{"i": 184, "got": "def strippen(function):\n \"\"\"pass\"\"\"\n\n def wrapper(*args, **kwargs):\n return strip_strings(function(*args, **kwargs))\n return wrapper"} +{"i": 185, "got": "def inten(function):\n \"\"\"pass\"\"\"\n\n def wrapper(*args, **kwargs):\n return coerce_to_int(function(*args, **kwargs))\n return wrapper"} +{"i": 186, "got": "def connect(url, max_retries=None, **kwargs):\n \"\"\"pass\"\"\"\n client = AvaticaClient(url, max_retries=max_retries)\n client.connect()\n return Connection(client, **kwargs)"} +{"i": 187, "got": "def connect(self):\n \"\"\"pass\"\"\"\n logger.debug('Opening connection to %s:%s', self.url.hostname, self.url.port)\n try:\n self.connection = httplib.HTTPConnection(self.url.hostname, self.url.port)\n self.connection.connect()\n except (httplib.HTTPException, socket.error) as e:\n raise errors.InterfaceError('Unable to connect to the specified service', e)"} +{"i": 188, "got": "def close(self):\n \"\"\"pass\"\"\"\n if self.connection is not None:\n logger.debug('Closing connection to %s:%s', self.url.hostname, self.url.port)\n try:\n self.connection.close()\n except httplib.HTTPException:\n logger.warning('Error while closing connection', exc_info=True)\n self.connection = None"} +{"i": 189, "got": "def connection_sync(self, connection_id, connProps=None):\n \"\"\"pass\"\"\"\n if connProps is None:\n connProps = {}\n request = requests_pb2.ConnectionSyncRequest()\n request.connection_id = connection_id\n request.conn_props.auto_commit = connProps.get('autoCommit', False)\n request.conn_props.has_auto_commit = True\n request.conn_props.read_only = connProps.get('readOnly', False)\n request.conn_props.has_read_only = True\n request.conn_props.transaction_isolation = connProps.get('transactionIsolation', 0)\n request.conn_props.catalog = connProps.get('catalog', '')\n request.conn_props.schema = connProps.get('schema', '')\n response_data = self._apply(request)\n response = responses_pb2.ConnectionSyncResponse()\n response.ParseFromString(response_data)\n return response.conn_props"} +{"i": 190, "got": "def open_connection(self, connection_id, info=None):\n \"\"\"pass\"\"\"\n request = requests_pb2.OpenConnectionRequest()\n request.connection_id = connection_id\n if info is not None:\n for k, v in info.items():\n request.info[k] = v\n response_data = self._apply(request)\n response = responses_pb2.OpenConnectionResponse()\n response.ParseFromString(response_data)"} +{"i": 191, "got": "def close_connection(self, connection_id):\n \"\"\"pass\"\"\"\n request = requests_pb2.CloseConnectionRequest()\n request.connection_id = connection_id\n self._apply(request)"} +{"i": 192, "got": "def fit(self, X, y):\n \"\"\"pass\"\"\"\n self.X = X\n self.y = y\n if hasattr(self.gamma, '__iter__'):\n self.gamma = self._optimize_gamma(self.gamma)\n return self"} +{"i": 193, "got": "def predict(self, X):\n \"\"\"pass\"\"\"\n K = pairwise_kernels(self.X, X, metric=self.kernel, gamma=self.gamma)\n return (K * self.y[:, None]).sum(axis=0) / K.sum(axis=0)"} +{"i": 194, "got": "def _compute_hidden_activations(self, X):\n \"\"\"pass\"\"\"\n self._compute_input_activations(X)\n acts = self.input_activations_\n if callable(self.activation_func):\n args_dict = self.activation_args if self.activation_args else {}\n X_new = self.activation_func(acts, **args_dict)\n else:\n func_name = self.activation_func\n func = self._internal_activation_funcs[func_name]\n X_new = func(acts, **self._extra_args)\n return X_new"} +{"i": 195, "got": "def transform(self, X, y=None):\n \"\"\"pass\"\"\"\n if self.components_ is None:\n raise ValueError('No components initialized')\n return self._compute_hidden_activations(X)"} +{"i": 196, "got": "def _compute_radii(self):\n \"\"\"pass\"\"\"\n radii = self._get_user_components('radii')\n if radii is None:\n centers = self.components_['centers']\n n_centers = centers.shape[0]\n max_dist = np.max(pairwise_distances(centers))\n radii = np.ones(n_centers) * max_dist / sqrt(2.0 * n_centers)\n self.components_['radii'] = radii"} +{"i": 197, "got": "def _compute_centers(self, X, sparse, rs):\n \"\"\"pass\"\"\"\n centers = self._get_user_components('centers')\n if centers is None:\n n_features = X.shape[1]\n if sparse:\n fxr = range(n_features)\n cols = [X.getcol(i) for i in fxr]\n min_dtype = X.dtype.type(10000000000.0)\n sp_min = lambda col: np.minimum(min_dtype, np.min(col.data))\n min_Xs = np.array(map(sp_min, cols))\n max_dtype = X.dtype.type(-10000000000.0)\n sp_max = lambda col: np.maximum(max_dtype, np.max(col.data))\n max_Xs = np.array(map(sp_max, cols))\n else:\n min_Xs = X.min(axis=0)\n max_Xs = X.max(axis=0)\n spans = max_Xs - min_Xs\n ctrs_size = (self.n_hidden, n_features)\n centers = min_Xs + spans * rs.uniform(0.0, 1.0, ctrs_size)\n self.components_['centers'] = centers"} +{"i": 198, "got": "def compat_serializer_check_is_valid(serializer):\n \"\"\"pass\"\"\"\n if DRFVLIST[0] >= 3:\n serializer.is_valid(raise_exception=True)\n elif not serializer.is_valid():\n serializers.ValidationError('The serializer raises a validation error')"} +{"i": 199, "got": "def compat_serializer_attr(serializer, obj):\n \"\"\"pass\"\"\"\n if DRFVLIST[0] == 3 and DRFVLIST[1] == 1:\n for i in serializer.instance:\n if i.id == obj.id:\n return i\n return None\n else:\n return obj"} +{"i": 200, "got": "def compat_get_paginated_response(view, page):\n \"\"\"pass\"\"\"\n if DRFVLIST[0] == 3 and DRFVLIST[1] >= 1:\n from rest_messaging.serializers import ComplexMessageSerializer\n serializer = ComplexMessageSerializer(page, many=True)\n return view.get_paginated_response(serializer.data)\n else:\n serializer = view.get_pagination_serializer(page)\n return Response(serializer.data)"} +{"i": 201, "got": "def compat_pagination_messages(cls):\n \"\"\"pass\"\"\"\n if DRFVLIST[0] == 3 and DRFVLIST[1] >= 1:\n setattr(cls, 'pagination_class', MessagePagination)\n else:\n setattr(cls, 'paginate_by', getattr(settings, 'DJANGO_REST_MESSAGING_MESSAGES_PAGE_SIZE', 30))\n return cls"} +{"i": 202, "got": "def get_participants(self, obj):\n \"\"\"pass\"\"\"\n if self.callback is None:\n return [participant.id for participant in obj.participants.all()]\n else:\n return self.callback(obj)"} +{"i": 203, "got": "def get_is_notification(self, obj):\n \"\"\"pass\"\"\"\n try:\n o = compat_serializer_attr(self, obj)\n return o.is_notification\n except Exception:\n return False"} +{"i": 204, "got": "def process(self, quoted=False):\n \"\"\"pass\"\"\"\n self.p = urlparse(self.raw)\n self.scheme = self.p.scheme\n self.netloc = self.p.netloc\n self.opath = self.p.path if not quoted else quote(self.p.path)\n self.path = [x for x in self.opath.split('/') if x]\n self.params = self.p.params\n self.query = parse_qs(self.p.query, keep_blank_values=True)\n self.fragment = self.p.fragment"} +{"i": 205, "got": "def fetch(self, url, encoding=None, force_refetch=False, nocache=False, quiet=True):\n \"\"\"pass\"\"\"\n try:\n if not force_refetch and self.cache is not None and (url in self.cache):\n logging.debug('Retrieving content from cache for {}'.format(url))\n return self.cache.retrieve_blob(url, encoding)\n encoded_url = WebHelper.encode_url(url)\n req = Request(encoded_url, headers={'User-Agent': 'Mozilla/5.0'})\n req.add_header('Accept-encoding', 'gzip, deflate')\n getLogger().info('Fetching: {url} |'.format(url=url))\n response = urlopen(req)\n content = response.read()\n if 'Content-Encoding' in response.info() and response.info().get('Content-Encoding') == 'gzip':\n with gzip.open(BytesIO(content)) as gzfile:\n content = gzfile.read()\n if self.cache is not None and (not nocache) and (url not in self.cache):\n self.cache.insert_blob(url, content)\n except URLError as e:\n if hasattr(e, 'reason'):\n getLogger().exception('We failed to reach {}. Reason: {}'.format(url, e.reason))\n elif hasattr(e, 'code'):\n getLogger().exception(\"The server couldn't fulfill the request. Error code: {}\".format(e.code))\n else:\n getLogger().exception('Fetching error')\n if not quiet:\n raise\n finally:\n return content.decode(encoding) if content and encoding else content"} +{"i": 206, "got": "def download(self, url, path, force_refetch=False, nocache=False):\n \"\"\"pass\"\"\"\n if os.path.isfile(path):\n getLogger().info('File exists, download task skipped -> {path}'.format(path=path))\n return True\n try:\n getLogger().info('Downloading: {url} -> {path}'.format(url=url, path=path))\n response = self.fetch(url, force_refetch=force_refetch, nocache=nocache)\n if response is not None:\n local_file = open(path, 'wb')\n local_file.write(response)\n local_file.close()\n return True\n except Exception as e:\n if hasattr(e, 'reason'):\n getLogger().exception('We failed to reach a server. Reason: %s' % (e.reason,))\n elif hasattr(e, 'code'):\n getLogger().exception(\"The server couldn't fulfill the request. Error code: {code}\".format(code=e.code))\n else:\n getLogger().exception('Unknown error: %s' % (e,))\n return False"} +{"i": 207, "got": "def _platform(self) -> Optional[str]:\n \"\"\"pass\"\"\"\n try:\n return str(self.journey.MainStop.BasicStop.Dep.Platform.text)\n except AttributeError:\n pass"} +{"i": 208, "got": "def _delay(self) -> int:\n \"\"\"pass\"\"\"\n try:\n return int(self.journey.MainStop.BasicStop.Dep.Delay.text)\n except AttributeError:\n return 0"} +{"i": 209, "got": "def _departure(self) -> datetime:\n \"\"\"pass\"\"\"\n departure_time = datetime.strptime(self.journey.MainStop.BasicStop.Dep.Time.text, '%H:%M').time()\n if (departure_time - self.now).time() > departure_time:\n return datetime.combine(self.now.date(), departure_time)\n else:\n return datetime.combine(self.now.date() + timedelta(days=1), departure_time)"} +{"i": 210, "got": "def _extract(self, attribute) -> str:\n \"\"\"pass\"\"\"\n attr_data = self.journey.JourneyAttributeList.JourneyAttribute[self.attr_types.index(attribute)].Attribute\n attr_variants = attr_data.xpath('AttributeVariant/@type')\n data = attr_data.AttributeVariant[attr_variants.index('NORMAL')].Text.pyval\n return str(data)"} +{"i": 211, "got": "def _info(self) -> Optional[str]:\n \"\"\"pass\"\"\"\n try:\n return str(html.unescape(self.journey.InfoTextList.InfoText.get('text')))\n except AttributeError:\n pass"} +{"i": 212, "got": "def _info_long(self) -> Optional[str]:\n \"\"\"pass\"\"\"\n try:\n return str(html.unescape(self.journey.InfoTextList.InfoText.get('textL')).replace('
', '\\n'))\n except AttributeError:\n pass"} +{"i": 213, "got": "def validate(style):\n \"\"\"pass\"\"\"\n try:\n import jsonschema\n except ImportError:\n return\n try:\n jsonschema.validate(style, schema)\n except jsonschema.ValidationError as exc:\n new_exc = StyleValidationError(exc)\n new_exc.__cause__ = None\n raise new_exc"} +{"i": 214, "got": "def value_type(value):\n \"\"\"pass\"\"\"\n try:\n keys = list(value.keys())\n except AttributeError:\n return 'simple'\n if keys in ([], ['lookup'], ['re_lookup'], ['interval']):\n return keys[0]\n raise ValueError('Type of `value` could not be determined')"} +{"i": 215, "got": "def _register_mecab_loc(location):\n \"\"\"pass\"\"\"\n global MECAB_LOC\n if not os.path.isfile(location):\n logging.getLogger(__name__).warning('Provided mecab binary location does not exist {}'.format(location))\n logging.getLogger(__name__).info('Mecab binary is switched to: {}'.format(location))\n MECAB_LOC = location"} +{"i": 216, "got": "def run_mecab_process(content, *args, **kwargs):\n \"\"\"pass\"\"\"\n encoding = 'utf-8' if not 'encoding' in kwargs else kwargs['encoding']\n mecab_loc = kwargs['mecab_loc'] if 'mecab_loc' in kwargs else None\n if mecab_loc is None:\n mecab_loc = MECAB_LOC\n proc_args = [mecab_loc]\n if args:\n proc_args.extend(args)\n output = subprocess.run(proc_args, input=content.encode(encoding), stdout=subprocess.PIPE)\n output_string = os.linesep.join(output.stdout.decode(encoding).splitlines())\n return output_string"} +{"i": 217, "got": "def parse(content, *args, **kwargs):\n \"\"\"pass\"\"\"\n if 'mecab_loc' not in kwargs and MECAB_PYTHON3 and ('MeCab' in globals()):\n return MeCab.Tagger(*args).parse(content)\n else:\n return run_mecab_process([content], *args, **kwargs)"} +{"i": 218, "got": "def create_track(self, path_in_ipod=None, checksum=None):\n \"\"\"pass\"\"\"\n if bool(path_in_ipod) == bool(checksum):\n raise Exception\n if not path_in_ipod:\n path_in_ipod = self.audiodb.get_voice(checksum)\n track = Track(self, path_in_ipod=path_in_ipod)\n return track"} +{"i": 219, "got": "def voice(self):\n \"\"\"pass\"\"\"\n dbid = self.lldb.dbid\n text, lang = self._voiceoverdb.get_text_lang(dbid)\n return (text, lang)"} +{"i": 220, "got": "def add(self, src):\n \"\"\"pass\"\"\"\n if not audio.get_type(src):\n raise TypeError('The type of this file is not supported.')\n return super().add(src)"} +{"i": 221, "got": "def _get_cmd(command, arguments):\n \"\"\"pass\"\"\"\n if arguments is None:\n arguments = []\n if command.endswith('.py') or command.endswith('.pyw'):\n return [sys.executable, command] + list(arguments)\n else:\n return [command] + list(arguments)"} +{"i": 222, "got": "def argparse(argv, parser, arguments):\n \"\"\"pass\"\"\"\n\n def add_arg(parser, arg_spec):\n parser.add_argument(arg_spec.name, help=arg_spec.help)\n return parser\n parse_request = parser.map(lambda i: ArgumentParser(description=i.description))(lambda parser, arg_def: add_arg(parser, arg_def)).last().combine_latest(argv.to_list(), lambda parser, args: (parser, args))\n\n def subscribe(observer):\n\n def on_next(value):\n parser, args = value\n try:\n args = parser.parse_args(args)\n for key, value in vars(args).items():\n observer.on_next(Argument(key=key, value=value))\n except NameError as exc:\n observer.on_error('{}\\n{}'.format(exc, parser.format_help()))\n return parse_request.subscribe(on_next, observer.on_error, observer.on_completed)\n return AnonymousObservable(subscribe)"} +{"i": 223, "got": "def qn(phi, *n):\n \"\"\"pass\"\"\"\n phi = np.ravel(phi)\n n = np.asarray(n)\n i_n_phi = np.zeros((n.size, phi.size), dtype=complex)\n np.outer(n, phi, out=i_n_phi.imag)\n qn = np.exp(i_n_phi, out=i_n_phi).sum(axis=1)\n if qn.size == 1:\n qn = qn[0]\n return qn"} +{"i": 224, "got": "def correlation(self, n, k, error=False):\n \"\"\"pass\"\"\"\n self._calculate_corr(n, k)\n corr_nk = self._corr[n][k]\n if error:\n self._calculate_corr_err(n, k)\n return (corr_nk, self._corr_err[n][k])\n else:\n return corr_nk"} +{"i": 225, "got": "def cumulant(self, n, k, error=False):\n \"\"\"pass\"\"\"\n corr_nk = self.correlation(n, k, error=error)\n if k == 2:\n return corr_nk\n elif k == 4:\n corr_n2 = self.correlation(n, 2)\n return corr_nk - 2 * corr_n2 * corr_n2"} +{"i": 226, "got": "def flow(self, n, k, error=False, imaginary='nan'):\n \"\"\"pass\"\"\"\n cnk = self.cumulant(n, k, error=error)\n if error:\n cnk, cnk_err = cnk\n vnk_to_k = self._cnk_prefactor[k] * cnk\n kinv = 1 / k\n if vnk_to_k >= 0:\n vnk = vnk_to_k ** kinv\n elif imaginary == 'negative':\n vnk = -1 * (vnk_to_k ** (-kinv))\n elif imaginary == 'zero':\n vnk = 0.0\n else:\n warnings.warn('Imaginary flow: returning NaN.', RuntimeWarning)\n vnk = float('nan')\n if k == 2 and error:\n return (vnk, 0.5 / np.sqrt(abs(cnk)) * cnk_err)\n else:\n return vnk"} +{"i": 227, "got": "def _pdf(self, phi):\n \"\"\"pass\"\"\"\n pdf = np.inner(self._vn, np.cos(np.outer(phi, self._n)))\n pdf *= 2.0\n pdf += 1.0\n return pdf"} +{"i": 228, "got": "def _uniform_phi(M):\n \"\"\"pass\"\"\"\n return np.random.uniform(-np.pi, np.pi, M)"} +{"i": 229, "got": "def smart_text(s, encoding='utf-8', strings_only=False, errors='strict'):\n \"\"\"pass\"\"\"\n if isinstance(s, six.text_type):\n return s\n elif strings_only and (not isinstance(s, six.string_types)):\n return s\n elif not isinstance(s, six.string_types):\n if hasattr(s, '__unicode__'):\n s = s.__unicode__()\n elif six.PY3:\n if isinstance(s, six.binary_type):\n s = six.text_type(s, encoding, errors)\n else:\n s = six.text_type(s)\n else:\n s = six.text_type(six.binary_type(s), encoding, errors)\n else:\n s = s.decode(encoding, errors)\n return s"} +{"i": 230, "got": "def smart_bytes(s, encoding='utf-8', strings_only=False, errors='strict'):\n \"\"\"pass\"\"\"\n if isinstance(s, six.binary_type):\n if encoding == 'utf-8':\n return s\n else:\n return s.decode('utf-8', errors).encode(encoding, errors)\n elif strings_only and (not isinstance(s, six.text_type)):\n return s\n elif not isinstance(s, six.string_types):\n try:\n if six.PY3:\n return six.text_type(s).encode(encoding)\n else:\n return six.binary_type(s)\n except UnicodeEncodeError:\n return six.text_type(s).encode(encoding, errors)\n else:\n return s.encode(encoding, errors)"} +{"i": 231, "got": "def output(self, response, accepts):\n \"\"\"pass\"\"\"\n graph = self.get_graph(response)\n if graph is not None:\n mimetype, format = self.format_selector.decide(accepts, graph.context_aware)\n if mimetype is None:\n return self.make_406_response()\n if 'text' in mimetype:\n mimetype = mimetype + '; charset=utf-8'\n serialized = graph.serialize(format=format)\n response = self.make_new_response(response, mimetype, serialized)\n return response"} +{"i": 232, "got": "def decorate(self, view):\n \"\"\"pass\"\"\"\n from functools import wraps\n\n @wraps(view)\n def decorated(*args, **kwargs):\n response = view(*args, **kwargs)\n accept = self.get_accept()\n return self.output(response, accept)\n return decorated"} +{"i": 233, "got": "def get(self, var, default=None):\n \"\"\"pass\"\"\"\n try:\n return self.__get(var)\n except (KeyError, IndexError):\n return default"} +{"i": 234, "got": "def insert(self, var, value, index=None):\n \"\"\"pass\"\"\"\n current = self.__get(var)\n if not isinstance(current, list):\n raise KeyError('%s: is not a list' % var)\n if index is None:\n current.append(value)\n else:\n current.insert(index, value)\n if self.auto_save:\n self.save()"} +{"i": 235, "got": "def keys(self):\n \"\"\"pass\"\"\"\n s = set()\n for config in self.__configs:\n s |= config.keys()\n return s"} +{"i": 236, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n if self.scope:\n variable_path = '{0.scope}{0.path_separator}{1}'.format(self, variable_path)\n if self.key_prefix:\n variable_path = '{0.key_prefix}:{1}'.format(self, variable_path)\n val = self.client.get(variable_path)\n if val is None:\n return default\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 237, "got": "def setup_logging(verbose=False, logger=None):\n \"\"\"pass\"\"\"\n if not verbose:\n logging.getLogger('requests').setLevel(logging.WARNING)\n format_ = '%(asctime)s %(levelname)-8s %(name)-40s %(message)s' if verbose else '%(message)s'\n level = logging.DEBUG if verbose else logging.INFO\n handler_stdout = logging.StreamHandler(sys.stdout)\n handler_stdout.setFormatter(logging.Formatter(format_))\n handler_stdout.setLevel(logging.DEBUG)\n handler_stdout.addFilter(InfoFilter())\n handler_stderr = logging.StreamHandler(sys.stderr)\n handler_stderr.setFormatter(logging.Formatter(format_))\n handler_stderr.setLevel(logging.WARNING)\n root_logger = logging.getLogger(logger)\n root_logger.setLevel(level)\n root_logger.addHandler(handler_stdout)\n root_logger.addHandler(handler_stderr)"} +{"i": 238, "got": "def with_log(func):\n \"\"\"pass\"\"\"\n\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n \"\"\"pass\"\"\"\n decorator_logger = logging.getLogger('@with_log')\n decorator_logger.debug('Entering %s() function call.', func.__name__)\n log = kwargs.get('log', logging.getLogger(func.__name__))\n try:\n ret = func(*args, log=log, **kwargs)\n finally:\n decorator_logger.debug('Leaving %s() function call.', func.__name__)\n return ret\n return wrapper"} +{"i": 239, "got": "def get_arguments(argv=None, environ=None):\n \"\"\"pass\"\"\"\n name = 'appveyor-artifacts'\n environ = environ or os.environ\n require = getattr(pkg_resources, 'require')\n commit, owner, pull_request, repo, tag = ('', '', '', '', '')\n project = [p for p in require(name) if p.project_name == name][0]\n version = project.version\n args = docopt(__doc__, argv=argv or sys.argv[1:], version=version)\n if environ.get('TRAVIS') == 'true':\n commit = environ.get('TRAVIS_COMMIT', '')\n owner = environ.get('TRAVIS_REPO_SLUG', '/').split('/')[0]\n pull_request = environ.get('TRAVIS_PULL_REQUEST', '')\n if pull_request == 'false':\n pull_request = ''\n repo = environ.get('TRAVIS_REPO_SLUG', '/').split('/')[1].replace('_', '-')\n tag = environ.get('TRAVIS_TAG', '')\n commit = args['--commit'] or commit\n owner = args['--owner-name'] or owner\n pull_request = args['--pull-request'] or pull_request\n repo = args['--repo-name'] or repo\n tag = args['--tag-name'] or tag\n config = {'always_job_dirs': args['--always-job-dirs'], 'commit': commit, 'dir': args['--dir'] or '', 'ignore_errors': args['--ignore-errors'], 'job_name': args['--job-name'] or '', 'mangle_coverage': args['--mangle-coverage'], 'no_job_dirs': args['--no-job-dirs'] or '', 'owner': owner, 'pull_request': pull_request, 'raise': args['--raise'], 'repo': repo, 'tag': tag, 'verbose': args['--verbose']}\n return config"} +{"i": 240, "got": "def query_api(endpoint, log):\n \"\"\"pass\"\"\"\n url = API_PREFIX + endpoint\n headers = {'content-type': 'application/json'}\n response = None\n log.debug('Querying %s with headers %s.', url, headers)\n for i in range(QUERY_ATTEMPTS):\n try:\n try:\n response = requests.get(url, headers=headers, timeout=10)\n except (requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.Timeout):\n log.error('Timed out waiting for reply from server.')\n raise HandledError\n except requests.ConnectionError:\n log.error('Unable to connect to server.')\n raise HandledError\n except HandledError:\n if i == QUERY_ATTEMPTS - 1:\n raise\n else:\n log.warning('Network error, retrying in 1 second...')\n time.sleep(1)\n log.debug('Response status: %d', response.status_code)\n log.debug('Response headers: %s', str(response.headers))\n log.debug('Response text: %s', response.text)\n if not response.ok:\n message = response.json().get('message')\n if message:\n log.error('HTTP %d: %s', response.status_code, message)\n raise HandledError\n else:\n log.error('HTTP %d: Unknown error: %s', response.status_code, response.text)\n raise HandledError\n try:\n return response.json()\n except ValueError:\n log.error('Failed to parse JSON: %s', response.text)\n raise HandledError"} +{"i": 241, "got": "def validate(config, log):\n \"\"\"pass\"\"\"\n if config['always_job_dirs'] and config['no_job_dirs']:\n log.error('Contradiction: --always-job-dirs and --no-job-dirs used.')\n raise HandledError\n if config['commit']:\n if not REGEX_COMMIT.match(config['commit']):\n log.error('No or invalid git commit obtained.')\n raise HandledError\n if config['dir'] and (not os.path.isdir(config['dir'])):\n log.error(\"Not a directory or doesn't exist: %s\", config['dir'])\n raise HandledError\n if config['no_job_dirs'] not in ('', 'rename', 'overwrite', 'skip'):\n log.error('--no-job-dirs has invalid value. Check --help for valid values.')\n raise HandledError\n if not config['owner'] or not REGEX_GENERAL.match(config['owner']):\n log.error('No or invalid repo owner name obtained.')\n raise HandledError\n if config['pull_request'] and (not config['pull_request'].isdigit()):\n log.error('--pull-request is not a digit.')\n raise HandledError\n if config['repo'] and (not REGEX_GENERAL.match(config['repo'])):\n log.error('No or invalid repo name obtained.')\n raise HandledError\n if config['tag'] and (not REGEX_GENERAL.match(config['tag'])):\n log.error('Invalid git tag obtained.')\n raise HandledError"} +{"i": 242, "got": "def query_build_version(config, log):\n \"\"\"pass\"\"\"\n url = '/projects/{0}/{1}/history?recordsNumber=10'.format(config['owner'], config['repo'])\n log.debug('Querying AppVeyor history API for %s/%s...', config['owner'], config['repo'])\n json_data = query_api(url)\n if 'builds' not in json_data:\n log.error('Bad JSON reply: \"builds\" key missing.')\n raise HandledError\n for build in json_data['builds']:\n if config['tag'] and config['tag'] == build.get('tag'):\n log.debug('This is a tag build.')\n elif config['pull_request'] and config['pull_request'] == build.get('pullRequestId'):\n log.debug('This is a pull request build.')\n elif config['commit'] == build['commitId']:\n log.debug('This is a branch build.')\n else:\n continue\n log.debug('Build JSON dict: %s', str(build))\n return build['version']\n return None"} +{"i": 243, "got": "def incoming_messages(self) -> (t.List[t.Tuple[float, bytes]],):\n \"\"\"pass\"\"\"\n approximate_messages = self._receive_buffer.qsize()\n messages = []\n for _ in range(approximate_messages):\n try:\n messages.append(self._receive_buffer.get_nowait())\n except queue.Empty:\n break\n return messages"} +{"i": 244, "got": "def _safe_get(mapping, key, default=None):\n \"\"\"pass\"\"\"\n try:\n return mapping.get(key, default)\n except AttributeError:\n return default"} +{"i": 245, "got": "def strip_callables(row):\n \"\"\"pass\"\"\"\n callables = []\n to_delete = []\n to_add = []\n for columns, value in row.items():\n if isinstance(value, tuple):\n initial, fn = value\n else:\n initial = NOTHING\n fn = value\n if callable(fn) or inspect.isgenerator(fn):\n lgr.debug('Using %r as the initial value for columns %r in row %r', initial, columns, row)\n if not isinstance(columns, tuple):\n columns = (columns,)\n else:\n to_delete.append(columns)\n for column in columns:\n to_add.append((column, initial))\n callables.append((columns, fn))\n for column, value in to_add:\n row[column] = value\n for multi_columns in to_delete:\n del row[multi_columns]\n return callables"} +{"i": 246, "got": "def build(self, columns):\n \"\"\"pass\"\"\"\n self.columns = columns\n default = dict(elements.default('default_'), **_safe_get(self.init_style, 'default_', {}))\n self.style = elements.adopt({c: default for c in columns}, self.init_style)\n self.style['default_'] = default\n self.style['header_'] = self._compose('header_', {'align', 'width'})\n self.style['aggregate_'] = self._compose('aggregate_', {'align', 'width'})\n self.style['separator_'] = _safe_get(self.init_style, 'separator_', elements.default('separator_'))\n lgr.debug('Validating style %r', self.style)\n self.style['width_'] = _safe_get(self.init_style, 'width_', elements.default('width_'))\n elements.validate(self.style)\n self._setup_fields()\n ngaps = len(self.columns) - 1\n self.width_separtor = len(self.style['separator_']) * ngaps\n lgr.debug('Calculated separator width as %d', self.width_separtor)"} +{"i": 247, "got": "def _compose(self, name, attributes):\n \"\"\"pass\"\"\"\n name_style = _safe_get(self.init_style, name, elements.default(name))\n if self.init_style is not None and name_style is not None:\n result = {}\n for col in self.columns:\n cstyle = {k: v for k, v in self.style[col].items() if k in attributes}\n result[col] = dict(cstyle, **name_style)\n return result"} +{"i": 248, "got": "def get_config(self):\n \"\"\"pass\"\"\"\n self.create_ssl_certs()\n config = {'bootstrap_servers': self.get_brokers(), 'security_protocol': 'SSL', 'ssl_cafile': self.ssl['ca']['file'].name, 'ssl_certfile': self.ssl['cert']['file'].name, 'ssl_keyfile': self.ssl['key']['file'].name, 'ssl_check_hostname': False, 'ssl_password': None}\n self.config.update(config)"} +{"i": 249, "got": "def get_brokers(self):\n \"\"\"pass\"\"\"\n return ['{}:{}'.format(parsedUrl.hostname, parsedUrl.port) for url in [urlparse(url) for url in self.kafka_url.split(',')]]"} +{"i": 250, "got": "def create_ssl_certs(self):\n \"\"\"pass\"\"\"\n for key, file in self.ssl.items():\n file['file'] = self.create_temp_file(file['suffix'], file['content'])"} +{"i": 251, "got": "def create_temp_file(self, suffix, content):\n \"\"\"pass\"\"\"\n temp = tempfile.NamedTemporaryFile(suffix=suffix)\n temp.write(content.encode('latin1').decode('unicode_escape').encode('utf-8'))\n temp.seek(0)\n return temp"} +{"i": 252, "got": "def prefix_topic(self, topics):\n \"\"\"pass\"\"\"\n if not self.topic_prefix or not topics:\n return topics\n elif not isinstance(topics, str) and isinstance(topics, collections.Iterable):\n return [self.topic_prefix + topic for topic in topics]\n else:\n return self.topic_prefix + topics"} +{"i": 253, "got": "def send(self, topic, *args, **kwargs):\n \"\"\"pass\"\"\"\n prefix_topic = self.heroku_kafka.prefix_topic(topic)\n return super(HerokuKafkaProducer, self).send(prefix_topic, *args, **kwargs)"} +{"i": 254, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs):\n \"\"\"pass\"\"\"\n raise NotImplementedError"} +{"i": 255, "got": "def coerce(val=None, coerce_type=None, coercer: t.Optional[t.Callable]=t.Any) -> t.Any:\n \"\"\"pass\"\"\"\n if not (coerce_type or coercer):\n return val\n if coerce_type and type(val) is coerce_type:\n return val\n if coerce_type and coerce_type is bool and (not coercer):\n coercer = coerce_str_to_bool\n if coercer is None:\n coercer = coerce_type\n return coercer(val)"} +{"i": 256, "got": "def client(self):\n \"\"\"pass\"\"\"\n if self._client is not None:\n return self._client\n else:\n self._client = self.get_client()\n return self._client"} +{"i": 257, "got": "def write_uwsgi_ini_cfg(fp: t.IO, cfg: dict):\n \"\"\"pass\"\"\"\n fp.write('[uwsgi]\\n')\n for key, val in cfg.items():\n if isinstance(val, bool):\n val = str(val).lower()\n if isinstance(val, list):\n for v in val:\n fp.write(f'{key} = {v}\\n')\n else:\n fp.write(f'{key} = {val}\\n')"} +{"i": 258, "got": "def get(self, variable_path: str=None, default: t.Optional[t.Any]=None, coerce_type: t.Optional[t.Type]=None, coercer: t.Optional[t.Callable]=None, **kwargs) -> Any:\n \"\"\"pass\"\"\"\n if self.path_separator != self.consul_path_separator:\n variable_path = variable_path.replace(self.path_separator, self.consul_path_separator)\n if self.scope:\n _scope = self.consul_path_separator.join(self.scope.split(self.path_separator))\n variable_path = '{0}/{1}'.format(_scope, variable_path)\n index, data = self.client.kv.get(variable_path, **kwargs)\n if data is None:\n return default\n val = data['Value']\n if val is None:\n return val\n if val.startswith(self.object_serialize_prefix):\n _val = val[len(self.object_serialize_prefix):]\n bundle = self.object_deserialize(_val)\n if bundle == '':\n return self.coerce(bundle, coerce_type=coerce_type, coercer=coercer)\n else:\n return bundle\n if isinstance(val, bytes):\n val = val.decode()\n return self.coerce(val, coerce_type=coerce_type, coercer=coercer)"} +{"i": 259, "got": "def itunessd_to_dics(itunessd):\n \"\"\"pass\"\"\"\n header_size = get_table_size(header_table)\n header_chunk = itunessd[0:header_size]\n header_dic = chunk_to_dic(header_chunk, header_table)\n tracks_header_dic, tracks_offsets = get_dic_sub_numbers(itunessd, header_dic['tracks_header_offset'], tracks_header_table)\n tracks_dics = []\n for track_offset in tracks_offsets:\n _track_dic = chunk_to_dic(itunessd[track_offset:], track_table)\n track_dic = get_custom_fields_dic(_track_dic, track_table)\n tracks_dics.append(track_dic)\n playlists_header_dic, playlists_offsets = get_dic_sub_numbers(itunessd, header_dic['playlists_header_offset'], playlists_header_table)\n playlists_dics_and_indexes = []\n for playlist_offset in playlists_offsets:\n _playlist_header_dic, indexes_of_tracks = get_dic_sub_numbers(itunessd, playlist_offset, playlist_header_table)\n playlist_header_dic = get_custom_fields_dic(_playlist_header_dic, playlist_header_table)\n playlists_dics_and_indexes.append((playlist_header_dic, indexes_of_tracks))\n return (get_custom_fields_dic(header_dic, header_table), tracks_dics, playlists_dics_and_indexes)"} +{"i": 260, "got": "def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):\n \"\"\"pass\"\"\"\n header_dic['length'] = get_table_size(header_table)\n header_dic['number_of_tracks'] = len(tracks_dics)\n header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)\n header_dic['number_of_tracks2'] = 0\n header_part_size = get_table_size(header_table)\n tracks_header_dic = {'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics), 'number_of_tracks': len(tracks_dics)}\n tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)\n [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]\n _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in playlists_dics_and_indexes]\n all_tracks_chunck = b''.join(_tracks_chunks)\n _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)\n tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)\n track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck\n _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]\n _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]\n playlists_header_dic = {'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes), 'number_of_all_playlists': len(_types), 'flag1': 4294967295 if _types.count(NORMAL) == 0 else 1, 'number_of_normal_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(MASTER) + _types.count(NORMAL) + _types.count(PODCAST), 'flag2': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(1) + _types.count(NORMAL), 'number_of_audiobook_playlists': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST), 'flag3': 4294967295 if _types.count(AUDIOBOOK) == 0 else _types.count(PODCAST) + _types.count(NORMAL), 'number_of_podcast_playlists': 4294967295 if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL)}\n playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)\n _playlists_chunks = []\n for playlist_header_dic, indexes in playlists_dics_and_indexes:\n dic = playlist_header_dic.copy()\n dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)\n dic['number_of_all_track'] = len(indexes)\n dic['number_of_normal_track'] = len(indexes) if dic['type'] in [1, 2] else 0\n if dic['type'] == MASTER:\n header_dic['number_of_tracks2'] = len(indexes)\n _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)\n _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])\n playlist_chunk = _playlist_header_chunk + _indexes_chunk\n _playlists_chunks.append(playlist_chunk)\n all_playlists_chunk = b''.join(_playlists_chunks)\n _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)\n playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)\n playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk\n header_dic['tracks_header_offset'] = header_part_size\n header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)\n header_part_chunk = dic_to_chunk(header_dic, header_table)\n itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk\n return itunessd"} +{"i": 261, "got": "def create_plan(existing_users=None, proposed_users=None, purge_undefined=None, protected_users=None, allow_non_unique_id=True, manage_home=True, manage_keys=True):\n \"\"\"pass\"\"\"\n plan = list()\n proposed_usernames = list()\n if not purge_undefined:\n purge_undefined = constants.PURGE_UNDEFINED\n if not protected_users:\n protected_users = constants.PROTECTED_USERS\n if not allow_non_unique_id:\n allow_non_unique_id = constants.ALLOW_NON_UNIQUE_ID\n for proposed_user in proposed_users:\n proposed_usernames.append(proposed_user.name)\n user_matching_name = existing_users.describe_users(users_filter=dict(name=proposed_user.name))\n user_matching_id = get_user_by_uid(uid=proposed_user.uid, users=existing_users)\n if not allow_non_unique_id and user_matching_id and (not user_matching_name):\n plan.append(dict(action='fail', error='uid_clash', proposed_user=proposed_user, state='existing', result=None))\n elif not user_matching_name:\n plan.append(dict(action='add', proposed_user=proposed_user, state='missing', result=None, manage_home=manage_home, manage_keys=manage_keys))\n else:\n user_comparison = compare_user(passed_user=proposed_user, user_list=existing_users)\n if user_comparison.get('result'):\n plan.append(dict(action='update', proposed_user=proposed_user, state='existing', user_comparison=user_comparison, manage_home=manage_home, manage_keys=manage_keys))\n if purge_undefined:\n for existing_user in existing_users:\n if existing_user.name not in proposed_usernames and existing_user.name not in protected_users:\n plan.append(dict(action='delete', username=existing_user.name, state='existing', manage_home=manage_home, manage_keys=manage_keys))\n return plan"} +{"i": 262, "got": "def execute_plan(plan=None):\n \"\"\"pass\"\"\"\n execution_result = list()\n for task in plan:\n action = task['action']\n if action == 'delete':\n command = generate_delete_user_command(username=task.get('username'), manage_home=task['manage_home'])\n command_output = execute_command(command)\n execution_result.append(dict(task=task, command_output=command_output))\n remove_sudoers_entry(username=task.get('username'))\n elif action == 'add':\n command = generate_add_user_command(proposed_user=task.get('proposed_user'), manage_home=task['manage_home'])\n command_output = execute_command(command)\n if task['proposed_user'].public_keys and task['manage_home'] and task['manage_keys']:\n write_authorized_keys(task['proposed_user'])\n if task['proposed_user'].sudoers_entry:\n write_sudoers_entry(username=task['proposed_user'].name, sudoers_entry=task['proposed_user'].sudoers_entry)\n execution_result.append(dict(task=task, command_output=command_output))\n elif action == 'update':\n result = task['user_comparison'].get('result')\n action_count = 0\n for k, _ in iteritems(result):\n if '_action' in k:\n action_count += 1\n command_output = None\n if task['manage_home'] and task['manage_keys'] and (action_count == 1) and ('public_keys_action' in result):\n write_authorized_keys(task['proposed_user'])\n elif action_count == 1 and 'sudoers_entry_action' in result:\n write_sudoers_entry(username=task['proposed_user'].name, sudoers_entry=task['user_comparison']['result']['replacement_sudoers_entry'])\n else:\n command = generate_modify_user_command(task=task)\n command_output = execute_command(command)\n if task['manage_home'] and task['manage_keys'] and result.get('public_keys_action'):\n write_authorized_keys(task['proposed_user'])\n if result.get('sudoers_entry_action'):\n write_sudoers_entry(username=task['proposed_user'].name, sudoers_entry=task['user_comparison']['result']['replacement_sudoers_entry'])\n execution_result.append(dict(task=task, command_output=command_output))"} +{"i": 263, "got": "def output(self, output, accepts, set_http_code, set_content_type):\n \"\"\"pass\"\"\"\n graph = Decorator._get_graph(output)\n if graph is not None:\n output_mimetype, output_format = self.format_selector.decide(accepts, graph.context_aware)\n if output_mimetype is None:\n set_http_code('406 Not Acceptable')\n return ['406 Not Acceptable'.encode('utf-8')]\n if 'text' in output_mimetype:\n output_mimetype = output_mimetype + '; charset=utf-8'\n serialized = graph.serialize(format=output_format)\n set_content_type(output_mimetype)\n return [serialized]\n else:\n return output"} +{"i": 264, "got": "def add(self, src):\n \"\"\"pass\"\"\"\n checksum = get_checksum(src)\n filename = self.get_filename(checksum)\n if not filename:\n new_name = self._get_new_name()\n new_realpath = self._storage_dir + '/' + new_name\n os.makedirs(os.path.split(new_realpath)[0], exist_ok=True)\n shutil.copyfile(src, new_realpath)\n self._log[new_name] = {'checksum': checksum, 'mtime': os.path.getmtime(new_realpath), 'size': os.path.getsize(new_realpath)}\n self.write_log()\n return checksum"} +{"i": 265, "got": "def schemas(self):\n \"\"\"pass\"\"\"\n sql = 'SELECT schema_name FROM information_schema.schemata\\n ORDER BY schema_name'\n schemas = self.query(sql).fetchall()\n return [s[0] for s in schemas if s[0][:3] != 'pg_']"} +{"i": 266, "got": "def tables(self):\n \"\"\"pass\"\"\"\n if self.schema:\n return self.tables_in_schema(self.schema)\n else:\n tables = []\n for schema in self.schemas:\n tables = tables + [schema + '.' + t for t in self.tables_in_schema(schema)]\n return tables"} +{"i": 267, "got": "def _valid_table_name(self, table):\n \"\"\"pass\"\"\"\n if table is None or not len(table.strip()):\n raise ValueError('Invalid table name: %r' % table)\n return table.strip()"} +{"i": 268, "got": "def build_query(self, sql, lookup):\n \"\"\"pass\"\"\"\n for key, val in six.iteritems(lookup):\n sql = sql.replace('$' + key, val)\n return sql"} +{"i": 269, "got": "def tables_in_schema(self, schema):\n \"\"\"pass\"\"\"\n sql = 'SELECT table_name\\n FROM information_schema.tables\\n WHERE table_schema = %s'\n return [t[0] for t in self.query(sql, (schema,)).fetchall()]"} +{"i": 270, "got": "def parse_table_name(self, table):\n \"\"\"pass\"\"\"\n if '.' in table:\n schema, table = table.split('.')\n else:\n schema = None\n return (schema, table)"} +{"i": 271, "got": "def read_authorized_keys(username=None):\n \"\"\"pass\"\"\"\n authorized_keys_path = '{0}/.ssh/authorized_keys'.format(os.path.expanduser('~{0}'.format(username)))\n rnd_chars = random_string(length=RANDOM_FILE_EXT_LENGTH)\n tmp_authorized_keys_path = '/tmp/authorized_keys_{0}_{1}'.format(username, rnd_chars)\n authorized_keys = list()\n copy_result = execute_command(shlex.split(str('{0} cp {1} {2}'.format(sudo_check(), authorized_keys_path, tmp_authorized_keys_path))))\n result_message = copy_result[0][1].decode('UTF-8')\n if 'you must have a tty to run sudo' in result_message:\n raise OSError(\"/etc/sudoers is blocked sudo. Remove entry: 'Defaults requiretty'.\")\n if 'No such file or directory' not in result_message:\n execute_command(shlex.split(str('{0} chmod 755 {1}'.format(sudo_check(), tmp_authorized_keys_path))))\n with open(tmp_authorized_keys_path) as keys_file:\n for key in keys_file:\n authorized_keys.append(PublicKey(raw=key))\n execute_command(shlex.split(str('{0} rm {1}'.format(sudo_check(), tmp_authorized_keys_path))))\n return authorized_keys"} +{"i": 272, "got": "def write_authorized_keys(user=None):\n \"\"\"pass\"\"\"\n authorized_keys = list()\n authorized_keys_dir = '{0}/.ssh'.format(os.path.expanduser('~{0}'.format(user.name)))\n rnd_chars = random_string(length=RANDOM_FILE_EXT_LENGTH)\n authorized_keys_path = '{0}/authorized_keys'.format(authorized_keys_dir)\n tmp_authorized_keys_path = '/tmp/authorized_keys_{0}_{1}'.format(user.name, rnd_chars)\n if not os.path.isdir(authorized_keys_dir):\n execute_command(shlex.split(str('{0} mkdir -p {1}'.format(sudo_check(), authorized_keys_dir))))\n for key in user.public_keys:\n authorized_keys.append('{0}\\n'.format(key.raw))\n with open(tmp_authorized_keys_path, mode=text_type('w+')) as keys_file:\n keys_file.writelines(authorized_keys)\n execute_command(shlex.split(str('{0} cp {1} {2}'.format(sudo_check(), tmp_authorized_keys_path, authorized_keys_path))))\n execute_command(shlex.split(str('{0} chown -R {1} {2}'.format(sudo_check(), user.name, authorized_keys_dir))))\n execute_command(shlex.split(str('{0} chmod 700 {1}'.format(sudo_check(), authorized_keys_dir))))\n execute_command(shlex.split(str('{0} chmod 600 {1}'.format(sudo_check(), authorized_keys_path))))\n execute_command(shlex.split(str('{0} rm {1}'.format(sudo_check(), tmp_authorized_keys_path))))"} +{"i": 273, "got": "def b64encoded(self):\n \"\"\"pass\"\"\"\n if self._b64encoded:\n return text_type(self._b64encoded).strip('\\r\\n')\n else:\n return base64encode(self.raw)"} +{"i": 274, "got": "def raw(self):\n \"\"\"pass\"\"\"\n if self._raw:\n return text_type(self._raw).strip('\\r\\n')\n else:\n return text_type(base64decode(self._b64encoded)).strip('\\r\\n')"} +{"i": 275, "got": "def add_format(mimetype, format, requires_context=False):\n \"\"\"pass\"\"\"\n global formats, ctxless_mimetypes, all_mimetypes\n formats[mimetype] = format\n if not requires_context:\n ctxless_mimetypes.append(mimetype)\n all_mimetypes.append(mimetype)"} +{"i": 276, "got": "def add_format(self, mimetype, format, requires_context=False):\n \"\"\"pass\"\"\"\n self.formats[mimetype] = format\n if not requires_context:\n self.ctxless_mimetypes.append(mimetype)\n self.all_mimetypes.append(mimetype)"} +{"i": 277, "got": "def get_default_mimetype(self):\n \"\"\"pass\"\"\"\n mimetype = self.default_mimetype\n if mimetype is None:\n mimetype = DEFAULT_MIMETYPE\n if mimetype is None:\n mimetype = 'application/rdf+xml'\n return mimetype"} +{"i": 278, "got": "def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):\n \"\"\"pass\"\"\"\n backoff_interval = interval\n raised_exc = None\n attempt = 0\n if method not in ['get', 'patch', 'post']:\n raise ValueError\n if retries == -1:\n attempt = -1\n elif retries == 0:\n attempt = 1\n else:\n attempt = retries + 1\n while attempt != 0:\n if raised_exc:\n logger.error('Caught \"%s\" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)\n await asyncio.sleep(backoff_interval)\n backoff_interval *= backoff\n try:\n response = (await getattr(session, method)(url, **kwargs))[0]\n if response.status == 200:\n return await fn(response)\n elif response.status in http_status_codes_to_retry:\n logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)\n raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)\n else:\n raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)\n except aiohttp.ClientError as exc:\n try:\n code = exc.code\n except AttributeError:\n code = ''\n raised_exc = FailedRequest(code=code, message='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), raised=url)\n except asyncio.TimeoutError as exc:\n raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised=exc.__class__.__module__ + '.' + exc.__class__.__qualname__, url=url)\n attempt -= 1\n if raised_exc:\n raise raised_exc"} +{"i": 279, "got": "def generate_output(self, writer):\n \"\"\"pass\"\"\"\n with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:\n with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:\n xsl = fd_origin.read()\n xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))\n fd_destination.write(xsl)\n urls = ''\n articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)\n pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))\n pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)\n pages_without_date = list(filter(lambda p: p != 'index', self.context.get('pages')))\n pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)\n pages_sorted = pages_with_date_sorted + pages_without_date_sorted\n if 'index' in self.context.get('DIRECT_TEMPLATES'):\n index_reference = None\n if len(articles_sorted) > 0:\n index_reference = articles_sorted[0]\n elif len(pages_sorted) > 0:\n index_reference = pages_sorted[0]\n if index_reference is not None:\n urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)\n for article in articles_sorted:\n urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))\n for page in pages_sorted:\n urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))\n if self.context.get('CATEGORY_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('categories'))\n if self.context.get('TAG_URL'):\n urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0]))\n if self.context.get('AUTHOR_URL'):\n urls += self.__process_url_wrapper_elements(self.context.get('authors'))\n for direct_template in list(filter(lambda p: getattr(p, 'modified', None) is not getattr(p, 'date', None), self.context.get('DIRECT_TEMPLATES'))):\n modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))\n url = self.__get_direct_template_url(direct_template)\n urls += self.__create_url_node_for_content(None, 'others', url, modification_time)\n with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:\n fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})"} +{"i": 280, "got": "def __get_direct_template_url(self, name):\n \"\"\"pass\"\"\"\n url = self.pelican_settings.get('{}_SAVE_AS'.format(name.upper()))\n if url is None:\n url = self.settings.get('{}_URL'.format(name.upper()), '{}.html'.format(name))\n return urljoin(self.url_site, url)"} +{"i": 281, "got": "def __process_url_wrapper_elements(self, elements):\n \"\"\"pass\"\"\"\n urls = ''\n for url_wrapper, articles in elements:\n urls += self.__create_url_node_for_content(url=url_wrapper, modification_time='others', url=urljoin(self.url_site, url_wrapper.url), modification_time=self.__get_date_key(sorted(articles, key=self.__get_date_key, reverse=True)[0]))\n return urls"} +{"i": 282, "got": "def __create_url_node_for_content(self, content, content_type, url=None, modification_time=None):\n \"\"\"pass\"\"\"\n loc = url\n if loc is None:\n loc = urljoin(self.url_site, self.context.get('ARTICLE_URL').format(**content.url_format))\n lastmod = None\n if modification_time is not None:\n lastmod = modification_time.strftime('%Y-%m-%d')\n elif content is not None and getattr(content, 'modified', None) is not None:\n lastmod = getattr(content, 'modified').strftime('%Y-%m-%d')\n elif content is not None and getattr(content, 'date', None) is not None:\n lastmod = getattr(content, 'date').strftime('%Y-%m-%d')\n output = '{}'.format(loc)\n if lastmod is not None:\n output += '\\n{}'.format(lastmod)\n output += '\\n{}'.format(self.settings.get('changefrequencies').get(content_type))\n output += '\\n{:.2f}'.format(self.settings.get('priorities').get(content_type))\n return self.template_url.format(output)"} +{"i": 283, "got": "def add_attachment(message, attachment, rfc2231=True):\n \"\"\"pass\"\"\"\n data = attachment.read()\n part = MIMEBase('application', 'octet-stream')\n part.set_payload(data)\n encoders.encode_base64(part)\n filename = attachment.name if rfc2231 else Header(attachment.name).encode()\n part.add_header('Content-Disposition', 'attachment', filename=filename)\n message.attach(part)"} +{"i": 284, "got": "def _login(self):\n \"\"\"pass\"\"\"\n server, port, mode, debug = self.connection_details\n if mode == 'SSL':\n smtp_class = smtplib.SMTP_SSL\n else:\n smtp_class = smtplib.SMTP\n smtp = smtp_class(server, port)\n smtp.set_debuglevel(debug)\n if mode == 'TLS':\n smtp.starttls()\n self.authenticate(smtp)\n return smtp"} +{"i": 285, "got": "def send(self, email, attachments=()):\n \"\"\"pass\"\"\"\n msg = email.as_mime(attachments)\n if 'From' not in msg:\n msg['From'] = self.sender_address()\n if self._conn:\n self._conn.sendmail(self.username, email.recipients, msg.as_string())\n else:\n with self:\n self._conn.sendmail(self.username, email.recipients, msg.as_string())"} +{"i": 286, "got": "def check(qpi_or_h5file, checks=['attributes', 'background']):\n \"\"\"pass\"\"\"\n if isinstance(checks, str):\n checks = [checks]\n for ch in checks:\n if not ch in ['attributes', 'background']:\n raise ValueError('Unknown check: {}'.format(check))\n if isinstance(qpi_or_h5file, QPImage):\n qpi = qpi_or_h5file\n else:\n qpi = QPImage(h5file=qpi_or_h5file, h5mode='r')\n if 'attributes' in checks:\n check_attributes(qpi)\n if 'background' in checks:\n check_background(qpi)"} +{"i": 287, "got": "def check_attributes(qpi):\n \"\"\"pass\"\"\"\n missing_attrs = []\n for key in DATA_KEYS:\n if key not in qpi.meta:\n missing_attrs.append(key)\n if missing_attrs:\n msg = 'Attributes are missing: {} '.format(missing_attrs) + 'in {}!'.format(qpi)\n raise IntegrityCheckError(msg)"} +{"i": 288, "got": "def check_background(qpi):\n \"\"\"pass\"\"\"\n for imdat in [qpi._amp, qpi._pha]:\n try:\n fit, attrs = imdat.get_bg(key='fit', ret_attrs=True)\n except KeyError:\n pass\n else:\n kwargs = dict(attrs)\n binkey = 'estimate_bg_from_mask'\n if binkey in imdat.h5:\n kwargs['from_mask'] = imdat.h5[binkey][:]\n else:\n kwargs['from_mask'] = None\n with h5py.File('check.h5', driver='core', backing_store=False) as h5:\n testimdat = imdat.__class__(h5)\n testimdat['raw'] = imdat.raw\n try:\n bg = imdat.get_bg('data')\n except KeyError:\n pass\n else:\n testimdat.set_bg(bg, key='data')\n testimdat.estimate_bg(**kwargs)\n if not np.allclose(testimdat.get_bg(key='fit'), fit):\n msg = 'Wrong estimated (fitted) background!'\n raise IntegrityCheckError(msg)"} +{"i": 289, "got": "def write_image_dataset(group, key, data, h5dtype=None):\n \"\"\"pass\"\"\"\n if h5dtype is None:\n h5dtype = data.dtype\n if key in group:\n del group[key]\n if group.file.driver == 'core':\n kwargs = {}\n else:\n kwargs = {'fletcher32': True, 'chunks': data.shape}\n kwargs.update(COMPRESSION)\n dset = group.create_dataset(key, data=data.astype(h5dtype), **kwargs)\n dset.attrs.create('CLASS', b'IMAGE')\n dset.attrs.create('IMAGE_VERSION', b'1.2')\n dset.attrs.create('IMAGE_SUBCLASS', b'IMAGE_GRAYSCALE')\n return dset"} +{"i": 290, "got": "def info(self):\n \"\"\"pass\"\"\"\n info = []\n name = self.__class__.__name__.lower()\n for key in VALID_BG_KEYS:\n if key in self.h5['bg_data']:\n attrs = self.h5['bg_data'][key].attrs\n for akey in attrs:\n atr = attrs[akey]\n var = '{} background {}'.format(name, akey)\n info.append((var, atr))\n if 'fit' in self.h5['bg_data']:\n var_mask = '{} background from mask'.format(name)\n if 'estimate_bg_from_mask' in self.h5 and self.h5['estimate_bg_from_mask'] is not None:\n info.append((var_mask, True))\n elif 'estimate_bg_from_binary' in self.h5 and self.h5['estimate_bg_from_binary'] is not None:\n warnings.warn('Old file format detected!', DeprecationWarning)\n info.append((var_mask, True))\n else:\n info.append((var_mask, False))\n return info"} +{"i": 291, "got": "def del_bg(self, key):\n \"\"\"pass\"\"\"\n if key not in VALID_BG_KEYS:\n raise ValueError('Invalid bg key: {}'.format(key))\n elif key in self.h5['bg_data']:\n del self.h5['bg_data'][key]\n else:\n msg = \"No bg data to clear for '{}' in {}.\".format(key, self)\n warnings.warn(msg)"} +{"i": 292, "got": "def main() -> int:\n \"\"\"pass\"\"\"\n parser = argparse.ArgumentParser()\n parser.add_argument('--overwrite', help='Overwrites the unformatted source files with the well-formatted code in place. If not set, an exception is raised if any of the files do not conform to the style guide.', action='store_true')\n args = parser.parse_args()\n overwrite = bool(args.overwrite)\n repo_root = pathlib.Path(__file__).parent\n print(\"YAPF'ing...\")\n if overwrite:\n subprocess.check_call(['yapf', '--in-place', '--style=style.yapf', '--recursive', 'tests', 'icontract', 'setup.py', 'precommit.py'], cwd=repo_root.as_posix())\n else:\n subprocess.check_call(['yapf', '--diff', '--style=style.yapf', '--recursive', 'tests', 'icontract', 'setup.py', 'precommit.py'], cwd=repo_root.as_posix())\n print(\"Mypy'ing...\")\n subprocess.check_call(['mypy', 'icontract', 'tests'], cwd=repo_root.as_posix())\n print(\"Pylint'ing...\")\n subprocess.check_call(['pylint', '--rcfile=pylint.rc', 'tests', 'icontract'], cwd=repo_root.as_posix())\n print(\"Pydocstyle'ing...\")\n subprocess.check_call(['pydocstyle', 'icontract'], cwd=repo_root.as_posix())\n print('Testing...')\n env = os.environ.copy()\n env['ICONTRACT_SLOW'] = 'true'\n subprocess.check_call(['coverage', 'run', '--source', 'icontract', '-m', 'unittest', 'discover', 'tests'], cwd=repo_root.as_posix(), env=env)\n subprocess.check_call(['coverage', 'report'])\n print('Doctesting...')\n subprocess.check_call(['python3', '-m', 'doctest', 'README.rst'])\n for pth in (repo_root / 'icontract').glob('**/*.py'):\n subprocess.check_call(['python3', '-m', 'doctest', pth.as_posix()])\n print('Checking the restructured text of the readme...')\n subprocess.check_call(['python3', 'setup.py', 'check', '--restructuredtext', '--strict'])\n return 0"} +{"i": 293, "got": "def _collapse_invariants(bases: List[type], namespace: MutableMapping[str, Any]) -> None:\n \"\"\"pass\"\"\"\n invariants = []\n for base in bases:\n if hasattr(base, '__invariants__'):\n invariants.extend(getattr(base, '__invariants__'))\n if '__invariants__' in namespace:\n invariants.extend(namespace['__invariants__'])\n if invariants:\n namespace['__invariants__'] = invariants"} +{"i": 294, "got": "def _collapse_preconditions(base_preconditions: List[List[Contract]], bases_have_func: bool, preconditions: List[List[Contract]], func: Callable[..., Any]) -> List[List[Contract]]:\n \"\"\"pass\"\"\"\n if not base_preconditions and bases_have_func and preconditions:\n raise TypeError(\"The function {} can not weaken the preconditions because the bases specify no preconditions at all. Hence this function must accept all possible input since the preconditions are OR'ed and no precondition implies a dummy precondition which is always fulfilled.\".format(func.__qualname__))\n return base_preconditions + preconditions"} +{"i": 295, "got": "def _collapse_snapshots(base_snapshots: List[Snapshot], snapshots: List[Snapshot]) -> List[Snapshot]:\n \"\"\"pass\"\"\"\n seen_names = set()\n collapsed = base_snapshots + snapshots\n for snap in collapsed:\n if snap.name in seen_names:\n raise ValueError('There are conflicting snapshots with the name: {!r}.\\n\\nPlease mind that the snapshots are inherited from the base classes. Does one of the base classes defines a snapshot with the same name?'.format(snap.name))\n seen_names.add(snap.name)\n return collapsed"} +{"i": 296, "got": "def _collapse_postconditions(base_postconditions: List[Contract], postconditions: List[Contract]) -> List[Contract]:\n \"\"\"pass\"\"\"\n return base_postconditions + postconditions"} +{"i": 297, "got": "def _decorate_namespace_function(bases: List[type], namespace: MutableMapping[str, Any], key: str) -> None:\n \"\"\"pass\"\"\"\n value = namespace[key]\n assert inspect.isfunction(value) or isinstance(value, (staticmethod, classmethod))\n if inspect.isfunction(value):\n func = value\n elif isinstance(value, (staticmethod, classmethod)):\n func = value.__func__\n else:\n raise NotImplementedError('Unexpected value for a function: {}'.format(value))\n preconditions: List[icontract._checkers.Precondition] = []\n snapshots: List[icontract._checkers.Snapshot] = []\n postconditions: List[icontract._checkers.Postcondition] = []\n contract_checker = icontract._checkers.find_checker(func=func)\n if contract_checker is not None:\n preconditions = contract_checker.__preconditions__\n snapshots = contract_checker.__postcondition_snapshots__\n postconditions = contract_checker.__postconditions__\n if key not in ['__init__']:\n base_preconditions: List[icontract._checkers.Precondition] = []\n base_snapshots: List[icontract._checkers.Snapshot] = []\n base_postconditions: List[icontract._checkers.Postcondition] = []\n bases_have_func = False\n for base in bases:\n if not hasattr(base, key):\n continue\n bases_have_func = True\n base_func = getattr(base, key)\n base_contract_checker = icontract._checkers.find_checker(func=base_func)\n if base_contract_checker is None:\n continue\n base_preconditions.extend(base_contract_checker.__preconditions__)\n base_snapshots.extend(base_contract_checker.__postcondition_snapshots__)\n base_postconditions.extend(base_contract_checker.__postconditions__)\n preconditions = _collapse_preconditions(base_preconditions=base_preconditions, bases_have_func=bases_have_func, preconditions=preconditions, func=func)\n snapshots = _collapse_snapshots(base_snapshots=base_snapshots, snapshots=snapshots)\n postconditions = _collapse_postconditions(base_postconditions=base_postconditions, postconditions=postconditions)\n if preconditions or postconditions:\n if contract_checker is None:\n contract_checker = icontract._checkers.decorate_with_checker(func=func)\n if inspect.isfunction(value):\n namespace[key] = contract_checker\n elif isinstance(value, staticmethod):\n namespace[key] = staticmethod(contract_checker)\n elif isinstance(value, classmethod):\n namespace[key] = classmethod(contract_checker)\n else:\n raise NotImplementedError('Unexpected value for a function: {}'.format(value))\n contract_checker.__preconditions__ = preconditions\n contract_checker.__postcondition_snapshots__ = snapshots\n contract_checker.__postconditions__ = postconditions"} +{"i": 298, "got": "def tokenize_sents(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n spans = []\n for match in re.finditer('[^\\\\s]+', string):\n spans.append(match)\n spans_count = len(spans)\n rez = []\n off = 0\n for i in range(spans_count):\n tok = string[spans[i].start():spans[i].end()]\n if i == spans_count - 1:\n rez.append(string[off:spans[i].end()])\n elif tok[-1] in ['.', '!', '?', '\u2026', '\u00bb']:\n tok1 = tok[re.search('[.!?\u2026\u00bb]', tok).start() - 1]\n next_tok = string[spans[i + 1].start():spans[i + 1].end()]\n if next_tok[0].isupper():\n continue\n elif tok1.isupper():\n continue\n elif tok[-1] != '.':\n continue\n elif tok1[0] == '(':\n continue\n elif tok in ABBRS:\n continue\n else:\n rez.append(string[off:spans[i].end()])\n off = spans[i + 1].start()\n return rez"} +{"i": 299, "got": "def tokenize_text(string):\n \"\"\"pass\"\"\"\n string = six.text_type(string)\n rez = []\n for part in string.split('\\n'):\n par = []\n for sent in tokenize_sents(part):\n par.append(tokenize_words(sent))\n if par:\n rez.append(par)\n return rez"} +{"i": 300, "got": "def override_djconfig(**new_cache_values):\n \"\"\"pass\"\"\"\n\n def decorator(func):\n\n @wraps(func)\n def func_wrapper(*args, **kw):\n old_cache_values = {key: getattr(conf.config, key) for key in new_cache_values}\n conf.config._set_many(new_cache_values)\n try:\n return func(*args, **kw)\n finally:\n conf.config._set_many(old_cache_values)\n return func_wrapper\n return decorator"} +{"i": 301, "got": "def serialize(value, field):\n \"\"\"pass\"\"\"\n assert isinstance(field, forms.Field)\n if isinstance(field, forms.ModelMultipleChoiceField):\n return json.dumps([v.pk for v in value])\n elif isinstance(value, models.Model):\n return value.pk\n else:\n return value"} +{"i": 302, "got": "def get_version(package):\n \"\"\"pass\"\"\"\n with io.open(os.path.join(BASE_DIR, package, '__init__.py'), encoding='utf-8') as fh:\n return [l.split('=', 1)[1].strip().strip(\"'\").strip('\"') for l in fh.readlines() if '__version__' in l][0]"} +{"i": 303, "got": "def _check_backend():\n \"\"\"pass\"\"\"\n middleware = set(getattr(settings, 'MIDDLEWARE', None) or getattr(settings, 'MIDDLEWARE_CLASSES', None) or [])\n if 'djconfig.middleware.DjConfigLocMemMiddleware' in middleware:\n return\n elif 'djconfig.middleware.DjConfigMiddleware' in middleware:\n return\n else:\n raise ValueError('djconfig.middleware.DjConfigMiddleware is required but it was not found in MIDDLEWARE_CLASSES nor in MIDDLEWARE')"} +{"i": 304, "got": "def _register(self, form_class, check_middleware=True):\n \"\"\"pass\"\"\"\n if not issubclass(form_class, _ConfigFormBase):\n raise ValueError('The form does not inherit from `forms.ConfigForm`')\n self._registry.add(form_class)\n if check_middleware:\n _check_backend()"} +{"i": 305, "got": "def _reload(self):\n \"\"\"pass\"\"\"\n ConfigModel = apps.get_model('djconfig.Config')\n cache = {}\n data = dict(ConfigModel.objects.all().values_list('key', 'value'))\n for form_class in self._registry:\n empty_form = form_class()\n cache.update({name: field.initial for name, field in empty_form.fields.items()})\n form = form_class(data={name: _deserialize(data[name], field) for name, field in empty_form.fields.items() if name in data and (not isinstance(field, forms.FileField))})\n form.is_valid()\n cache.update({name: _unlazify(value) for name, value in form.cleaned_data.items() if name in data})\n cache.update({name: data[name] for name, field in empty_form.fields.items() if name in data and isinstance(field, forms.FileField)})\n cache['_updated_at'] = data.get('_updated_at')\n self._cache = cache"} +{"i": 306, "got": "def Mixed(*types):\n \"\"\"pass\"\"\"\n if len(types) < 2:\n raise ValueError('Mixed type requires at least 2 specific types')\n types = set(types)\n\n class MixedType(type):\n\n def __instancecheck__(cls, instance):\n \"\"\"pass\"\"\"\n for mtype in types:\n if isinstance(instance, mtype):\n return True\n return False\n\n class Mixed(object):\n __metaclass__ = MixedType\n return Mixed"} +{"i": 307, "got": "def one_of(*args):\n \"\"\"pass\"\"\"\n if len(args) == 1 and isinstance(args[0], list):\n items = args[0]\n else:\n items = list(args)\n\n def validate(value):\n if value not in items:\n return e('{} is not in the list {}', value, items)\n return validate"} +{"i": 308, "got": "def gte(min_value):\n \"\"\"pass\"\"\"\n\n def validate(value):\n if value < min_value:\n return e('{} is not greater than or equal to {}', value, min_value)\n return validate"} +{"i": 309, "got": "def lte(max_value):\n \"\"\"pass\"\"\"\n\n def validate(value):\n if value > max_value:\n return e('{} is not less than or equal to {}', value, max_value)\n return validate"} +{"i": 310, "got": "def gt(gt_value):\n \"\"\"pass\"\"\"\n\n def validate(value):\n if value <= gt_value:\n return e('{} is not greater than {}', value, gt_value)\n return validate"} +{"i": 311, "got": "def lt(lt_value):\n \"\"\"pass\"\"\"\n\n def validate(value):\n if value >= lt_value:\n return e('{} is not less than {}', value, lt_value)\n return validate"} +{"i": 312, "got": "def load_config(path=None, defaults=None):\n \"\"\"pass\"\"\"\n if defaults is None:\n defaults = DEFAULT_FILES\n config = ConfigParser(allow_no_value=True)\n if defaults:\n config.read(defaults)\n if path:\n with open(path) as fh:\n config.read_file(fh)\n return config"} +{"i": 313, "got": "def as_dict(config):\n \"\"\"pass\"\"\"\n settings = defaultdict(lambda: {})\n for section in config.sections():\n for key, val in config.items(section):\n settings[section][key] = val\n return settings"} +{"i": 314, "got": "def initialize(self, timeouts):\n \"\"\"pass\"\"\"\n if self.bind is True:\n self.socket.bind(self.address)\n else:\n self.socket.connect(self.address)\n self._set_timeouts(timeouts)"} +{"i": 315, "got": "def _set_timeouts(self, timeouts):\n \"\"\"pass\"\"\"\n send_timeout, recv_timeout = (None, None)\n try:\n send_timeout, recv_timeout = timeouts\n except TypeError:\n raise EndpointError('`timeouts` must be a pair of numbers (2, 3) which represent the timeout values for send and receive respectively')\n if send_timeout is not None:\n self.socket.set_int_option(nanomsg.SOL_SOCKET, nanomsg.SNDTIMEO, send_timeout)\n if recv_timeout is not None:\n self.socket.set_int_option(nanomsg.SOL_SOCKET, nanomsg.RCVTIMEO, recv_timeout)"} +{"i": 316, "got": "def send(self, payload):\n \"\"\"pass\"\"\"\n payload = self.encode(payload)\n payload = self.sign(payload)\n self.socket.send(payload)"} +{"i": 317, "got": "def receive(self, decode=True):\n \"\"\"pass\"\"\"\n payload = self.socket.recv()\n payload = self.verify(payload)\n if decode:\n payload = self.decode(payload)\n return payload"} +{"i": 318, "got": "def sign(self, payload):\n \"\"\"pass\"\"\"\n if self.authenticator:\n return self.authenticator.signed(payload)\n else:\n return payload"} +{"i": 319, "got": "def verify(self, payload):\n \"\"\"pass\"\"\"\n if not self.authenticator:\n return payload\n try:\n self.authenticator.auth(payload)\n return self.authenticator.unsigned(payload)\n except AuthenticatorInvalidSignature:\n raise\n except Exception as exception:\n raise AuthenticateError(str(exception))"} +{"i": 320, "got": "def get_summary(list_all=[], **kwargs):\n \"\"\"pass\"\"\"\n all_summary = []\n for module in list_all:\n summary = {'module_name': module['Name'], 'show_all': kwargs.get('show_all', True), 'project_name': kwargs.get('proj_name', 'TestProject'), 'home_page': kwargs.get('home_page', __about__.HOME_PAGE), 'start_time': '', 'end_time': '', 'duration_seconds': 0, 'total_case_num': 0, 'pass_cases_num': 0, 'fail_cases_num': 0, 'details': []}\n for case in module['TestCases']:\n case_detail = {}\n case_detail['linkurl'] = './caselogs/%s_%s.log' % (case['case_name'], case['exec_date'])\n if case['status'].lower() == 'pass':\n summary['pass_cases_num'] += 1\n case_detail['c_style'] = 'tr_pass'\n else:\n summary['fail_cases_num'] += 1\n case_detail['c_style'] = 'tr_fail'\n case_detail.update(case)\n summary['details'].append(case_detail)\n try:\n st = module['TestCases'][0].get('start_at')\n et = module['TestCases'][-1].get('end_at')\n summary['start_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(st))\n summary['end_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(et))\n summary['duration_seconds'] = float('%.2f' % (et - st))\n except Exception as _:\n logger.log_warning(\"Will set 'start_at' and 'end_at' to 'None'\")\n summary['start_time'], summary['end_time'], summary['duration_seconds'] = (None, None, None)\n if summary['fail_cases_num'] > 0:\n summary['dict_report'] = {'result': 0, 'message': 'failure', 'pass': summary['pass_cases_num'], 'fail': summary['fail_cases_num']}\n else:\n summary['dict_report'] = {'result': 1, 'message': 'success', 'pass': summary['pass_cases_num'], 'fail': summary['fail_cases_num']}\n all_summary.append(summary)\n return all_summary"} +{"i": 321, "got": "def add_report_data(list_all, module_name='TestModule', **kwargs):\n \"\"\"pass\"\"\"\n start_at = kwargs.get('start_at')\n case_name = kwargs.get('case_name', 'TestCase')\n raw_case_name = kwargs.get('raw_case_name', 'TestCase')\n exec_date_time = time.localtime(start_at)\n execdate = time.strftime('%Y-%m-%d', exec_date_time)\n exectime = time.strftime('%H:%M:%S', exec_date_time)\n _case_report = {'resp_tester': kwargs.get('resp_tester', 'administrator'), 'tester': kwargs.get('tester', 'administrator'), 'case_name': case_name, 'raw_case_name': raw_case_name, 'status': kwargs.get('status', 'Pass'), 'exec_date': execdate, 'exec_time': exectime, 'start_at': start_at, 'end_at': kwargs.get('end_at')}\n for module in list_all:\n if module_name != module['Name']:\n continue\n for case in module['TestCases']:\n if raw_case_name == case['raw_case_name']:\n case.update(_case_report)\n return list_all\n else:\n module['TestCases'].append(_case_report)\n return list_all\n list_all.append({'Name': module_name, 'TestCases': [_case_report]})\n return list_all"} +{"i": 322, "got": "def get_webpack(request, name='DEFAULT'):\n \"\"\"pass\"\"\"\n if not hasattr(request, '_webpack_map'):\n request._webpack_map = {}\n wp = request._webpack_map.get(name)\n if wp is None:\n wp = request._webpack_map[name] = Webpack(request, name)\n return wp"} +{"i": 323, "got": "def includeme(config):\n \"\"\"pass\"\"\"\n settings = config.registry.settings\n root_package_name = config.root_package.__name__\n config.registry.webpack = {'DEFAULT': WebpackState(settings, root_package_name)}\n for extra_config in aslist(settings.get('webpack.configs', [])):\n state = WebpackState(settings, root_package_name, name=extra_config)\n config.registry.webpack[extra_config] = state\n for state in six.itervalues(config.registry.webpack):\n if state.static_view:\n config.add_static_view(name=state.static_view_name, path=state.static_view_path, cache_max_age=state.cache_max_age)\n config.add_request_method(get_webpack, 'webpack')"} +{"i": 324, "got": "def _get_setting(self, setting, default=None, name=None, inherit=True):\n \"\"\"pass\"\"\"\n if name is None:\n name = self.name\n if name == 'DEFAULT':\n return self._settings.get('webpack.{0}'.format(setting), default)\n val = self._settings.get('webpack.{0}.{1}'.format(name, setting), SENTINEL)\n if val is SENTINEL:\n if inherit:\n return self._get_setting(setting, default, 'DEFAULT')\n else:\n return default\n return val"} +{"i": 325, "got": "def load_stats(self, cache=None, wait=None):\n \"\"\"pass\"\"\"\n if cache is None:\n cache = not self.debug\n if wait is None:\n wait = self.debug\n while not cache or self._stats is None:\n self._stats = self._load_stats()\n start = time.time()\n while wait and self._stats.get('status') == 'compiling':\n if self.timeout and time.time() - start > self.timeout:\n raise RuntimeError('Webpack {0!r} timed out while compiling'.format(self.stats_file.path))\n time.sleep(0.1)\n return self._stats"} +{"i": 326, "got": "def _load_stats(self):\n \"\"\"pass\"\"\"\n for attempt in range(0, 3):\n try:\n with self.stats_file.open() as f:\n return json.load(f)\n except ValueError:\n if attempt < 2:\n time.sleep(attempt * 0.2)\n else:\n raise\n except IOError:\n raise IOError('Could not read stats file {0}. Make sure you are using the webpack-bundle-tracker plugin'.format(self.stats_file))"} +{"i": 327, "got": "def _chunk_filter(self, extensions):\n \"\"\"pass\"\"\"\n if isinstance(extensions, six.string_types):\n extensions = extensions.split()\n\n def _filter(chunk):\n \"\"\"pass\"\"\"\n name = chunk['name']\n if extensions is not None and (not any((name.endswith(e) for e in extensions))):\n return False\n for pattern in self.state.ignore_re:\n if pattern.match(name):\n return False\n for pattern in self.state.ignore:\n if fnmatch.fnmatchcase(name, pattern):\n return False\n return True\n return _filter"} +{"i": 328, "got": "def _unique_names():\n \"\"\"pass\"\"\"\n characters = 'abcdefghijklmnopqrstuvwxyz0123456789'\n characters = [characters[i:i + 1] for i in irange(len(characters))]\n rng = random.Random()\n while True:\n letters = [rng.choice(characters) for i in irange(10)]\n yield ''.join(letters)"} +{"i": 329, "got": "def escape_queue(s):\n \"\"\"pass\"\"\"\n if isinstance(s, PosixPath):\n s = unicode_(s)\n elif isinstance(s, bytes):\n s = s.decode('utf-8')\n if s.startswith('~/'):\n return '~/' + shell_escape(s[2:])\n else:\n return shell_escape(s)"} +{"i": 330, "got": "def parse_ssh_destination(destination):\n \"\"\"pass\"\"\"\n match = _re_ssh.match(destination)\n if not match:\n raise InvalidDestination('Invalid destination: %s' % destination)\n user, password, host, port = match.groups()\n info = {}\n if user:\n info['username'] = user\n else:\n info['username'] = getpass.getuser()\n if password:\n info['password'] = password\n if port:\n info['port'] = int(port)\n info['hostname'] = host\n return info"} +{"i": 331, "got": "def _ssh_client(self):\n \"\"\"pass\"\"\"\n ssh = paramiko.SSHClient()\n ssh.load_system_host_keys()\n ssh.set_missing_host_key_policy(paramiko.RejectPolicy())\n return ssh"} +{"i": 332, "got": "def _connect(self):\n \"\"\"pass\"\"\"\n ssh = self._ssh_client()\n logger.debug('Connecting with %s', ', '.join(('%s=%r' % (k, v if k != 'password' else '***') for k, v in iteritems(self.destination))))\n ssh.connect(**self.destination)\n logger.debug('Connected to %s', self.destination['hostname'])\n self._ssh = ssh"} +{"i": 333, "got": "def get_client(self):\n \"\"\"pass\"\"\"\n if self._ssh is None:\n self._connect()\n return self._ssh\n else:\n try:\n chan = self._ssh.get_transport().open_session()\n except (socket.error, paramiko.SSHException):\n logger.warning('Lost connection, reconnecting...')\n self._ssh.close()\n self._connect()\n finally:\n chan.close()\n return self._ssh"} +{"i": 334, "got": "def activate(lancet, method, project):\n \"\"\"pass\"\"\"\n with taskstatus('Looking up project') as ts:\n if method == 'key':\n func = get_project_keys\n elif method == 'dir':\n func = get_project_keys\n for key, project_path in func(lancet):\n if key.lower() == project.lower():\n break\n else:\n ts.abort('Project \"{}\" not found (using {}-based lookup)', project, method)\n config = load_config(os.path.join(project_path, LOCAL_CONFIG))\n lancet.defer_to_shell('cd', project_path)\n venv = config.get('lancet', 'virtualenv', fallback=None)\n if venv:\n venv_path = os.path.join(project_path, os.path.expanduser(venv))\n activate_script = os.path.join(venv_path, 'bin', 'activate')\n lancet.defer_to_shell('source', activate_script)\n elif 'VIRTUAL_ENV' in os.environ:\n lancet.defer_to_shell('deactivate')"} +{"i": 335, "got": "def workon(ctx, issue_id, new, base_branch):\n \"\"\"pass\"\"\"\n lancet = ctx.obj\n if not (issue_id or new):\n raise click.UsageError('Provide either an issue ID or the --new flag.')\n elif issue_id and new:\n raise click.UsageError('Provide either an issue ID or the --new flag, but not both.')\n summary = click.prompt('Issue summary')\n issue = create_issue(lancet, summary=summary, add_to_active_sprint=True)\n else:\n issue = get_issue(lancet, issue_id)\n username = lancet.tracker.whoami()\n active_status = lancet.config.get('tracker', 'active_status')\n if not base_branch:\n base_branch = lancet.config.get('repository', 'base_branch')\n branch = get_branch(lancet, issue, base_branch)\n transition = get_transition(ctx, lancet, issue, active_status)\n assign_issue(lancet, issue, username, active_status)\n set_issue_status(lancet, issue, active_status, transition)\n with taskstatus('Checking out working branch') as ts:\n lancet.repo.checkout(branch.name)\n ts.ok('Checked out working branch based on \"{}\"'.format(base_branch))\n with taskstatus('Starting harvest timer') as ts:\n lancet.timer.start(issue)\n ts.ok('Started harvest timer')"} +{"i": 336, "got": "def time(lancet, issue):\n \"\"\"pass\"\"\"\n issue = get_issue(lancet, issue)\n with taskstatus('Starting harvest timer') as ts:\n lancet.timer.start(issue)\n ts.ok('Started harvest timer')"} +{"i": 337, "got": "def pause(ctx):\n \"\"\"pass\"\"\"\n lancet = ctx.obj\n paused_status = lancet.config.get('tracker', 'paused_status')\n issue = get_issue(lancet)\n transition = get_transition(ctx, lancet, issue, paused_status)\n set_issue_status(lancet, issue, paused_status, transition)\n with taskstatus('Pausing harvest timer') as ts:\n lancet.timer.pause()\n ts.ok('Harvest timer paused')"} +{"i": 338, "got": "def raisefrom(exc_type, message, exc):\n \"\"\"pass\"\"\"\n if sys.version_info[:2] >= (3, 2):\n six.raise_from(exc_type(message), exc)\n else:\n six.reraise(exc_type, '%s - %s' % (message, exc), sys.exc_info()[2])"} +{"i": 339, "got": "def init_runner(self, parser, tracers, projinfo):\n \"\"\"pass\"\"\"\n self.parser = parser\n self.tracers = tracers\n self.proj_info = projinfo"} +{"i": 340, "got": "def _run_grid_multiprocess(self, func, iterables):\n \"\"\"pass\"\"\"\n multiprocessing.freeze_support()\n pool = multiprocessing.Pool()\n pool_tracers = pool.map(func, iterables)\n pool.close()\n pool.join()\n self.tracers = dict(zip(self._default_devices, pool_tracers))"} +{"i": 341, "got": "def _run_grid_multithread(self, func, iterables):\n \"\"\"pass\"\"\"\n f = lambda x: threading.Thread(target=func, args=(x,))\n threads = map(f, iterables)\n for thread in threads:\n thread.setDaemon(True)\n thread.start()\n thread.join()"} +{"i": 342, "got": "def init_project_env(subject='Automation', proj_path=None, sysencoding='utf-8', debug=False):\n \"\"\"pass\"\"\"\n if not proj_path:\n try:\n executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))\n except:\n executable_file_path = os.path.dirname(sys.path[0])\n proj_path = executable_file_path\n p = os.path.join(proj_path, subject)\n proj_conf = {'sys_coding': sysencoding, 'debug': debug, 'module_name': os.path.splitext(os.path.basename(subject))[0], 'cfg_file': os.path.join(p, 'config.ini'), 'path': {'root': p, 'case': os.path.join(p, 'testcase'), 'data': os.path.join(p, 'data'), 'buffer': os.path.join(p, 'buffer'), 'resource': os.path.join(p, 'resource'), 'tools': os.path.join(p, 'tools'), 'rst': os.path.join(p, 'result'), 'rst_log': os.path.join(p, 'result', 'testcase'), 'rst_shot': os.path.join(p, 'result', 'screenshots')}}\n [FileSystemUtils.mkdirs(v) for v in proj_conf['path'].values()]\n if os.path.isdir(p):\n sys.path.append(p)\n else:\n ''\n return proj_conf"} +{"i": 343, "got": "def get_long_description():\n \"\"\"pass\"\"\"\n here = os.path.abspath(os.path.dirname(__file__))\n with copen(os.path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as description:\n return description.read()"} +{"i": 344, "got": "def flatten(nested_list: list) -> list:\n \"\"\"pass\"\"\"\n return list(sorted(filter(lambda y: y is not None, list(map(lambda x: nested_list.extend(x) if isinstance(x, list) else x, nested_list)))))"} +{"i": 345, "got": "def get_py_files(dir_name: str) -> list:\n \"\"\"pass\"\"\"\n return flatten([['{0}/{1}'.format(path, f) for f in files if f.endswith('.py')] for path, _, files in os.walk(dir_name) if not path.startswith('./build')])"} +{"i": 346, "got": "def exit(self) -> None:\n \"\"\"pass\"\"\"\n total = sum((len(logs) for logs in self.logs.values()))\n if self.json:\n self.logs['total'] = total\n print(json.dumps(self.logs, indent=self.indent))\n else:\n for name, log in self.logs.items():\n if not log or self.parser[name].as_bool('quiet'):\n continue\n print('[[{0}]]'.format(name))\n getattr(snekchek.format, name + '_format')(log)\n print('\\n')\n print('-' * 30)\n print('Total:', total)\n sys.exit(self.status_code)"} +{"i": 347, "got": "def run_linter(self, linter) -> None:\n \"\"\"pass\"\"\"\n self.current = linter.name\n if linter.name not in self.parser['all'].as_list('linters') or linter.base_pyversion > sys.version_info:\n return\n if any((x not in self.installed for x in linter.requires_install)):\n raise ModuleNotInstalled(linter.requires_install)\n linter.add_output_hook(self.out_func)\n linter.set_config(self.fn, self.parser[linter.name])\n linter.run(self.files)\n self.status_code = self.status_code or linter.status_code"} +{"i": 348, "got": "def read_rcfile():\n \"\"\"pass\"\"\"\n files = ['{}/.millipederc'.format(os.environ.get('HOME')), '/usr/local/etc/millipederc', '/etc/millipederc']\n for filepath in files:\n if os.path.isfile(filepath):\n with open(filepath) as rcfile:\n return parse_rcfile(rcfile)\n return {}"} +{"i": 349, "got": "def parse_rcfile(rcfile):\n \"\"\"pass\"\"\"\n\n def parse_bool(value):\n \"\"\"pass\"\"\"\n value = value.lower()\n if value in ('yes', 'true'):\n return True\n elif value in ('no', 'false'):\n return False\n else:\n raise ValueError(\"Can't parse {}\".format(value))\n valid_keys = {'size': int, 'comment': str, 'template': str, 'reverse': parse_bool, 'opposite': parse_bool, 'position': int}\n params = {}\n for linenum, line in enumerate(rcfile):\n line = line.strip()\n if not line or line[0] == '#':\n continue\n pos = line.find(' ')\n key = line[:pos]\n value = line[pos:].strip()\n if key in valid_keys.keys():\n try:\n params[key] = valid_keys[key](value)\n except ValueError:\n print('Ignoring line {} from rcfile'.format(linenum + 1), file=sys.stderr)\n return params"} +{"i": 350, "got": "def compute_settings(args, rc_settings):\n \"\"\"pass\"\"\"\n settings = {}\n for key, value in args.items():\n if key in ['reverse', 'opposite']:\n settings[key] = value ^ rc_settings.get(key, False)\n else:\n settings[key] = value or rc_settings.get(key)\n if not settings['size']:\n settings['size'] = DEFAULT_SIZE\n return settings"} +{"i": 351, "got": "def millipede(size, comment=None, reverse=False, template='default', position=0, opposite=False):\n \"\"\"pass\"\"\"\n padding_offsets = [2, 1, 0, 1, 2, 3, 4, 4, 3]\n padding_suite_length = len(padding_offsets)\n head_padding_extra_offset = 2\n if opposite:\n padding_offsets.reverse()\n position = position or 0\n templates = {'frozen': '\u2554\u2550(\u2744\u2744\u2744)\u2550\u2557', 'love': '\u255a\u2550(\u2744\u2744\u2744)\u2550\u255d', 'corporate': '\u2554\u2299 \u2299\u2557', 'musician': '\u255a\u2299 \u2299\u255d', 'bocal': {'bodyr': '\u2554\u2550(\u2665\u2665\u2665)\u2550\u2557', 'body': '\u255a\u2550(\u2665\u2665\u2665)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'ascii': {'bodyr': '\u2554\u2550(\u00a9\u00a9\u00a9)\u2550\u2557', 'body': '\u255a\u2550(\u00a9\u00a9\u00a9)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'default': {'bodyr': '\u2554\u2550(\u266b\u2669\u266c)\u2550\u2557', 'body': '\u255a\u2550(\u266b\u2669\u266c)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'inception': {'bodyr': '\u2554\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1f\ud83d\udc1f\ud83d\udc1f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'humancentipede': '|=(###)=|', 'heart': {'bodyr': '/\u2299 \u2299\\\\', 'body': '\\\\\u2299 \u2299/', 'headr': '\u2554\u2550(\u2588\u2588\u2588)\u2550\u2557', 'head': '\u255a\u2550(\u2588\u2588\u2588)\u2550\u255d'}, 'corporate': {'bodyr': '\u2554\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\udc1b\ud83d\udc1b\ud83d\udc1b)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'musician': {'bodyr': '\u2554\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u2557', 'body': '\u255a\u2550(\ud83d\ude37\ud83d\ude37\ud83d\ude37)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}, 'bocal': {'bodyr': '\u2554\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u2557', 'body': '\u255a\u2550(\u2764\ufe0f\u2764\ufe0f\u2764\ufe0f)\u2550\u255d', 'headr': '\u2554\u2299 \u2299\u2557', 'head': '\u255a\u2299 \u2299\u255d'}}\n template = templates.get(template, templates['default'])\n head = '{}{}\\n'.format(' ' * (padding_offsets[position % padding_suite_length] + head_padding_extra_offset), template['headr'] if reverse else template['head'])\n body_lines = ['{}{}\\n'.format(' ' * (padding_offsets[x + position] % padding_suite_length), template['bodyr'] if reverse else template['body']) for x in range(size)]\n if reverse:\n body_lines.reverse()\n body = ''.join(body_lines)\n output = ''\n if reverse:\n output += body + head\n if comment:\n output += '\\n' + comment + '\\n'\n elif comment:\n output += comment + '\\n\\n'\n output += head + body\n return output"} +{"i": 352, "got": "def api_post(message, url, name, http_data=None, auth=None):\n \"\"\"pass\"\"\"\n try:\n import requests\n except ImportError:\n print('requests is required to do api post.', file=sys.stderr)\n sys.exit(1)\n data = {name: message}\n if http_data:\n for var in http_data:\n key, value = var.split('=')\n data[key] = value\n response = requests.post(url, data=data, auth=auth)\n if response.status_code != 200:\n raise RuntimeError('Unable to post data')"} +{"i": 353, "got": "def run_main(args: argparse.Namespace, do_exit=True) -> None:\n \"\"\"pass\"\"\"\n if args.init:\n generate()\n return\n handler = CheckHandler(file=args.config_file, out_json=args.json, files=args.files)\n for style in get_stylers():\n handler.run_linter(style())\n for linter in get_linters():\n handler.run_linter(linter())\n for security in get_security():\n handler.run_linter(security())\n for tool in get_tools():\n tool = tool()\n if tool.name == 'pypi' and handler.status_code != 0:\n continue\n handler.run_linter(tool)\n if do_exit:\n handler.exit()\n return handler.status_code"} +{"i": 354, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n parser = argparse.ArgumentParser()\n parser.add_argument('--json', help='output in JSON format', action='store_true', default=False)\n parser.add_argument('--config-file', help='Select config file to use', default='.snekrc')\n parser.add_argument('files', metavar='file', nargs='*', default=[], help='Files to run checks against')\n parser.add_argument('--init', help='generate snekrc', action='store_true', default=False)\n args = parser.parse_args()\n run_main(args)"} +{"i": 355, "got": "def get_session(user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs):\n \"\"\"pass\"\"\"\n s = requests.Session()\n ua = kwargs.get('full_agent')\n if not ua:\n ua = UserAgent.get(user_agent, user_agent_config_yaml, user_agent_lookup, **kwargs)\n s.headers['User-Agent'] = ua\n extra_params = os.getenv('EXTRA_PARAMS')\n if extra_params is not None:\n extra_params_dict = dict()\n if '=' in extra_params:\n logger.info('Loading extra parameters from environment variable')\n for extra_param in extra_params.split(','):\n key, value = extra_param.split('=')\n extra_params_dict[key] = value\n else:\n extra_params_found = False\n extra_params_dict = kwargs.get('extra_params_dict')\n if extra_params_dict:\n extra_params_found = True\n logger.info('Loading extra parameters from dictionary')\n extra_params_json = kwargs.get('extra_params_json', '')\n if extra_params_json:\n if extra_params_found:\n raise SessionError('More than one set of extra parameters given!')\n extra_params_found = True\n logger.info('Loading extra parameters from: %s' % extra_params_json)\n extra_params_dict = load_json(extra_params_json)\n extra_params_yaml = kwargs.get('extra_params_yaml', '')\n if extra_params_found:\n if extra_params_yaml:\n raise SessionError('More than one set of extra parameters given!')\n else:\n if extra_params_yaml:\n logger.info('Loading extra parameters from: %s' % extra_params_yaml)\n extra_params_dict = load_yaml(extra_params_yaml)\n else:\n extra_params_dict = dict()\n extra_params_lookup = kwargs.get('extra_params_lookup')\n if extra_params_lookup:\n extra_params_dict = extra_params_dict.get(extra_params_lookup)\n if extra_params_dict is None:\n raise SessionError('%s does not exist in extra_params!' % extra_params_lookup)\n auth_found = False\n basic_auth = os.getenv('BASIC_AUTH')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth environment variable')\n auth_found = True\n else:\n basic_auth = kwargs.get('basic_auth')\n if basic_auth:\n logger.info('Loading authorisation from basic_auth argument')\n auth_found = True\n bauth = extra_params_dict.get('basic_auth')\n if bauth:\n if not auth_found:\n basic_auth = bauth\n logger.info('Loading authorisation from basic_auth parameter')\n auth_found = True\n del extra_params_dict['basic_auth']\n s.params = extra_params_dict\n auth = kwargs.get('auth')\n if auth:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from auth argument')\n auth_found = True\n basic_auth_file = kwargs.get('basic_auth_file')\n if basic_auth_file:\n if auth_found:\n raise SessionError('More than one authorisation given!')\n logger.info('Loading authorisation from: %s' % basic_auth_file)\n basic_auth = load_file_to_str(basic_auth_file)\n if basic_auth:\n auth = decode(basic_auth)\n s.auth = auth\n status_forcelist = kwargs.get('status_forcelist', [429, 500, 502, 503, 504])\n method_whitelist = kwargs.get('method_whitelist', frozenset(['HEAD', 'TRACE', 'GET', 'PUT', 'OPTIONS', 'DELETE']))\n retries = Retry(total=5, backoff_factor=0.4, status_forcelist=status_forcelist, method_whitelist=method_whitelist, raise_on_redirect=True, raise_on_status=True)\n s.mount('http://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n s.mount('https://', HTTPAdapter(retries, max_retries=100, pool_connections=100))\n return s"} +{"i": 356, "got": "def connect(self):\n \"\"\"pass\"\"\"\n if self.connection_type.lower() == 'ssl':\n self.server = smtplib.SMTP_SSL(host=self.host, port=self.port, local_hostname=self.local_hostname, timeout=self.timeout, source_address=self.source_address)\n elif self.connection_type.lower() == 'lmtp':\n self.server = smtplib.LMTP(host=self.host, port=self.port, local_hostname=self.local_hostname, source_address=self.source_address)\n else:\n self.server = smtplib.SMTP(host=self.host, port=self.port, local_hostname=self.local_hostname, timeout=self.timeout, source_address=self.source_address)\n self.server.login(self.username, self.password)"} +{"i": 357, "got": "def send(self, recipients, subject, text_body, html_body=None, sender=None, **kwargs):\n \"\"\"pass\"\"\"\n if sender is None:\n sender = self.sender\n v = validate_email(sender, check_deliverability=False)\n sender = v['email']\n normalised_recipients = list()\n for recipient in recipients:\n v = validate_email(recipient, check_deliverability=True)\n normalised_recipients.append(v['email'])\n if html_body is not None:\n msg = MIMEMultipart('alternative')\n part1 = MIMEText(text_body, 'plain')\n part2 = MIMEText(html_body, 'html')\n msg.attach(part1)\n msg.attach(part2)\n else:\n msg = MIMEText(text_body)\n msg['Subject'] = subject\n msg['From'] = sender\n msg['To'] = ', '.join(normalised_recipients)\n self.connect()\n self.server.sendmail(sender, normalised_recipients, msg.as_string(), **kwargs)\n self.close()"} +{"i": 358, "got": "def get_session(db_url):\n \"\"\"pass\"\"\"\n engine = create_engine(db_url, poolclass=NullPool, echo=False)\n Session = sessionmaker(bind=engine)\n Base.metadata.create_all(engine)\n return Session()"} +{"i": 359, "got": "def get_params_from_sqlalchemy_url(db_url):\n \"\"\"pass\"\"\"\n result = urlsplit(db_url)\n return {'database': result.path[1:], 'host': result.hostname, 'port': result.port, 'username': result.username, 'password': result.password, 'driver': result.scheme}"} +{"i": 360, "got": "def get_unset_cache(self):\n \"\"\"pass\"\"\"\n caches = []\n if self._cached_api_global_response is None:\n caches.append('global')\n if self._cached_api_ticker_response is None:\n caches.append('ticker')\n return (len(caches), caches)"} +{"i": 361, "got": "def dicts_filter(dicts_object, field_to_filter, value_of_filter):\n \"\"\"pass\"\"\"\n lambda_query = lambda value: value[field_to_filter] == value_of_filter\n filtered_coin = filter(lambda_query, dicts_object)\n selected_coins = list(filtered_coin)\n return selected_coins"} +{"i": 362, "got": "def send_request(self, endpoint='ticker', coin_name=None, **kwargs):\n \"\"\"pass\"\"\"\n built_url = self._make_url(endpoint, coin_name)\n payload = dict(**kwargs)\n self._process_request(endpoint, built_url, payload)"} +{"i": 363, "got": "def get_response(self, data_type=None):\n \"\"\"pass\"\"\"\n if not data_type:\n return self.cache.get_response(r_type='ticker') or self.cache.get_response(r_type='global')\n elif data_type == 'ticker':\n return self.cache.get_response(r_type='ticker')\n else:\n return self.cache.get_response(r_type='global')"} +{"i": 364, "got": "def iso_639_alpha3(code):\n \"\"\"pass\"\"\"\n code = normalize_code(code)\n code = ISO3_MAP.get(code, code)\n if code in ISO3_ALL:\n return code\n else:\n return None"} +{"i": 365, "got": "def list_to_alpha3(languages, synonyms=True):\n \"\"\"pass\"\"\"\n codes = set([])\n for language in ensure_list(languages):\n code = iso_639_alpha3(language)\n if code is not None:\n codes.add(code)\n if synonyms:\n codes.update(expand_synonyms(code))\n return codes"} +{"i": 366, "got": "def _search_generator(self, item: Any, reverse: bool=False) -> Generator[Any, None, None]:\n \"\"\"pass\"\"\"\n results = 0\n for _, x in self.enumerate(item, reverse=reverse):\n yield x\n results += 1\n if results == 0:\n raise SearchError(str(item))"} +{"i": 367, "got": "def _search_generator(self, item: Any) -> Generator[Any, None, None]:\n \"\"\"pass\"\"\"\n results = 0\n for x in self.enumerate(item):\n yield x\n results += 1\n if results == 0:\n raise SearchError(str(item))"} +{"i": 368, "got": "def _search_generator(self, item: Any) -> Generator[Tuple[Any, Any], None, None]:\n \"\"\"pass\"\"\"\n results = 0\n for key, value in self.enumerate(item):\n yield (key, value)\n results += 1\n if results == 0:\n raise SearchError(str(item))"} +{"i": 369, "got": "def serialize(obj):\n \"\"\"pass\"\"\"\n from datetime import datetime, date, time\n if isinstance(obj, date) and (not isinstance(obj, datetime)):\n obj = datetime.combine(obj, time.min)\n if isinstance(obj, datetime):\n return obj.isoformat()"} +{"i": 370, "got": "def check(response, expected_status=200, url=None):\n \"\"\"pass\"\"\"\n if response.status_code != expected_status:\n if url is None:\n url = response.url\n try:\n err = response.json()\n except:\n err = {}\n if all((x in err for x in ('status', 'message', 'description', 'details'))):\n raise _APIError(err['status'], err['message'], url, err, err['description'], err['details'])\n suffix = '.html' if ' 200:\n with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as f:\n f.write(response.text.encode('utf-8'))\n msg = '{}...\\n\\n[snipped; full response written to {f.name}'.format(*msg[:100], **locals())\n msg = 'Request {url!r} returned code {response.status_code}, expected {expected_status}. \\n{msg}'.format(**locals())\n raise _APIError(response.status_code, msg, url, response.text)\n if response.headers.get('Content-Type') == 'application/json':\n try:\n return response.json()\n except:\n raise Exception('Cannot decode json; text={response.text!r}'.format(**locals()))\n else:\n return response.text"} +{"i": 371, "got": "def _get_auth(self, user=None, password=None):\n \"\"\"pass\"\"\"\n fn = os.path.expanduser(AUTH_FILE)\n if os.path.exists(fn):\n for i, line in enumerate(csv.reader(open(fn))):\n if len(line) != 3:\n log.warning('Cannot parse line {i} in {fn}'.format(**locals()))\n continue\n hostname, username, pwd = line\n if hostname in ('', '*', self.host) and (user is None or username == user):\n return (username, pwd)\n if user is None:\n user = os.environ.get('AMCAT_USER', os.environ.get('USER'))\n if password is None:\n password = os.environ.get('AMCAT_PASSWORD')\n if user is None or password is None:\n raise Exception('No authentication info for {user}@{self.host} from {fn} or AMCAT_USER / AMCAT_PASSWORD variables'.format(**locals()))\n return (user, password)"} +{"i": 372, "got": "def request(self, url, method='get', format=None, data=None, expected_status=None, headers=None, use_xpost=True, **options):\n \"\"\"pass\"\"\"\n if expected_status is None:\n if method == 'get':\n expected_status = 200\n elif method == 'post':\n expected_status = 201\n else:\n raise ValueError('No expected status supplied and method unknown.')\n if not url.startswith('http'):\n url = '{self.host}/api/v4/{url}'.format(**locals())\n if format is not None:\n options = dict({'format': format}, **options)\n options = {field: value for field, value in options.items() if value is not None}\n headers = dict(headers or {}, Authorization='Token {}'.format(self.token))\n if method == 'get' and use_xpost:\n assert data is None\n headers.update({'X-HTTP-METHOD-OVERRIDE': method})\n data = options\n options = None\n method = 'post'\n r = requests.request(method, url, data=data, params=options, headers=headers)\n log.debug('HTTP {method} {url} (options={options!r}, data={data!r},headers={headers}) -> {r.status_code}'.format(**locals()))\n return check(r, expected_status=expected_status)"} +{"i": 373, "got": "def get_pages(self, url, page=1, page_size=100, yield_pages=False, **filters):\n \"\"\"pass\"\"\"\n n = 0\n for page in itertools.count(page):\n r = self.request(url, page=page, page_size=page_size, **filters)\n n += len(r['results'])\n log.debug('Got {url} page {page} / {pages}'.format(url=url, **r))\n if yield_pages:\n yield r\n else:\n for row in r['results']:\n yield row\n if r['next'] is None:\n break"} +{"i": 374, "got": "def get_scroll(self, url, page_size=100, yield_pages=False, **filters):\n \"\"\"pass\"\"\"\n n = 0\n options = dict(page_size=page_size, **filters)\n format = filters.get('format')\n while True:\n r = self.request(url, use_xpost=False, **options)\n n += len(r['results'])\n log.debug('Got {} {n}/{total}'.format((url.split('?')[0],), total=r['total'], **locals()))\n if yield_pages:\n yield r\n else:\n for row in r['results']:\n yield row\n if r['next'] is None:\n break\n url = r['next']\n options = {'format': None}"} +{"i": 375, "got": "def get_error(self, block=True, timeout=None):\n \"\"\"pass\"\"\"\n return self._error_queue.get(block=block, timeout=timeout)"} +{"i": 376, "got": "def get_feedback(self, block=True, timeout=None):\n \"\"\"pass\"\"\"\n if self._feedback_greenlet is None:\n self._feedback_greenlet = gevent.spawn(self._feedback_loop)\n return self._feedback_queue.get(block=block, timeout=timeout)"} +{"i": 377, "got": "def wait_send(self, timeout=None):\n \"\"\"pass\"\"\"\n self._send_queue_cleared.clear()\n self._send_queue_cleared.wait(timeout=timeout)"} +{"i": 378, "got": "def start(self):\n \"\"\"pass\"\"\"\n if self._send_greenlet is None:\n self._send_greenlet = gevent.spawn(self._send_loop)"} +{"i": 379, "got": "def stop(self, timeout=10.0):\n \"\"\"pass\"\"\"\n if self._send_greenlet is not None and self._send_queue.qsize() > 0:\n self.wait_send(timeout=timeout)\n if self._send_greenlet is not None:\n gevent.kill(self._send_greenlet)\n self._send_greenlet = None\n if self._error_greenlet is not None:\n gevent.kill(self._error_greenlet)\n self._error_greenlet = None\n if self._feedback_greenlet is not None:\n gevent.kill(self._feedback_greenlet)\n self._feedback_greenlet = None\n return self._send_queue.qsize() < 1"} +{"i": 380, "got": "def convert_to_ssml(text, text_format):\n \"\"\"pass\"\"\"\n if text_format is None:\n return text\n elif text_format == 'plain':\n return plain_to_ssml(text)\n elif text_format == 'html':\n return html_to_ssml(text)\n else:\n raise ValueError(text_format + ': text format not found.')"} +{"i": 381, "got": "def html_to_ssml(text):\n \"\"\"pass\"\"\"\n ssml_text = reduce(lambda x, y: x.replace(y, html_to_ssml_maps[y]), html_to_ssml_maps, text)\n return ssml_text"} +{"i": 382, "got": "def iexpand(string, keep_escapes=False):\n \"\"\"pass\"\"\"\n if isinstance(string, bytes):\n is_bytes = True\n string = string.decode('latin-1')\n else:\n is_bytes = False\n if is_bytes:\n return (entry.encode('latin-1') for entry in ExpandBrace(keep_escapes).expand(string))\n else:\n return (entry for entry in ExpandBrace(keep_escapes).expand(string))"} +{"i": 383, "got": "def set_expanding(self):\n \"\"\"pass\"\"\"\n status = not self.expanding\n if status:\n self.expanding = True\n return status"} +{"i": 384, "got": "def get_escape(self, c, i):\n \"\"\"pass\"\"\"\n try:\n escaped = next(i)\n except StopIteration:\n escaped = ''\n if self.keep_escapes:\n return c + escaped\n else:\n return escaped"} +{"i": 385, "got": "def squash(self, a, b):\n \"\"\"pass\"\"\"\n return (u''.join(x) if isinstance(x, tuple) else x for x in itertools.product(a, b))"} +{"i": 386, "got": "def get_literals(self, c, i, depth):\n \"\"\"pass\"\"\"\n result = ['']\n is_dollar = False\n while c:\n ignore_brace = is_dollar\n is_dollar = False\n if c == '$':\n is_dollar = True\n elif c == '\\\\':\n c = [self.get_escape(c, i)]\n else:\n if not ignore_brace and c == '{':\n index = i.index\n try:\n seq = self.get_sequence(next(i), i, depth + 1)\n if seq:\n c = seq\n except StopIteration:\n i.rewind(i.index - index)\n if not is_dollar and self.is_expanding() and (c in [',', '}']):\n i.rewind(1)\n return ((x for x in result),)\n else:\n result = self.squash(result, [c] if isinstance(c, str) else c)\n c = next(i)\n return ((x for x in result),)"} +{"i": 387, "got": "def combine(self, a, b):\n \"\"\"pass\"\"\"\n for l in [a, b]:\n for x in l:\n yield x"} +{"i": 388, "got": "def add_episode(self, text, text_format, title=None, author=None, summary='watson', publish_date=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if title in self.episodes:\n raise ValueError('\"' + title + '\" already exists as an episode title.')\n link = self.output_path + '/' + title.replace(' ', '_').lower() + '.mp3'\n episode_text = convert_to_ssml(text, text_format)\n new_episode = Episode(episode_text, text_format, title, author, link, summary, publish_date, synthesizer, synth_args, sentence_break)\n self.episodes[title] = new_episode"} +{"i": 389, "got": "def add_scheduled_job(self, text_source, cron_args, text_format, title=None, author='watson', summary=None, synthesizer='. ', synth_args=None, sentence_break=' '):\n \"\"\"pass\"\"\"\n if not callable(text_source):\n raise TypeError('Argument \"text\" must be a function')\n\n def add_episode():\n episode_text = text_source()\n episode_title = title + '_' + datetime.utcnow().strftime('%Y%m%d%H%M%S')\n self.add_episode(episode_text, text_format, episode_title, author, summary, datetime.utcnow(), synthesizer, synth_args, sentence_break)\n self._scheduler.add_job(add_episode, 'cron', id=title, **cron_args)[self.scheduled_jobs[title]]\n if not self._scheduler.running:\n self._scheduler.start()"} +{"i": 390, "got": "def publish(self, titles):\n \"\"\"pass\"\"\"\n if isinstance(titles, Sequence) and (not isinstance(titles, six.string_types)):\n for title in titles:\n self.episodes[title].publish()\n elif isinstance(titles, six.string_types):\n self.episodes[titles].publish()\n else:\n raise TypeError('titles must be a string or a sequence of strings.')\n self.update_rss_feed()"} +{"i": 391, "got": "def render_audio(self):\n \"\"\"pass\"\"\"\n segment = text_to_speech(self._text, self.synthesizer, self.synth_args, self.sentence_break)\n milli = len(segment)\n seconds = '{0:.1f}'.format(float(milli) / 1000 % 60).zfill(2)\n minutes = '{0:.0f}'.format(milli / 60000 % 60).zfill(2)\n hours = '{0:.0f}'.format(milli / (3600 * 1000) % 24).zfill(2)\n self.duration = hours + ':' + minutes + ':' + seconds\n segment.export(self.link, format='mp3')\n self.length = os.path.getsize(self.link)"} +{"i": 392, "got": "def remove_exponent(d):\n \"\"\"pass\"\"\"\n if d == d.to_integral():\n return d.quantize(Decimal(1))\n else:\n return d.normalize()"} +{"i": 393, "got": "def millify(n, precision=0, drop_nulls=True, prefixes=[]):\n \"\"\"pass\"\"\"\n millnames = ['', 'k', 'M', 'B', 'T', 'P', 'E', 'Z', 'Y']\n if prefixes:\n millnames = ['']\n millnames.extend(prefixes)\n n = float(n)\n millidx = max(0, min(len(millnames) - 1, int(math.floor(0 if n == 0 else math.log10(abs(n)) / 3))))\n result = '{:.{precision}f}'.format(n / 10 ** (3 * millidx), precision=precision)\n if drop_nulls:\n result = remove_exponent(Decimal(result))\n return '{0}{dx}'.format(result, dx=millnames[millidx])"} +{"i": 394, "got": "def prettify(amount, separator=','):\n \"\"\"pass\"\"\"\n orig = str(amount)\n new = re.sub('^(-?\\\\d+)(\\\\d{3})', '\\\\g<1>{0}\\\\g<2>'.format(separator), str(amount))\n if orig == new:\n return new\n else:\n return prettify(new)"} +{"i": 395, "got": "def load_json(json_data, decoder=None):\n \"\"\"pass\"\"\"\n if decoder is None:\n decoder = DateTimeDecoder\n return json.loads(json_data, object_hook=decoder.decode)"} +{"i": 396, "got": "def load_json_file(file, decoder=None):\n \"\"\"pass\"\"\"\n if decoder is None:\n decoder = DateTimeDecoder\n if not hasattr(file, 'read'):\n with io.open(file, 'r', encoding='utf-8') as f:\n return json.load(f, object_hook=decoder.decode)\n else:\n return json.load(file, object_hook=decoder.decode)"} +{"i": 397, "got": "def save_json(val, pretty=False, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n return data"} +{"i": 398, "got": "def save_json_file(file, val, pretty=False, compact=True, sort=True, encoder=None):\n \"\"\"pass\"\"\"\n if encoder is None:\n encoder = DateTimeEncoder\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n if pretty:\n data = json.dumps(val, indent=4, separators=(',', ': '), sort_keys=sort, cls=encoder)\n elif compact:\n data = json.dumps(val, separators=(',', ':'), sort_keys=sort, cls=encoder)\n else:\n data = json.dumps(val, sort_keys=sort, cls=encoder)\n finally:\n if not opened:\n file.close()\n if not sys.version_info > (3, 0) and isinstance(data, str):\n data = data.decode('utf-8')\n file.write(data)"} +{"i": 399, "got": "def load_yaml_file(file):\n \"\"\"pass\"\"\"\n if not hasattr(file, 'read'):\n with io.open(file, 'r', encoding='utf-8') as f:\n return yaml.load(f, yaml.FullLoader)\n else:\n return yaml.load(file, yaml.FullLoader)"} +{"i": 400, "got": "def save_yaml_file(file, val):\n \"\"\"pass\"\"\"\n opened = False\n if not hasattr(file, 'write'):\n file = io.open(file, 'w', encoding='utf-8')\n opened = True\n try:\n yaml.dump(val, file)\n finally:\n if opened:\n file.close()"} +{"i": 401, "got": "def get_embedded_yara(self, iocid):\n \"\"\"pass\"\"\"\n ioc_obj = self.iocs[iocid]\n ids_to_process = set([])\n signatures = ''\n for elem in ioc_obj.top_level_indicator.xpath('.//IndicatorItem[Context/@search = \"Yara/Yara\"]'):\n signature = elem.findtext('Content')\n signatures = signatures + '\\n' + signature\n if signatures:\n signatures += '\\n'\n return signatures"} +{"i": 402, "got": "def get_yara_condition_string(self, indicator_node, parameters_node, ids_to_process, condition_string='', joining_value='or'):\n \"\"\"pass\"\"\"\n indicator_node_id = str(indicator_node.get('id'))\n if indicator_node_id not in ids_to_process:\n msg = 'Entered into get_yara_condition_string with a invalid node to walk [[}]'.format(indicator_node_id)\n raise YaraConversionError(msg)\n expected_tag = 'Indicator'\n if indicator_node.tag != expected_tag:\n raise YaraConversionError('indicator_node expected tag is [%s]' % expected_tag)\n is_set = None\n for param in parameters_node.xpath('.//param[@ref-id=\"{}\"]'.format(indicator_node_id)):\n if param.attrib['name'] == 'yara/set':\n is_set = True\n set_count = param.findtext('value', None)\n try:\n temp = int(set_count)\n if temp < 1:\n raise YaraConversionError('yara/set parameter value was less than 1')\n if temp > len(indicator_node.getchildren()):\n msg = 'yara/set value is greater than the number of children of Indicator node [%s]' % str(indicator_node_id)\n raise YaraConversionError(msg)\n except ValueError:\n raise YaraConversionError('yara/set parameter was not a integer')\n set_dict = {'set_count': set_count, 'set_ids': []}\n for node in indicator_node.getchildren():\n node_id = node.get('id')\n safe_node_id = node_id.replace('-', '')\n if node_id not in ids_to_process:\n continue\n if node.tag == 'IndicatorItem':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, joining_value, recursed_condition])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping = {'prefix': '#', 'identifier': '', 'condition': ' ', 'postfix': ''}\n use_condition_template = False\n negation = node.get('negate')\n condition = node.get('condition')\n search = node.xpath('Context/@search')[0]\n content = node.findtext('Content')\n yara_condition = self.condition_to_yara_map[condition]\n if not yara_condition:\n msg = 'Invalid IndicatorItem condition encountered [%s][%s]' % (str(node_id), str(condition))\n raise YaraConversionError(msg)\n if negation.lower() == 'true':\n negation = True\n else:\n negation = False\n if search == 'Yara/FileSize':\n mapping['prefix'] = ''\n mapping['identifier'] = 'filesize'\n mapping['postfix'] = ' ' + content\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif search == 'Yara/RuleName':\n if content not in self.ioc_names_set:\n if mangle_name(content) in self.ioc_names_mangled_set:\n msg = 'Yara/RuleName is present as a mangled name.[{}][{}]'.format(mangle_name(content), node_id)\n log.warning(msg)\n content = mangle_name(content)\n else:\n log.warning('Yara/RuleName points to a name [{}] that is not in the set of IOCs being processed [{}]'.format(content, node_id))\n if mangle_name(content) != content:\n msg = 'Yara/RuleName contains characters which would cause libyara errors [{}]' % node_id\n raise YaraConversionError(msg)\n mapping['prefix'] = ''\n mapping['identifier'] = content\n else:\n xp = './/param[@ref-id=\"{}\" and (@name=\"yara/count\" or @name=\"yara/offset/at\" or @name=\"yara/offset/in\")]'.format(node_id)\n params = parameters_node.xpath(xp)\n if len(params) > 1:\n msg = 'More than one condition parameters assigned to IndicatorItem [{}]'.format(node_id)\n raise YaraConversionError(msg)\n for param in params:\n param_name = param.get('name', None)\n if param_name == 'yara/count':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['prefix'] = '#'\n mapping['postfix'] = ' ' + param.findtext('value')\n mapping['condition'] = yara_condition\n use_condition_template = True\n elif param_name == 'yara/offset/at':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'at'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n elif param_name == 'yara/offset/in':\n log.debug('Found [%s] attached to [%s]' % (param.attrib['name'], node_id))\n mapping['condition'] = 'in'\n mapping['postfix'] = ' ' + param.findtext('value')\n use_condition_template = True\n if use_condition_template:\n temp_string = self.yara_II_condition_template % mapping\n else:\n temp_string = self.yara_II_template % mapping\n if condition_string == '':\n condition_string = temp_string\n else:\n condition_string = ' '.join([condition_string, joining_value, temp_string])\n elif node.tag == 'Indicator':\n if is_set:\n raise YaraConversionError('Cannot have Indicator nodes underneath a Indicator node with yara/set')\n operator = node.get('operator').lower()\n if operator not in ('or', 'and'):\n raise YaraConversionError('Indicator@operator is not and/or. [%s] has [%s]' % (id, operator))\n recursed_condition = self.get_yara_condition_string(node, parameters_node, ids_to_process, '', operator)\n xp = './/param[@ref-id=\"{}\" and @name=\"yara/set\"]'.format(node_id)\n if not parameters_node.xpath(xp) and has_siblings(node):\n recursed_condition = '(%s)' % recursed_condition\n if condition_string == '':\n condition_string = recursed_condition\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n if is_set:\n log.debug('Building set expression for [%s]' % indicator_node_id)\n if len(set_dict['set_ids']) == 0:\n raise YaraConversionError('yara/set processing did not yield any set ids')\n elif len(set_dict['set_ids']) == 1:\n log.warning('yara/set with 1 id found for node [%s]' % node_id)\n set_ids = ''.join(set_dict['set_ids'])\n else:\n set_ids = ','.join(set_dict['set_ids'])\n mapping['set_ids'] = set_ids\n temp_set_string = self.yara_set_string_template % set_dict\n if condition_string == '':\n condition_string = temp_set_string\n else:\n condition_string = ' '.join([condition_string, indicator_node.getparent().get('operator').lower(), temp_set_string])\n return condition_string"} +{"i": 403, "got": "def write_yara(self, output_file):\n \"\"\"pass\"\"\"\n fout = open(output_file, 'wb')\n fout.write('\\n')\n for iocid in self.yara_signatures:\n signature = self.yara_signatures[iocid]\n fout.write(signature)\n fout.write('\\n')\n fout.close()\n return True"} +{"i": 404, "got": "def safe_makedirs(fdir):\n \"\"\"pass\"\"\"\n if os.path.isdir(fdir):\n return True\n else:\n try:\n os.makedirs(fdir)\n except WindowsError as e:\n if 'Cannot create a file when that file already exists' in e:\n log.debug('relevant dir already exists')\n else:\n raise WindowsError(e)\n return True"} +{"i": 405, "got": "def convert_to_10(self):\n \"\"\"pass\"\"\"\n if len(self) < 1:\n log.error('no iocs available to modify')\n return False\n log.info('Converting IOCs from 1.1 to 1.0.')\n errors = []\n for iocid in self.iocs:\n pruned = False\n ioc_obj_11 = self.iocs[iocid]\n metadata = ioc_obj_11.metadata\n name_11 = metadata.findtext('.//short_description')\n keywords_11 = metadata.findtext('.//keywords')\n description_11 = metadata.findtext('.//description')\n author_11 = metadata.findtext('.//authored_by')\n created_date_11 = metadata.findtext('.//authored_date')\n last_modified_date_11 = ioc_obj_11.root.get('last-modified')\n links_11 = []\n for link in metadata.xpath('//link'):\n link_rel = link.get('rel')\n link_text = link.text\n links_11.append((link_rel, None, link_text))\n try:\n ioc_logic = ioc_obj_11.root.xpath('.//criteria')[0]\n except IndexError:\n log.exception('Could not find criteria nodes for IOC [{}]. Did you attempt to convert OpenIOC 1.0 iocs?'.format(iocid))\n errors.append(iocid)\n continue\n try:\n tlo_11 = ioc_logic.getchildren()[0]\n except IndexError:\n log.exception('Could not find children for the top level criteria/children nodes for IOC [{}]' .format(iocid))\n errors.append(iocid)\n continue\n tlo_id = tlo_11.get('id')\n comment_dict = {}\n for param in ioc_obj_11.parameters.xpath('//param[@name=\"comment\"]'):\n param_id = param.get('ref-id')\n param_text = param.findtext('value')\n comment_dict[param_id] = param_text\n ioc_obj_10 = ioc_api.IOC(name=name_11, description=description_11, author=author_11, links=links_11, keywords=keywords_11, iocid=iocid)\n ioc_obj_10.root.attrib['last-modified'] = last_modified_date_11\n authored_date_node = ioc_obj_10.metadata.find('authored_date')\n authored_date_node.text = created_date_11\n ioc_obj_10.root.attrib['xmlns'] = 'http://schemas.mandiant.com/2010/ioc'\n del ioc_obj_10.root.attrib['published-date']\n ioc_obj_10.root.remove(ioc_obj_10.parameters)\n ioc_obj_10.root.tag = 'ioc'\n metadata_node = ioc_obj_10.metadata\n criteria_node = ioc_obj_10.top_level_indicator.getparent()\n metadata_dictionary = {}\n for child in metadata_node:\n metadata_dictionary[child.tag] = child\n for tag in METADATA_REQUIRED_10:\n if tag not in metadata_dictionary:\n msg = 'IOC {} is missing required metadata: [{}]'.format(iocid, tag)\n raise DowngradeError(msg)\n for tag in METADATA_ORDER_10:\n if tag in metadata_dictionary:\n ioc_obj_10.root.append(metadata_dictionary.get(tag))\n ioc_obj_10.root.remove(metadata_node)\n ioc_obj_10.root.remove(criteria_node)\n criteria_node.tag = 'definition'\n ioc_obj_10.root.append(criteria_node)\n ioc_obj_10.top_level_indicator.attrib['id'] = tlo_id\n ids_to_skip = set()\n indicatoritems_to_remove = set()\n for condition_type in self.openioc_11_only_conditions:\n for elem in ioc_logic.xpath('//IndicatorItem[@condition=\"%s\"]' % condition_type):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in ioc_logic.xpath('//IndicatorItem[@preserve-case=\"true\"]'):\n pruned = True\n indicatoritems_to_remove.add(elem)\n for elem in indicatoritems_to_remove:\n nid = None\n current = elem\n if nid != tlo_id:\n parent = current.getparent()\n nid = parent.get('id')\n if nid == tlo_id:\n current_id = current.get('id')\n ids_to_skip.add(current_id)\n else:\n current = parent\n try:\n self.convert_branch(tlo_11, ioc_obj_10.top_level_indicator, ids_to_skip, comment_dict)\n except DowngradeError:\n log.exception('Problem converting IOC [{}]'.format(iocid))\n errors.append(iocid)\n continue\n if not ioc_obj_10.top_level_indicator.getchildren():\n self.null_pruned_iocs.add(iocid)\n elif pruned is True:\n self.pruned_11_iocs.add(iocid)\n self.iocs_10[iocid] = ioc_obj_10\n return errors"} +{"i": 406, "got": "def convert_branch(self, old_node, new_node, ids_to_skip, comment_dict=None):\n \"\"\"pass\"\"\"\n expected_tag = 'Indicator'\n if old_node.tag != expected_tag:\n raise DowngradeError('old_node expected tag is [%s]' % expected_tag)\n if not comment_dict:\n comment_dict = {}\n for node in old_node.getchildren():\n node_id = node.get('id')\n if node_id in ids_to_skip:\n continue\n if node.tag == 'IndicatorItem':\n negation = node.get('negate')\n condition = node.get('condition')\n if 'true' in negation.lower():\n new_condition = condition + 'not'\n else:\n new_condition = condition\n document = node.xpath('Context/@document')[0]\n search = node.xpath('Context/@search')[0]\n content_type = node.xpath('Content/@type')[0]\n content = node.findtext('Content')\n context_type = node.xpath('Context/@type')[0]\n new_ii_node = ioc_api.make_indicatoritem_node(condition=condition, document=document, search=search, content_type=content_type, content=content, context_type=context_type, nid=node_id)\n new_ii_node.attrib['condition'] = new_condition\n if node_id in comment_dict:\n comment = comment_dict[node_id]\n comment_node = et.Element('Comment')\n comment_node.text = comment\n new_ii_node.append(comment_node)\n del new_ii_node.attrib['negate']\n del new_ii_node.attrib['preserve-case']\n new_node.append(new_ii_node)\n elif node.tag == 'Indicator':\n operator = node.get('operator')\n if operator.upper() not in ('OR', 'AND'):\n raise DowngradeError('Indicator@operator is not AND/OR. [%s] has [%s]' % (node_id, operator))\n new_i_node = ioc_api.make_indicator_node(operator, node_id)\n new_node.append(new_i_node)\n self.convert_branch(node, new_i_node, ids_to_skip, comment_dict)\n else:\n raise DowngradeError('node is not a Indicator/IndicatorItem')\n return True"} +{"i": 407, "got": "def create(self, permission):\n \"\"\"pass\"\"\"\n parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', 'single', {'id': self.parent_object.id})\n target_url = parent_url + self.client.get_url_path(self._URL_KEY, 'POST', 'single')\n r = self.client.request('POST', target_url, json=permission._serialize())\n return permission._deserialize(r.json(), self)"} +{"i": 408, "got": "def set(self, permissions):\n \"\"\"pass\"\"\"\n parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', 'single', {'id': self.parent_object.id})\n target_url = parent_url + self.client.get_url_path(self._URL_KEY, 'PUT', 'multi')\n r = self.client.request('PUT', target_url, json=permissions)\n if r.status_code != 201:\n raise exceptions.ServerError('Expected 201 response, got %s: %s' % (r.status_code, target_url))\n return self.list()"} +{"i": 409, "got": "def list(self):\n \"\"\"pass\"\"\"\n parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', 'single', {'id': self.parent_object.id})\n target_url = parent_url + self.client.get_url_path(self._URL_KEY, 'GET', 'multi')\n return base.Query(self, target_url)"} +{"i": 410, "got": "def get(self, permission_id, expand=[]):\n \"\"\"pass\"\"\"\n parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', 'single', {'id': self.parent_object.id})\n target_url = parent_url + self.client.get_url_path(self._URL_KEY, 'GET', 'single', {'permission_id': permission_id})\n return self._get(target_url, expand=expand)"} +{"i": 411, "got": "def get_config():\n \"\"\"pass\"\"\"\n configpath = get_configpath()\n if not configpath.exists():\n raise IOError('Config file {} not found.'.format(str(configpath)))\n config = configparser.ConfigParser()\n config.read(str(configpath))\n return config"} +{"i": 412, "got": "def set_database_path(dbfolder):\n \"\"\"pass\"\"\"\n configpath = get_configpath()\n try:\n d = get_config()\n except IOError:\n d = configparser.ConfigParser()\n d['pyciss_db'] = {}\n d['pyciss_db']['path'] = dbfolder\n with configpath.open('w') as f:\n d.write(f)\n print('Saved database path into {}.'.format(configpath))"} +{"i": 413, "got": "def get_db_root():\n \"\"\"pass\"\"\"\n d = get_config()\n dbroot = Path(d['pyciss_db']['path'])\n dbroot.mkdir(exist_ok=True)\n return dbroot"} +{"i": 414, "got": "def print_db_stats():\n \"\"\"pass\"\"\"\n dbroot = get_db_root()\n n_ids = len(list(dbroot.glob('[N,W]*')))\n print('Number of WACs and NACs in database: {}'.format(n_ids))\n print('These kind of data are in the database: (returning pd.DataFrame)')\n d = {}\n for key, val in PathManager.extensions.items():\n d[key] = [len(list(dbroot.glob('**/*' + val)))]\n return pd.DataFrame(d)"} +{"i": 415, "got": "def is_lossy(label):\n \"\"\"pass\"\"\"\n val = getkey(from_=label, keyword='INST_CMPRS_TYPE').decode().strip()\n if val == 'LOSSY':\n return True\n else:\n return False"} +{"i": 416, "got": "def download_and_calibrate_parallel(list_of_ids, n=None):\n \"\"\"pass\"\"\"\n setup_cluster(n_cores=n)\n c = Client()\n lbview = c.load_balanced_view()\n lbview.map_async(download_and_calibrate, list_of_ids)\n subprocess.Popen(['ipcluster', 'stop', '--quiet'])"} +{"i": 417, "got": "def _set_supported_content_type(self, content_types_supported):\n \"\"\"pass\"\"\"\n if not isinstance(content_types_supported, list):\n raise TypeError(\"Settings 'READTIME_CONTENT_SUPPORT' must bea list of content types.\")\n self.content_type_supported = content_types_supported"} +{"i": 418, "got": "def _set_lang_settings(self, lang_settings):\n \"\"\"pass\"\"\"\n is_int = isinstance(lang_settings, int)\n is_dict = isinstance(lang_settings, dict)\n if not (is_int or is_dict):\n raise TypeError(\"Settings 'READTIME_WPM' must be either an int,or a dict with settings per language.\")\n if is_int:\n self.lang_settings['default']['wpm'] = lang_settings\n elif is_dict:\n for lang, conf in lang_settings.items():\n if not 'wpm' in conf:\n raise KeyError('Missing wpm value for thelanguage: {}'.format(lang))\n if not isinstance(conf['wpm'], int):\n raise TypeError('WPM is not an integer for the language: {}'.format(lang))\n if not 'min_singular' in conf:\n raise KeyError('Missing singular form for \"minute\" for the language: {}'.format(lang))\n if not 'min_plural' in conf:\n raise KeyError('Missing plural form for \"minutes\" for the language: {}'.format(lang))\n if not 'sec_singular' in conf:\n raise KeyError('Missing singular form for \"second\" for the language: {}'.format(lang))\n if not 'sec_plural' in conf:\n raise KeyError('Missing plural form for \"seconds\" for the language: {}'.format(lang))\n self.lang_settings = lang_settings"} +{"i": 419, "got": "def initialize_settings(self, sender):\n \"\"\"pass\"\"\"\n try:\n self.initialized = True\n settings_content_types = sender.settings.get('READTIME_CONTENT_SUPPORT', self.content_type_supported)\n self._set_supported_content_type(settings_content_types)\n lang_settings = sender.settings.get('READTIME_WPM', self.lang_settings)\n self._set_lang_settings(lang_settings)\n except Exception as e:\n raise Exception('ReadTime Plugin: %s' % str(e))"} +{"i": 420, "got": "def read_time(self, content):\n \"\"\"pass\"\"\"\n if get_class_name(content) in self.content_type_supported:\n if hasattr(content, 'readtime'):\n return\n default_lang_conf = self.lang_settings['default']\n lang_conf = self.lang_settings.get(content.lang, default_lang_conf)\n avg_reading_wpm = lang_conf['wpm']\n num_words = len(content._content.split())\n minutes = num_words // avg_reading_wpm\n seconds = int(num_words / avg_reading_wpm * 60 - minutes * 60)\n minutes_str = self.pluralize(minutes, lang_conf['min_singular'], lang_conf['min_plural'])\n seconds_str = self.pluralize(seconds, lang_conf['sec_singular'], lang_conf['sec_plural'])\n content.readtime = minutes\n content.readtime_string = minutes_str\n content.readtime_with_seconds = (minutes, seconds)\n content.readtime_string_with_seconds = '{}, {}'.format(minutes_str, seconds_str)"} +{"i": 421, "got": "def pluralize(self, measure, singular, plural):\n \"\"\"pass\"\"\"\n if measure == 1:\n return '{} {}'.format(measure, singular)\n else:\n return '{} {}'.format(measure, plural)"} +{"i": 422, "got": "def list_datasources(self, source_id):\n \"\"\"pass\"\"\"\n target_url = self.client.get_url('DATASOURCE', 'GET', 'multi', {'source_id': source_id})\n return base.Query(self.client.get_manager(Datasource), target_url)"} +{"i": 423, "got": "def get_datasource(self, source_id, datasource_id):\n \"\"\"pass\"\"\"\n target_url = self.client.get_url('DATASOURCE', 'GET', 'single', {'source_id': source_id, 'datasource_id': datasource_id})\n return self.client.get_manager(Datasource)._get(target_url)"} +{"i": 424, "got": "def open_store_variable(self, name, var):\n \"\"\"pass\"\"\"\n data = indexing.LazilyOuterIndexedArray(CDMArrayWrapper(name, self))\n return Variable(var.dimensions, data, {a: getattr(var, a) for a in var.ncattrs()})"} +{"i": 425, "got": "def get_attrs(self):\n \"\"\"pass\"\"\"\n return FrozenOrderedDict(((a, getattr(self.ds, a)) for a in self.ds.ncattrs()))"} +{"i": 426, "got": "def get_dimensions(self):\n \"\"\"pass\"\"\"\n return FrozenOrderedDict(((k, len(v)) for k, v in self.ds.dimensions.items()))"} +{"i": 427, "got": "def _find_base_tds_url(catalog_url):\n \"\"\"pass\"\"\"\n url_components = urlparse(catalog_url)\n if url_components.path:\n return catalog_url.split(url_components.path)[0]\n else:\n return catalog_url"} +{"i": 428, "got": "def filter_time_nearest(self, time, regex=None):\n \"\"\"pass\"\"\"\n return min(self._get_datasets_with_times(regex), key=lambda i: abs((i[0] - time).total_seconds()))[-1]"} +{"i": 429, "got": "def filter_time_range(self, start, end, regex=None):\n \"\"\"pass\"\"\"\n return [item[-1] for item in self._get_datasets_with_times(regex) if start <= item[0] <= end]"} +{"i": 430, "got": "def check_token(func):\n \"\"\"pass\"\"\"\n\n @wraps(func)\n def wrapper(*args, **kwargs):\n response = func(*args, **kwargs)\n if response.status_code == 401:\n raise InvalidToken('Access token invalid or no longer valid')\n return response\n return wrapper"} +{"i": 431, "got": "def upload(self, remote_path, file_content, ondup=None, **kwargs):\n \"\"\"pass\"\"\"\n params = {'path': remote_path, 'ondup': ondup}\n files = {'file': ('file', file_content, '')}\n url = 'https://c.pcs.baidu.com/rest/2.0/pcs/file'\n return self._request('file', 'upload', url=url, extra_params=params, files=files, **kwargs)"} +{"i": 432, "got": "def upload_tmpfile(self, file_content, **kwargs):\n \"\"\"pass\"\"\"\n params = {'type': 'tmpfile'}\n files = {'file': ('file', file_content, '')}\n url = 'https://c.pcs.baidu.com/rest/2.0/pcs/file'\n return self._request('file', 'upload', url=url, extra_params=params, files=files, **kwargs)"} +{"i": 433, "got": "def upload_superfile(self, remote_path, block_list, ondup=None, **kwargs):\n \"\"\"pass\"\"\"\n params = {'path': remote_path, 'ondup': ondup}\n data = {'param': json.dumps({'block_list': block_list})}\n return self._request('file', 'createsuperfile', extra_params=params, data=data, **kwargs)"} +{"i": 434, "got": "def mkdir(self, remote_path, **kwargs):\n \"\"\"pass\"\"\"\n data = {'path': remote_path}\n return self._request('file', 'mkdir', data=data, **kwargs)"} +{"i": 435, "got": "def meta(self, remote_path, **kwargs):\n \"\"\"pass\"\"\"\n params = {'path': remote_path}\n return self._request('file', 'meta', extra_params=params, **kwargs)"} +{"i": 436, "got": "def login(self):\n \"\"\"pass\"\"\"\n if os.path.exists(self._cookieFileName):\n with open(self._cookieFileName, 'r') as cookieFile:\n self._vid = cookieFile.read().strip()\n try:\n self._get_installations()\n except ResponseError:\n self._vid = None\n os.remove(self._cookieFileName)\n if self._vid is None:\n self._create_cookie()\n with open(self._cookieFileName, 'w') as cookieFile:\n cookieFile.write(self._vid)\n self._get_installations()\n self._giid = self.installations[0]['giid']"} +{"i": 437, "got": "def _get_installations(self):\n \"\"\"pass\"\"\"\n response = None\n for base_url in urls.BASE_URLS:\n urls.BASE_URL = base_url\n try:\n response = requests.get(urls.get_installations(self._username), headers={'Cookie': 'vid={}'.format(self._vid), 'Accept': 'application/json,text/javascript, */*; q=0.01'})\n if 2 == response.status_code // 100:\n break\n elif 503 == response.status_code:\n continue\n else:\n raise ResponseError(response.status_code, response.text)\n except requests.exceptions.RequestException as ex:\n raise RequestError(ex)\n _validate_response(response)\n self.installations = json.loads(response.text)"} +{"i": 438, "got": "def get_overview(self):\n \"\"\"pass\"\"\"\n response = None\n try:\n response = requests.get(urls.overview(self._giid), headers={'Accept': 'application/json, text/javascript, */*; q=0.01', 'Accept-Encoding': 'gzip, deflate', 'Content-Type': 'application/json', 'Cookie': 'vid={}'.format(self._vid)})\n except requests.exceptions.RequestException as ex:\n raise RequestError(ex)\n _validate_response(response)\n return json.loads(response.text)"} +{"i": 439, "got": "def set_smartplug_state(self, device_label, state):\n \"\"\"pass\"\"\"\n response = None\n try:\n response = requests.post(urls.smartplug(self._giid), headers={'Content-Type': 'application/json', 'Cookie': 'vid={}'.format(self._vid)}, data=json.dumps([{'deviceLabel': device_label, 'state': state}]))\n except requests.exceptions.RequestException as ex:\n raise RequestError(ex)\n _validate_response(response)"} +{"i": 440, "got": "def get_history(self, filters=(), pagesize=15, offset=0):\n \"\"\"pass\"\"\"\n response = None\n try:\n response = requests.get(urls.history(self._giid), headers={'Accept': 'application/json, text/javascript, */*; q=0.01', 'Cookie': 'vid={}'.format(self._vid)}, params={'offset': int(offset), 'pagesize': int(pagesize), 'notificationCategories': filters})\n except requests.exceptions.RequestException as ex:\n raise RequestError(ex)\n _validate_response(response)\n return json.loads(response.text)"} +{"i": 441, "got": "def get_climate(self, device_label):\n \"\"\"pass\"\"\"\n response = None\n try:\n response = requests.get(urls.climate(self._giid), headers={'Accept': 'application/json, text/javascript, */*; q=0.01', 'Cookie': 'vid={}'.format(self._vid)}, params={'deviceLabel': device_label})\n except requests.exceptions.RequestException as ex:\n raise RequestError(ex)\n _validate_response(response)\n return json.loads(response.text)"} +{"i": 442, "got": "def type_id(self):\n \"\"\"pass\"\"\"\n try:\n return ContentType.objects.get_for_model(self.model, for_concrete_model=False).id\n except DatabaseError as e:\n raise DatabaseError('Unable to fetch ContentType object, is a plugin being registered before the initial syncdb? (original error: {0})'.format(str(e)))"} +{"i": 443, "got": "def get_output_cache_key(self, placeholder_name, instance):\n \"\"\"pass\"\"\"\n cachekey = self.get_output_cache_base_key(placeholder_name, instance)\n if self.cache_output_per_site:\n cachekey = '{0}-s{1}'.format(cachekey, settings.SITE_ID)\n if self.cache_output_per_language:\n user_language = get_language()\n if user_language not in self.cache_supported_language_codes:\n user_language = 'unsupported'\n cachekey = '{0}.{1}'.format(cachekey, user_language)\n return cachekey"} +{"i": 444, "got": "def get_output_cache_keys(self, placeholder_name, instance):\n \"\"\"pass\"\"\"\n base_key = self.get_output_cache_base_key(placeholder_name, instance)\n cachekeys = [base_key]\n if self.cache_output_per_site:\n site_ids = list(Site.objects.values_list('pk', flat=True))\n if settings.SITE_ID not in site_ids:\n site_ids.append(settings.SITE_ID)\n base_key = get_rendering_cache_key(placeholder_name, instance)\n cachekeys = ['{0}-s{1}'.format(base_key, site_id) for site_id in site_ids]\n if self.cache_output_per_language or self.render_ignore_item_language:\n total_list = []\n cache_languages = list(self.cache_supported_language_codes) + ['unsupported', 'None']\n placeholder = instance.placeholder\n total_list.extend((get_placeholder_cache_key(placeholder, lc) for lc in cache_languages))\n for user_language in cache_languages:\n total_list.extend(('{0}.{1}'.format(base, user_language) for base in cachekeys))\n cachekeys = total_list\n return cachekeys"} +{"i": 445, "got": "def get_cached_output(self, placeholder_name, instance):\n \"\"\"pass\"\"\"\n cachekey = self.get_output_cache_key(placeholder_name, instance)\n return cache.get(cachekey)"} +{"i": 446, "got": "def set_cached_output(self, placeholder_name, instance, output):\n \"\"\"pass\"\"\"\n cachekey = self.get_output_cache_key(placeholder_name, instance)\n if self.cache_timeout is not DEFAULT_TIMEOUT:\n cache.set(cachekey, output, self.cache_timeout)\n else:\n cache.set(cachekey, output)"} +{"i": 447, "got": "def render(self, request, instance, **kwargs):\n \"\"\"pass\"\"\"\n render_template = self.get_render_template(request, instance, **kwargs)\n if not render_template:\n return str(_(\"{No rendering defined for class '%s'}\" % self.__class__.__name__))\n context = self.get_context(request, instance, **kwargs)\n return self.render_to_string(request, render_template, context)"} +{"i": 448, "got": "def inline_requests(method_or_func):\n \"\"\"pass\"\"\"\n args = get_args(method_or_func)\n if not args:\n raise TypeError('Function must accept at least one argument.')\n if args[0] == 'self':\n\n def wrapper(self, response, **kwargs):\n callback = create_bound_method(method_or_func, self)\n genwrapper = RequestGenerator(callback, **kwargs)\n return genwrapper(response)\n else:\n warnings.warn('Decorating a non-method function will be deprecated', ScrapyDeprecationWarning, stacklevel=1)\n\n def wrapper(response, **kwargs):\n genwrapper = RequestGenerator(method_or_func, **kwargs)\n return genwrapper(response)\n return wraps(method_or_func)(wrapper)"} +{"i": 449, "got": "def get_args(method_or_func):\n \"\"\"pass\"\"\"\n try:\n args = list(inspect.signature(method_or_func).parameters.keys())\n except AttributeError:\n args = inspect.getargspec(method_or_func).args\n return args"} +{"i": 450, "got": "def _unwindGenerator(self, generator, _prev=None):\n \"\"\"pass\"\"\"\n while True:\n if _prev:\n ret, _prev = (_prev, None)\n else:\n try:\n ret = next(generator)\n except StopIteration:\n return\n if isinstance(ret, Request):\n if ret.callback:\n warnings.warn('Got a request with callback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n elif ret.errback:\n warnings.warn('Got a request with errback set, bypassing the generator wrapper. Generator may not be able to resume. %s' % ret)\n else:\n yield self._wrapRequest(ret, generator)\n else:\n yield ret"} +{"i": 451, "got": "def jwt_required(fn):\n \"\"\"pass\"\"\"\n\n @wraps(fn)\n def wrapper(*args, **kwargs):\n jwt_data = _decode_jwt_from_headers()\n ctx_stack.top.jwt = jwt_data\n return fn(*args, **kwargs)\n return wrapper"} +{"i": 452, "got": "def jwt_optional(fn):\n \"\"\"pass\"\"\"\n\n @wraps(fn)\n def wrapper(*args, **kwargs):\n try:\n jwt_data = _decode_jwt_from_headers()\n ctx_stack.top.jwt = jwt_data\n except (NoAuthorizationError, InvalidHeaderError):\n pass\n return fn(*args, **kwargs)\n return wrapper"} +{"i": 453, "got": "def decode_jwt(encoded_token):\n \"\"\"pass\"\"\"\n secret = config.decode_key\n algorithm = config.algorithm\n audience = config.audience\n return jwt.decode(encoded_token, secret, algorithms=[algorithm], audience=audience)"} +{"i": 454, "got": "def init_app(self, app):\n \"\"\"pass\"\"\"\n if not hasattr(app, 'extensions'):\n app.extensions = {}\n app.extensions['flask-jwt-simple'] = self\n self._set_default_configuration_options(app)\n self._set_error_handler_callbacks(app)\n app.config['PROPAGATE_EXCEPTIONS'] = True"} +{"i": 455, "got": "def _set_error_handler_callbacks(self, app):\n \"\"\"pass\"\"\"\n\n @app.errorhandler(NoAuthorizationError)\n def handle_no_auth_error(e):\n return self._unauthorized_callback(str(e))\n\n @app.errorhandler(InvalidHeaderError)\n def handle_invalid_header_error(e):\n return self._invalid_token_callback(str(e))\n\n @app.errorhandler(jwt.ExpiredSignatureError)\n def handle_expired_error(e):\n return self._expired_token_callback()\n\n @app.errorhandler(jwt.InvalidTokenError)\n def handle_invalid_token_error(e):\n return self._invalid_token_callback(str(e))"} +{"i": 456, "got": "def _set_default_configuration_options(app):\n \"\"\"pass\"\"\"\n app.config.setdefault('JWT_HEADER_NAME', 'Authorization')\n app.config.setdefault('JWT_HEADER_TYPE', 'Bearer')\n app.config.setdefault('JWT_EXPIRES', datetime.timedelta(hours=1))\n app.config.setdefault('JWT_ALGORITHM', 'HS256')\n app.config.setdefault('JWT_IDENTITY_CLAIM', 'sub')\n app.config.setdefault('JWT_DECODE_AUDIENCE', None)\n app.config.setdefault('JWT_SECRET_KEY', None)\n app.config.setdefault('JWT_PRIVATE_KEY', None)\n app.config.setdefault('JWT_PUBLIC_KEY', None)"} +{"i": 457, "got": "def category(**kwargs):\n \"\"\"pass\"\"\"\n if 'series' in kwargs:\n kwargs.pop('series')\n path = 'series'\n else:\n path = None\n return Fred().category(path, **kwargs)"} +{"i": 458, "got": "def releases(release_id=None, **kwargs):\n \"\"\"pass\"\"\"\n if 'id' not in kwargs and release_id is not None:\n kwargs['release_id'] = release_id\n return Fred().release(**kwargs)\n else:\n return Fred().releases(**kwargs)"} +{"i": 459, "got": "def series(identifier=None, **kwargs):\n \"\"\"pass\"\"\"\n if identifier:\n kwargs['series_id'] = identifier\n if 'release' in kwargs:\n kwargs.pop('release')\n path = 'release'\n elif 'releases' in kwargs:\n kwargs.pop('releases')\n path = 'release'\n else:\n path = None\n return Fred().series(path, **kwargs)"} +{"i": 460, "got": "def source(source_id=None, **kwargs):\n \"\"\"pass\"\"\"\n if source_id is not None:\n kwargs['source_id'] = source_id\n elif 'id' in kwargs:\n source_id = kwargs.pop('id')\n kwargs['source_id'] = source_id\n if 'releases' in kwargs:\n kwargs.pop('releases')\n path = 'releases'\n else:\n path = None\n return Fred().source(path, **kwargs)"} +{"i": 461, "got": "def sources(source_id=None, **kwargs):\n \"\"\"pass\"\"\"\n if source_id or 'id' in kwargs:\n return source(source_id, **kwargs)\n else:\n return Fred().sources(**kwargs)"} +{"i": 462, "got": "def _create_path(self, *args):\n \"\"\"pass\"\"\"\n args = filter(None, args)\n path = self.endpoint + '/'.join(args)\n return path"} +{"i": 463, "got": "def item_extra_kwargs(self, item):\n \"\"\"pass\"\"\"\n if use_feed_image:\n feed_image = item.feed_image\n if feed_image:\n image_complete_url = urljoin(self.get_site_url(), feed_image.file.url)\n else:\n image_complete_url = ''\n content_field = getattr(item, self.item_content_field)\n try:\n content = expand_db_html(content_field)\n except:\n content = content_field.__html__()\n soup = BeautifulSoup(content, 'html.parser')\n for div in soup.find_all('div', {'class': 'responsive-object'}):\n del div['style']\n for img_tag in soup.findAll('img'):\n if not img_tag.has_attr('src'):\n continue\n img_tag['src'] = urljoin(self.get_site_url(), img_tag['src'])\n fields_to_add = {'content': soup.prettify(formatter='html')}\n if use_feed_image:\n fields_to_add['image'] = image_complete_url\n else:\n fields_to_add['image'] = ''\n return fields_to_add"} +{"i": 464, "got": "def treenav_undefined_url(request, item_slug):\n \"\"\"pass\"\"\"\n item = get_object_or_404(treenav.MenuItem, slug=item_slug)\n raise Http404"} +{"i": 465, "got": "def treenav_save_other_object_handler(sender, instance, created, **kwargs):\n \"\"\"pass\"\"\"\n from django.contrib.contenttypes.models import ContentType\n from .models import MenuItem\n cache_key = 'django-treenav-menumodels'\n if sender == MenuItem:\n cache.delete(cache_key)\n menu_models = cache.get(cache_key)\n if not menu_models:\n menu_models = []\n for menu_item in MenuItem.objects.exclude(content_type__isnull=True):\n menu_models.append(menu_item.content_type.model_class())\n cache.set(cache_key, menu_models)\n if sender in menu_models:\n ct = ContentType.objects.get_for_model(sender)\n items = MenuItem.objects.filter(content_type=ct, object_id=instance.pk)\n for item in items:\n if item.href != instance.get_absolute_url():\n item.href = instance.get_absolute_url()\n item.save()"} +{"i": 466, "got": "def refresh_hrefs(self, request):\n \"\"\"pass\"\"\"\n for item in treenav.MenuItem.objects.all():\n item.save()\n self.message_user(request, _('Menu item HREFs refreshed successfully.'))\n info = (self.model._meta.app_label, self.model._meta.model_name)\n changelist_url = reverse('admin:%s_%s_changelist' % info, current_app=self.admin_site.name)\n return redirect(changelist_url)"} +{"i": 467, "got": "def clean_cache(self, request):\n \"\"\"pass\"\"\"\n treenav.delete_cache()\n self.message_user(request, _('Cache menuitem cache cleaned successfully.'))\n info = (self.model._meta.app_label, self.model._meta.model_name)\n changelist_url = reverse('admin:%s_%s_changelist' % info, current_app=self.admin_site.name)\n return redirect(changelist_url)"} +{"i": 468, "got": "def rebuild_tree(self, request):\n \"\"\"pass\"\"\"\n self.model.objects.rebuild()\n self.message_user(request, _('Menu Tree Rebuilt.'))\n return self.clean_cache(request)"} +{"i": 469, "got": "def save_related(self, request, form, formsets, change):\n \"\"\"pass\"\"\"\n super(MenuItemAdmin, self).save_related(request, form, formsets, change)\n self.model.objects.rebuild()"} +{"i": 470, "got": "def _calculate_dispersion(X: Union[pd.DataFrame, np.ndarray], labels: np.ndarray, centroids: np.ndarray) -> float:\n \"\"\"pass\"\"\"\n disp = np.sum(np.sum([np.abs(inst - centroids[label]) ** 2 for inst, label in zip(X, labels)]))\n return disp"} +{"i": 471, "got": "def _calculate_gap(self, X: Union[pd.DataFrame, np.ndarray], n_refs: int, n_clusters: int) -> Tuple[float, int]:\n \"\"\"pass\"\"\"\n ref_dispersions = np.zeros(n_refs)\n for i in range(n_refs):\n random_data = np.random.random_sample(size=X.shape)\n centroids, labels = kmeans2(data=random_data, k=n_clusters, iter=10, minit='points')\n dispersion = self._calculate_dispersion(X=random_data, labels=labels, centroids=centroids)\n ref_dispersions[i] = dispersion\n centroids, labels = kmeans2(data=X, k=n_clusters, iter=10, minit='points')\n dispersion = self._calculate_dispersion(X=X, labels=labels, centroids=centroids)\n gap_value = np.mean(np.log(ref_dispersions)) - np.log(dispersion)\n return (gap_value, int(n_clusters))"} +{"i": 472, "got": "def _process_with_rust(self, X: Union[pd.DataFrame, np.ndarray], n_refs: int, cluster_array: np.ndarray):\n \"\"\"pass\"\"\"\n from gap_statistic.rust import gapstat\n for label, gap_value in gapstat.optimal_k(X, list(cluster_array)):\n yield (gap_value, label)"} +{"i": 473, "got": "def _process_with_joblib(self, X: Union[pd.DataFrame, np.ndarray], n_refs: int, cluster_array: np.ndarray):\n \"\"\"pass\"\"\"\n if Parallel is None:\n raise EnvironmentError('joblib is not installed; cannot use joblib as the parallel backend!')\n with Parallel(n_jobs=self.n_jobs) as parallel:\n for gap_value, n_clusters in parallel((delayed(self._calculate_gap)(X, n_refs, n_clusters) for n_clusters in cluster_array)):\n yield (gap_value, n_clusters)"} +{"i": 474, "got": "def _process_with_multiprocessing(self, X: Union[pd.DataFrame, np.ndarray], n_refs: int, cluster_array: np.ndarray):\n \"\"\"pass\"\"\"\n with ProcessPoolExecutor(max_workers=self.n_jobs) as executor:\n jobs = [executor.submit(self._calculate_gap, X, n_refs, n_clusters) for n_clusters in cluster_array]\n for future in as_completed(jobs):\n gap_value, k = future.result()\n yield (gap_value, k)"} +{"i": 475, "got": "def _process_non_parallel(self, X: Union[pd.DataFrame, np.ndarray], n_refs: int, cluster_array: np.ndarray):\n \"\"\"pass\"\"\"\n for gap_value, n_clusters in [self._calculate_gap(X, n_refs, n_clusters) for n_clusters in cluster_array]:\n yield (gap_value, n_clusters)"} +{"i": 476, "got": "def get_last(self):\n \"\"\"pass\"\"\"\n query = self.table().where('batch', self.get_last_batch_number())\n return query.order_by('migration', 'desc').get()"} +{"i": 477, "got": "def compile_insert(self, query, values):\n \"\"\"pass\"\"\"\n table = self.wrap_table(query.from__)\n if not isinstance(values, list):\n values = [values]\n columns = self.columnize(values[0].keys())\n parameters = self.parameterize(values[0].values())\n value = ['(%s)' % parameters] * len(values)\n parameters = ', '.join(value)\n return 'INSERT INTO %s (%s) VALUES %s' % (table, columns, parameters)"} +{"i": 478, "got": "def get_alter_table_sql(self, diff):\n \"\"\"pass\"\"\"\n sql = []\n for column_diff in diff.changed_columns.values():\n if self.is_unchanged_binary_column(column_diff):\n continue\n old_column_name = column_diff.old_column_name\n column = column_diff.column\n if any([column_diff.has_changed('type'), column_diff.has_changed('precision'), column_diff.has_changed('scale'), column_diff.has_changed('fixed')]):\n query = 'ALTER ' + old_column_name + ' TYPE ' + self.get_sql_type_declaration(column.to_dict())\n sql.append('ALTER TABLE ' + diff.name + ' ' + query)\n if column_diff.has_changed('default') or column_diff.has_changed('type'):\n if column.get_default() is None:\n default_clause = ' DROP DEFAULT'\n else:\n default_clause = ' SET' + self.get_default_value_declaration_sql(column.to_dict())\n query = 'ALTER ' + old_column_name + default_clause\n sql.append('ALTER TABLE ' + diff.name + ' ' + query)\n if column_diff.has_changed('notnull'):\n op = 'DROP'\n if column.get_notnull():\n op = 'SET'\n query = 'ALTER ' + old_column_name + ' ' + op + ' NOT NULL'\n sql.append('ALTER TABLE ' + diff.name + ' ' + query)\n if column_diff.has_changed('autoincrement'):\n if column.get_autoincrement():\n seq_name = self.get_identity_sequence_name(diff.name, old_column_name)\n sql.append('CREATE SEQUENCE ' + seq_name)\n sql.append(\"SELECT setval('\" + seq_name + \"', (SELECT MAX(\" + old_column_name + ') FROM ' + diff.name + '))\")\n query = 'ALTER ' + old_column_name + \" SET DEFAULT nextval('\" + seq_name + \"')\"\n sql.append('ALTER TABLE ' + diff.name + ' ' + query)\n else:\n query = 'ALTER ' + old_column_name + ' DROP DEFAULT'\n sql.append('ALTER TABLE ' + diff.name + ' ' + query)\n if column_diff.has_changed('length'):\n query = 'ALTER ' + old_column_name + ' TYPE ' + self.get_sql_type_declaration(column.to_dict())\n sql.append('ALTER TABLE ' + diff.name + ' ' + query)\n for old_column_name, column in diff.renamed_columns.items():\n sql.append('ALTER TABLE ' + diff.name + ' RENAME COLUMN ' + old_column_name + ' TO ' + column.get_name())\n return sql"} +{"i": 479, "got": "def _date_based_where(self, type, query, where):\n \"\"\"pass\"\"\"\n value = str(where['value']).zfill(2)\n value = self.parameter(value)\n return \"strftime('%s', %s) %s %s\" % (type, self.wrap(where['column']), where['operator'], value)"} +{"i": 480, "got": "def compile_select(self, query):\n \"\"\"pass\"\"\"\n sql = super(MySqlQueryGrammar, self).compile_select(query)\n if query.unions:\n sql = '%s %s' % (sql, self._compile_unions(query))\n return sql"} +{"i": 481, "got": "def _compile_lock(self, query, value):\n \"\"\"pass\"\"\"\n if isinstance(value, basestring):\n return value\n elif value is True:\n return 'FOR UPDATE'\n elif value is False:\n return 'LOCK IN SHARE MODE'"} +{"i": 482, "got": "def plot_best_worst_fits(assignments_df, data, modality_col='Modality', score='$\\\\log_2 K$'):\n \"\"\"pass\"\"\"\n ncols = 2\n nrows = len(assignments_df.groupby(modality_col).groups.keys())\n fig, axes = plt.subplots(nrows=nrows, ncols=ncols * 4, figsize=(ncols * 6, 4))\n axes_iter = axes.flat\n fits = ('Highest', 'Lowest')\n for modality, df in assignments_df.groupby(modality_col):\n df = df.sort_values(score)\n color = MODALITY_TO_COLOR[modality]\n for fit in fits:\n if fit == 'Highest':\n ids = df['Feature ID'][-10:]\n else:\n ids = df['Feature ID'][:10]\n fit_psi = data[ids]\n tidy_fit_psi = fit_psi.stack().reset_index()\n tidy_fit_psi = tidy_fit_psi.rename(columns={'level_0': 'Sample ID', 'level_1': 'Feature ID', 0: '$\\\\Psi$'})\n if not tidy_fit_psi.empty:\n continue\n ax = six.next(axes_iter)\n violinplot(x='Feature ID', y='$\\\\Psi$', data=tidy_fit_psi, color=color, ax=ax)\n ax.set(title='{} {} {}'.format(fit, score, modality), xticks=[])\n sns.despine()\n fig.tight_layout()"} +{"i": 483, "got": "def violinplot(x=None, y=None, data=None, bw=0.2, scale='width', inner=None, ax=None, **kwargs):\n \"\"\"pass\"\"\"\n if ax is None:\n ax = plt.gca()\n sns.violinplot(x, y, data=data, bw=bw, scale=scale, inner=inner, ax=ax, **kwargs)\n ax.set(ylim=(0, 1), yticks=(0, 0.5, 1))\n return ax"} +{"i": 484, "got": "def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):\n \"\"\"pass\"\"\"\n if percentages:\n counts = (100 * (counts.T / counts.T.sum()).T)\n if ax is None:\n ax = plt.gca()\n full_width = 0.8\n width = full_width / counts.shape[0]\n for i, (group, series) in enumerate(counts.iterrows()):\n left = np.arange(len(self.modality_order)) + i * width\n height = [series[i] if i in group else 0 for i in self.modality_order]\n color = phenotype_to_color[group]\n ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')\n ylabel = 'Percentage of events' if percentages else 'Number of events'\n ax.set_ylabel(ylabel)\n ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)\n ax.set_xticklabels(self.modality_order)\n ax.set_xlabel('Splicing modality')\n ax.set_xlim(0, len(self.modality_order))\n ax.legend(loc='best')\n ax.grid(axis='y', linestyle='-', linewidth=0.5)\n sns.despine()"} +{"i": 485, "got": "def event_estimation(self, event, logliks, logsumexps, renamed=''):\n \"\"\"pass\"\"\"\n plotter = _ModelLoglikPlotter()\n plotter.plot(event, logliks, logsumexps, self.modality_to_color, renamed=renamed)\n return plotter"} +{"i": 486, "got": "def predict(self, fitted):\n \"\"\"pass\"\"\"\n if fitted.shape[0] != len(self.modalities):\n raise ValueError(\"This data doesn't look like it had the distance between it and the five modalities calculated\")\n return fitted.idxmin()"} +{"i": 487, "got": "def logliks(self, x):\n \"\"\"pass\"\"\"\n x = x.copy()\n x[x == 0] = VERY_SMALL_NUMBER\n x[x == 1] = 1 - VERY_SMALL_NUMBER\n return np.array([np.log(prob) + rv.logpdf(x[np.isfinite(x)]).sum() for prob, rv in zip(self.prob_parameters, self.rvs)])"} +{"i": 488, "got": "def get_next_value(sequence_name, initial_value, reset_value='default', *, nowait=False, using=None):\n \"\"\"pass\"\"\"\n from .models import Sequence\n if reset_value is not None and (not initial_value < reset_value):\n assert False\n if using is None:\n using = router.db_for_write(Sequence)\n connection = connections[using]\n if getattr(connection, 'pg_version', 0) >= 90500 and reset_value is None and (not nowait):\n with connection.cursor() as cursor:\n cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])\n last, = cursor.fetchone()\n return last\n else:\n with transaction.atomic(using=using, savepoint=False):\n sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})\n if not created:\n sequence.last += 1\n if reset_value is not None and sequence.last >= reset_value:\n sequence.last = initial_value\n sequence.save()\n return sequence.last"} +{"i": 489, "got": "def check(self, final_line_count):\n \"\"\"pass\"\"\"\n if self._lines_seen['version']:\n self._process_version_lines()\n self._process_plan_lines(final_line_count)"} +{"i": 490, "got": "def _process_version_lines(self):\n \"\"\"pass\"\"\"\n if len(self._lines_seen['version']) > 1:\n self._add_error(_('Multiple version lines appeared.'))\n elif self._lines_seen['version'][0] != 1:\n self._add_error(_('The version must be on the first line.'))"} +{"i": 491, "got": "def _process_plan_lines(self, final_line_count):\n \"\"\"pass\"\"\"\n if not self._lines_seen['plan']:\n self._add_error(_('Missing a plan.'))\n return\n elif len(self._lines_seen['plan']) > 1:\n self._add_error(_('Only one plan line is permitted per file.'))\n return\n else:\n plan, at_line = self._lines_seen['plan'][0]\n if not self._plan_on_valid_line(at_line, final_line_count):\n self._add_error(_('A plan must appear at the beginning or end of the file.'))\n return\n elif plan.expected_tests != self._lines_seen['test']:\n self._add_error(_('Expected {expected_count} tests but only {seen_count} ran.').format(expected_count=plan.expected_tests, seen_count=self._lines_seen['test']))"} +{"i": 492, "got": "def _plan_on_valid_line(self, at_line, final_line_count):\n \"\"\"pass\"\"\"\n if at_line == 1 or (at_line == final_line_count):\n return True\n after_version = self._lines_seen['version'] and self._lines_seen['version'][0] == 1 and (at_line == 2)\n if after_version:\n return True\n else:\n return False"} +{"i": 493, "got": "def handle_bail(self, bail):\n \"\"\"pass\"\"\"\n self._add_error(_('Bailed: {reason}').format(reason=bail.reason))"} +{"i": 494, "got": "def handle_skipping_plan(self, skip_plan):\n \"\"\"pass\"\"\"\n skip_line = Result(True, None, skip_plan.directive.text, Directive('SKIP'))\n self._suite.addTest(Adapter(self._filename, skip_line))"} +{"i": 495, "got": "def mptt_before_insert(mapper, connection, instance):\n \"\"\"pass\"\"\"\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n table_pk = getattr(table.c, db_pk.name)\n if instance.parent_id is None:\n instance.left = 1\n instance.right = 2\n instance.level = instance.get_default_level()\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1])) or 1\n instance.tree_id = tree_id\n else:\n parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.level])).where(table_pk == instance.parent_id).fetchone()\n connection.execute(table.update(and_(table.c.rgt >= parent_pos_right, table.c.tree_id == parent_tree_id)).values(lft=case([(table.c.lft > parent_pos_right, table.c.lft + 2)], else_=table.c.lft), rgt=case([(table.c.rgt >= parent_pos_right, table.c.rgt + 2)], else_=table.c.rgt)))\n instance.level = parent_level + 1\n instance.tree_id = parent_tree_id\n instance.left = parent_pos_right\n instance.right = parent_pos_right + 1"} +{"i": 496, "got": "def mptt_before_update(mapper, connection, instance):\n \"\"\"pass\"\"\"\n node_id = getattr(instance, instance.get_pk_name())\n table = _get_tree_table(mapper)\n db_pk = instance.get_pk_column()\n default_level = instance.get_default_level()\n table_pk = getattr(table.c, db_pk.name)\n mptt_move_inside = None\n left_sibling = None\n left_sibling_tree_id = None\n if hasattr(instance, 'mptt_move_inside'):\n mptt_move_inside = instance.mptt_move_inside\n if hasattr(instance, 'mptt_move_before'):\n right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()\n current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()\n if current_lvl_nodes:\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n elif not right_sibling_parent:\n left_sibling_tree_id = right_sibling_tree_id - 1\n if hasattr(instance, 'mptt_move_after'):\n left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()\n instance.parent_id = left_sibling_parent\n left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}\n '\\n Get the subtree\\n '\n subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id))).order_by(table.c.lft).fetchall()\n subtree = [x[0] for x in subtree]\n '\\n Get the node position\\n '\n node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()\n if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside) and (left_sibling_tree_id is None):\n return\n if instance.parent_id is not None:\n '\\n Get the parent\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n if node_parent_id is None and node_tree_id == parent_tree_id:\n instance.parent_id = None\n return\n mptt_before_delete(mapper, connection, instance, False)\n if instance.parent_id is not None:\n '\\n Delete the subtree\\n '\n parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()\n node_size = node_pos_right - node_pos_left + 1\n if not left_sibling:\n left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}\n instance.tree_id = parent_tree_id\n _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)\n else:\n if left_sibling_tree_id or left_sibling_tree_id == 0:\n tree_id = left_sibling_tree_id + 1\n connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=tree_id))\n else:\n tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))\n connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))"} +{"i": 497, "got": "def after_flush_postexec(self, session, context):\n \"\"\"pass\"\"\"\n instances = self.instances[session]\n while instances:\n instance = instances.pop()\n if instance not in session:\n continue\n parent = self.get_parent_value(instance)\n while parent != NO_VALUE and parent is not None:\n instances.discard(parent)\n session.expire(parent, ['left', 'right', 'tree_id', 'level'])\n parent = self.get_parent_value(parent)\n session.expire(instance, ['left', 'right', 'tree_id', 'level'])\n self.expire_session_for_children(session, instance)"} +{"i": 498, "got": "def is_ancestor_of(self, other, inclusive=False):\n \"\"\"pass\"\"\"\n if inclusive:\n return (self.tree_id == other.tree_id) & (self.left <= other.left) & (other.right <= self.right)\n else:\n return (self.tree_id == other.tree_id) & (self.left < other.left) & (other.right < self.right)"} +{"i": 499, "got": "def move_inside(self, parent_id):\n \"\"\"pass\"\"\"\n session = Session.object_session(self)\n self.parent_id = parent_id\n self.mptt_move_inside = parent_id\n session.add(self)"} +{"i": 500, "got": "def move_after(self, node_id):\n \"\"\"pass\"\"\"\n session = Session.object_session(self)\n self.parent_id = self.parent_id\n self.mptt_move_after = node_id\n session.add(self)"} +{"i": 501, "got": "def make_request(cls, url, method=None, params=None, basic_auth=None, timeout=600):\n \"\"\"pass\"\"\"\n params = {} if params is None else params\n cls.request_id += 1\n params = {k: v for k, v in params.items() if v is not None}\n data = {'method': method, 'params': params, 'jsonrpc': '2.0', 'id': cls.request_id}\n headers = {'Content-Type': 'application/json-rpc', 'user-agent': 'LBRY python3-api'}\n request = requests.Request('POST', url, json=data, headers=headers, auth=basic_auth)\n prepared = request.prepare()\n try:\n sesh = requests.Session()\n response = sesh.send(prepared, timeout=timeout)\n response_json = response.json()\n if 'result' in response_json:\n return (response_json['result'], response)\n elif 'error' in response_json:\n raise LBRYUtils.LBRYException('POST Request made to LBRY received an error', response_json, response.status_code, prepared)\n except requests.HTTPError as HE:\n print(HE)\n return (None, None)\n except requests.RequestException as RE:\n print(RE)\n print('Printing Request Created:\\n')\n LBRYUtils.print_request(prepared)\n return (None, None)"} +{"i": 502, "got": "def adjust_status(info: dict) -> dict:\n \"\"\"pass\"\"\"\n modified_info = deepcopy(info)\n modified_info.update({'level': get_nearest_by_numeric_key(STATUS_MAP, int(info['level'])), 'level2': STATUS_MAP[99] if info['level2'] is None else get_nearest_by_numeric_key(STATUS_MAP, int(info['level2']))})\n return modified_info"} +{"i": 503, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n cdc_data = await self.raw_cdc_data()\n nearest = await self.nearest_by_coordinates(latitude, longitude)\n return adjust_status(cdc_data[nearest['state']['name']])"} +{"i": 504, "got": "def status_by_state(self, state: str) -> dict:\n \"\"\"pass\"\"\"\n data = await self.raw_cdc_data()\n try:\n info = next((v for k, v in data.items() if state in k))\n except StopIteration:\n return {}\n return adjust_status(info)"} +{"i": 505, "got": "def insert(self, **kwargs):\n \"\"\"pass\"\"\"\n if self.is_valid:\n before = self.before_insert()\n if before:\n return before\n try:\n self._document['_id'] = self.insert_one(self._document)\n self.after_insert()\n return self._document\n except PyMongoException as exc:\n return PyMongoError(error_message=exc.details.get('errmsg', exc.details.get('err', 'PyMongoError.')), operation='insert', collection=type(self).__name__, document=self._document)\n else:\n return self._errors"} +{"i": 506, "got": "def update(self, **kwargs):\n \"\"\"pass\"\"\"\n if self.is_valid:\n if '_id' in self._document:\n to_update = self.find_one({'_id': self._id})\n if to_update:\n before = self.before_update(old=to_update)\n return before if before else self.replace_one({'_id': self._id}, self._document), self.after_update(old=to_update), self._document\n else:\n return DocumentNotFoundError(type(self).__name__, self._id)\n else:\n return UnidentifiedDocumentError(type(self).__name__, self._document)\n else:\n return self._errors"} +{"i": 507, "got": "def delete(self, **kwargs):\n \"\"\"pass\"\"\"\n if self.is_valid:\n if '_id' in self._document:\n to_delete = self.find_one({'_id': self._id})\n if to_delete:\n before = self.before_delete()\n return before if before else PyMongoError(error_message=exc.details.get('errmsg', exc.details.get('err', 'PyMongoError.')), operation='delete', collection=type(self).__name__, document=self._document)\n else:\n return DocumentNotFoundError(type(self).__name__, self._id)\n else:\n return UnidentifiedDocumentError(type(self).__name__, self._document)"} +{"i": 508, "got": "def find_one(cls, filter=None, *args, **kwargs):\n \"\"\"pass\"\"\"\n return cls.collection.find_one(filter, *args, **kwargs)"} +{"i": 509, "got": "def find(cls, *args, **kwargs):\n \"\"\"pass\"\"\"\n return list(cls.collection.find(*args, **kwargs))"} +{"i": 510, "got": "def aggregate(cls, pipeline=None, **kwargs):\n \"\"\"pass\"\"\"\n return list(cls.collection.aggregate(pipeline or [], **kwargs))"} +{"i": 511, "got": "def in_file(self, fn: str) -> Iterator[Statement]:\n \"\"\"pass\"\"\"\n yield from self.__file_to_statements.get(fn, [])"} +{"i": 512, "got": "def at_line(self, line: FileLine) -> Iterator[Statement]:\n \"\"\"pass\"\"\"\n num = line.num\n for stmt in self.in_file(line.filename):\n if stmt.location.start.line == num:\n yield stmt"} +{"i": 513, "got": "def wrap(text, width=70, **kwargs):\n \"\"\"pass\"\"\"\n w = ParagraphWrapper(width=width, **kwargs)\n return w.wrap(text)"} +{"i": 514, "got": "def fill(text, width=70, **kwargs):\n \"\"\"pass\"\"\"\n w = ParagraphWrapper(width=width, **kwargs)\n return w.fill(text)"} +{"i": 515, "got": "def split(cls, text):\n \"\"\"pass\"\"\"\n result = [line.strip('\\n') for line in cls.parasep_re.split(text)]\n if result == ['', '']:\n result = ['']\n return result"} +{"i": 516, "got": "def wrap(self, text):\n \"\"\"pass\"\"\"\n lines = []\n linewrap = partial(textwrap.TextWrapper.wrap, self)\n for para in self.split(text):\n lines.extend(linewrap(para))\n lines.append('')\n lines = lines[:-1]\n return lines"} +{"i": 517, "got": "def getSenderNumberMgtURL(self, CorpNum, UserID):\n \"\"\"pass\"\"\"\n result = self._httpget('/FAX/?TG=SENDER', CorpNum, UserID)\n return result.url"} +{"i": 518, "got": "def getUnitCost(self, CorpNum):\n \"\"\"pass\"\"\"\n result = self._httpget('/FAX/UnitCost', CorpNum)\n return int(result.unitCost)"} +{"i": 519, "got": "def getFaxResult(self, CorpNum, ReceiptNum, UserID=None):\n \"\"\"pass\"\"\"\n if ReceiptNum == None or len(ReceiptNum) != 18:\n raise PopbillException(-99999999, '\uc811\uc218\ubc88\ud638\uac00 \uc62c\ubc14\ub974\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.')\n return self._httpget('/FAX/' + ReceiptNum, CorpNum, UserID)"} +{"i": 520, "got": "def getFaxResultRN(self, CorpNum, RequestNum, UserID=None):\n \"\"\"pass\"\"\"\n if RequestNum == None or RequestNum == '':\n raise PopbillException(-99999999, '\uc694\uccad\ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n return self._httpget('/FAX/Get/' + RequestNum, CorpNum, UserID)"} +{"i": 521, "got": "def sendFax(self, CorpNum, SenderNum, ReceiverNum, ReceiverName=None, FilePath=None, ReserveDT=None, UserID=False, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n receivers = []\n receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))\n return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)"} +{"i": 522, "got": "def sendFax_multi(self, CorpNum, SenderNum=None, Receiver=None, FilePath=None, ReserveDT=False, UserID=None, SenderName=None, adsYN=None, title=None, RequestNum=None):\n \"\"\"pass\"\"\"\n if SenderNum == None or SenderNum == '':\n raise PopbillException(-99999999, '\ubc1c\uc2e0\uc790 \ubc88\ud638\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n elif Receiver == None:\n raise PopbillException(-99999999, '\uc218\uc2e0\uc790 \uc815\ubcf4\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(Receiver) is str and (not type(Receiver) is FaxReceiver) and (not type(Receiver) is list):\n raise PopbillException(-99999999, \"'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.\")\n elif FilePath == None:\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uacbd\ub85c\uac00 \uc785\ub825\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.')\n if not type(FilePath) is str and (not type(FilePath) is list):\n raise PopbillException(-99999999, '\ubc1c\uc2e0 \ud30c\uc77c\uc740 \ud30c\uc77c\uacbd\ub85c \ub610\ub294 \uacbd\ub85c\ubaa9\ub85d\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n elif type(FilePath) is list:\n if len(FilePath) < 1 or len(FilePath) > 20:\n raise PopbillException(-99999999, '\ud30c\uc77c\uc740 1\uac1c \uc774\uc0c1, 20\uac1c \uae4c\uc9c0 \uc804\uc1a1 \uac00\ub2a5\ud569\ub2c8\ub2e4.')\n req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}\n if type(Receiver) is str:\n Receiver = FaxReceiver(receiveNum=Receiver)\n if type(Receiver) is FaxReceiver:\n Receiver = [Receiver]\n if adsYN:\n req['adsYN'] = True\n for r in Receiver:\n req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})\n if ReserveDT != None:\n req['sndDT'] = ReserveDT\n if title != None:\n req['title'] = title\n if RequestNum != None:\n req['requestNum'] = RequestNum\n postData = self._stringtify(req)\n if type(FilePath) is str:\n FilePath = [FilePath]\n files = []\n for filePath in FilePath:\n with open(filePath, 'rb') as f:\n files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))\n result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)\n return result.receiptNum"} +{"i": 523, "got": "def model_node(**kwargs):\n \"\"\"pass\"\"\"\n kwargs.setdefault('default', {})\n\n def decorator(model):\n return types.ModelType(model, **kwargs)\n return decorator"} +{"i": 524, "got": "def status_by_coordinates(self, latitude: float, longitude: float) -> dict:\n \"\"\"pass\"\"\"\n return await self.nearest_by_coordinates(latitude, longitude)"} +{"i": 525, "got": "def status_by_zip(self, zip_code: str) -> dict:\n \"\"\"pass\"\"\"\n try:\n location = next((d for d in self.user_reports() if d['zip'] == zip_code))\n except StopIteration:\n return {}\n return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))"} +{"i": 526, "got": "def print_request(request):\n \"\"\"pass\"\"\"\n print('{}\\n{}\\n{}\\n\\n{}'.format('-----------START-----------', request.method + ' ', request.url, '\\n'.join(('{}: {}'.format(k, v) for k, v in request.headers.items()))))"} +{"i": 527, "got": "def filter_validate_schemas(get_response, params):\n \"\"\"pass\"\"\"\n request_schema = params.get('request_schema')\n if request_schema is None:\n return get_response\n\n def _convert_params(schema, data):\n for sc in schema.fields.values():\n name = sc.serialized_name or sc.name\n val = data.getlist(name)\n if val is not None:\n if len(val) == 1 and (not isinstance(sc, ListType)):\n val = val[0]\n data[name] = val\n\n def decorated_filter(request, *args, **kwargs):\n data = {'headers': CIDict(request.headers), 'path': request.app.router.get(request)[2], 'params': RequestParameters(request.args), 'body': {}}\n if request.body:\n if request.form:\n data['body'] = RequestParameters(request.form)\n else:\n data['body'] = deepcopy(request.json)\n if hasattr(request_schema, 'body') and request.form:\n _convert_params(request_schema.body, data['body'])\n if hasattr(request_schema, 'params') and data['params']:\n _convert_params(request_schema.params, data['params'])\n try:\n model = request_schema(data, strict=False, validate=False)\n model.validate()\n request.validated = model.to_native()\n except BaseError as e:\n raise ValidationErrors(e.to_primitive())\n return await get_response(request, *args, **kwargs)\n return decorated_filter"} +{"i": 528, "got": "def filter_validate_response(get_response, params):\n \"\"\"pass\"\"\"\n schema = params.get('response_schema')\n\n def decorated_filter(request, *args, **kwargs):\n response = await get_response(request, *args, **kwargs)\n if isinstance(response, HTTPResponse) and (not isinstance(response, Response)):\n return response\n if not isinstance(response, Response):\n raise TypeError('response is not an instance of rafter.http.Response.')\n if schema:\n data = {'body': response.data, 'headers': response.headers}\n try:\n model = schema(data, strict=False, validate=False)\n model.validate()\n result = model.to_primitive()\n response.body = result.get('body', None)\n response.headers.update(result.get('headers', {}))\n except BaseError as e:\n log.exception(e)\n abort(500, 'Wrong data output')\n return response\n return decorated_filter"} +{"i": 529, "got": "def _write_int(fname, data, append=True):\n \"\"\"pass\"\"\"\n data_ex = pexdoc.exh.addex(ValueError, 'There is no data to save to file')\n fos_ex = pexdoc.exh.addex(OSError, 'File *[fname]* could not be created: *[reason]*')\n data_ex(len(data) == 0 or (len(data) == 1 and len(data[0]) == 0))\n try:\n pmisc.make_dir(fname)\n mode = 'w' if append is False else 'a'\n if sys.hexversion < 50331648:\n with open(fname, mode) as file_handle:\n csv.writer(file_handle, delimiter=',').writerows(data)\n else:\n with open(fname, mode, newline='') as file_handle:\n csv.writer(file_handle, delimiter=',').writerows(data)\n except (IOError, OSError) as eobj:\n fos_ex(True, _MF('fname', fname, 'reason', eobj.strerror))"} +{"i": 530, "got": "def revdocs2reverts(rev_docs, radius=defaults.RADIUS, use_sha1=False, resort=False, verbose=False):\n \"\"\"pass\"\"\"\n page_rev_docs = groupby(rev_docs, lambda rd: rd.get('page'))\n for page_doc, rev_docs in page_rev_docs:\n if verbose:\n sys.stderr.write(page_doc.get('title') + ': ')\n sys.stderr.flush()\n if resort:\n if verbose:\n sys.stderr.write('(sorting) ')\n sys.stderr.flush()\n rev_docs = sorted(rev_docs, key=lambda r: (r.get('timestamp'), r.get('id')))\n detector = Detector(radius=radius)\n for rev_doc in rev_docs:\n if not use_sha1 and 'text' not in rev_doc:\n logger.warn(\"Skipping {0}: 'text' field not found in {0}\".format(rev_doc['id'], rev_doc))\n continue\n if use_sha1:\n checksum = rev_doc.get('sha1') or DummyChecksum()\n elif 'text' in rev_doc:\n text_bytes = bytes(rev_doc['text'], 'utf8', 'replace')\n checksum = hashlib.sha1(text_bytes).digest()\n revert = detector.process(checksum, rev_doc)\n if revert:\n yield revert.to_json()\n if verbose:\n sys.stderr.write('r')\n sys.stderr.flush()\n elif verbose:\n sys.stderr.write('.')\n sys.stderr.flush()\n if verbose:\n sys.stderr.write('\\n')\n sys.stderr.flush()"} +{"i": 531, "got": "def dsort(fname, order, has_header=True, frow=0, ofname=None):\n \"\"\"pass\"\"\"\n ofname = fname if ofname is None else ofname\n obj = CsvFile(fname=fname, has_header=has_header, frow=frow)\n obj.dsort(order)\n obj.write(fname=ofname, header=has_header, append=False)"} +{"i": 532, "got": "def main() -> None:\n \"\"\"pass\"\"\"\n logging.basicConfig(level=logging.INFO)\n with ClientSession() as websession:\n try:\n client = Client(websession)\n user_coord_resp = await client.user_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('User data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, user_coord_resp)\n user_zip_resp = await client.user_reports.status_by_zip(ZIP_CODE)\n _LOGGER.info('User data by ZIP code (%s): %s', ZIP_CODE, user_zip_resp)\n cdc_coord_resp = await client.cdc_reports.status_by_coordinates(LATITUDE, LONGITUDE)\n _LOGGER.info('CDC data by latitude/longitude (%s, %s): %s', LATITUDE, LONGITUDE, cdc_coord_resp)\n cdc_state_resp = await client.cdc_reports.status_by_state(STATE)\n _LOGGER.info('CDC data by state name (%s): %s', STATE, cdc_state_resp)\n except FluNearYouError as err:\n print(err)"} +{"i": 533, "got": "def call(cls, method, params=None, timeout=600):\n \"\"\"pass\"\"\"\n params = [] if params is None else params\n return cls.make_request(SERVER_ADDRESS, method, params, timeout=timeout)"} +{"i": 534, "got": "def concatenate(fname1, fname2, dfilter1=None, dfilter2=None, has_header1=True, has_header2=True, frow1=0, frow2=0, ofname=None, ocols=None):\n \"\"\"pass\"\"\"\n iro = pexdoc.exh.addex(RuntimeError, 'Files have different number of columns')\n iom = pexdoc.exh.addex(RuntimeError, 'Number of columns in data files and output columns are different')\n obj1 = CsvFile(fname=fname1, dfilter=dfilter1, has_header=has_header1, frow=frow1)\n obj2 = CsvFile(fname=fname2, dfilter=dfilter2, has_header=has_header2, frow=frow2)\n ofname = fname1 if ofname is None else ofname\n if ocols is None:\n if has_header1:\n ocols = [obj1.header()] if obj1.cfilter is None else [obj1.cfilter]\n elif ocols is None:\n if has_header2:\n ocols = [obj2.header()] if obj2.cfilter is None else [obj2.cfilter]\n else:\n if iom(obj1.cfilter is not None and len(obj1.cfilter) != len(ocols)):\n ocols = [ocols]\n iro(_C(obj1.cfilter, obj2.cfilter) and (len(obj1.cfilter) != len(obj2.cfilter)))\n data = ocols + obj1.data(filtered=True) + obj2.data(filtered=True)\n write(fname=ofname, data=data, append=False)"} +{"i": 535, "got": "def resource(self, uri, methods=frozenset({'GET'}), host=None, strict_slashes=None, stream=False, version=None, name=None, **kwargs):\n \"\"\"pass\"\"\"\n if strict_slashes is None:\n strict_slashes = self.strict_slashes\n\n def decorator(handler):\n self.resources.append((FutureRoute(handler, uri, methods, host, strict_slashes, stream, version, name), kwargs))\n return handler\n return decorator"} +{"i": 536, "got": "def add_resource(self, handler, uri, methods=frozenset({'GET'}), host=None, strict_slashes=None, version=None, name=None, **kwargs):\n \"\"\"pass\"\"\"\n self.resource(uri=uri, methods=methods, host=host, strict_slashes=strict_slashes, version=version, name=name, **kwargs)(handler)"} +{"i": 537, "got": "def in_file(self, fn: str) -> Iterator[InsertionPoint]:\n \"\"\"pass\"\"\"\n logger.debug('finding insertion points in file: %s', fn)\n yield from self.__file_insertions.get(fn, [])"} +{"i": 538, "got": "def at_line(self, line: FileLine) -> Iterator[InsertionPoint]:\n \"\"\"pass\"\"\"\n logger.debug('finding insertion points at line: %s', str(line))\n filename = line.filename\n line_num = line.num\n for ins in self.in_file(filename):\n if line_num == ins.location.line:\n logger.debug('found insertion point at line [%s]: %s', str(line), ins)\n yield ins"} +{"i": 539, "got": "def _doAtomicFileCreation(filePath):\n \"\"\"pass\"\"\"\n try:\n _os.close(_os.open(filePath, _os.O_CREAT | _os.O_EXCL))\n return True\n except OSError as e:\n if e.errno == _errno.EEXIST:\n return False\n else:\n raise e"} +{"i": 540, "got": "def findNextFile(folder='.', prefix=None, suffix=None, fnameGen=None, base=0, maxattempts=10):\n \"\"\"pass\"\"\"\n expFolder = _os.path.expanduser(_os.path.expandvars(folder))\n return _findNextFile(expFolder, prefix, suffix, fnameGen, base, maxattempts, 0)"} +{"i": 541, "got": "def _run(passedArgs=None, stderr=None, stdout=None, exitFn=None):\n \"\"\"pass\"\"\"\n description = 'Finds the next available file-name in a sequence.\\n\\n This program will create a file of zero size and will output the path to it\\n on STDOUT. No files which exist will be altered in this operation and\\n concurrent invocations of this program will return separate files. In case\\n of conflict, this program will attempt to generate a new file name up to\\n \\'maxattempts\\' number of times before failing. (See --max-attempts)\\n\\n The sequence will start from the base argument (See --base, default: 0).\\n\\n This program will look for the next file in the sequence ignoring any gaps.\\n Hence, if the files \"a.0.txt\" and \"a.3.txt\" exist, then the next file\\n returned will be \"a.4.txt\" when called with prefix=\"a.\" and suffix=\".txt\".\\n\\n Returns:\\n Path of the file which follows the provided pattern and can be opened\\n for writing.\\n\\n Otherwise, it prints an error (wrong path, drive full, illegal\\n character in filename, etc.) to stderr and exits with a non-zero error\\n code.\\n \"\"\"\n argParser = _argparse.ArgumentParser(description=description, formatter_class=_argparse.RawTextHelpFormatter)\n argParser.add_argument('prefix', help='Prefix for the sequence of files.')\n argParser.add_argument('suffix', help='Suffix for the sequence of files.', nargs='?', default='')\n argParser.add_argument('folder', help='The folder where the file will be created.', nargs='?', default=_os.getcwd())\n argParser.add_argument('-m', '--max-attempts', help='Number of attempts to make before giving up.', default=10)\n argParser.add_argument('-b', '--base', help='From where to start counting (default: 0).', default=0)\n passedArgs = passedArgs if passedArgs is not None else _sys.argv[1:]\n args = argParser.parse_args(passedArgs)\n stdout = _sys.stdout if stdout is None else stdout\n stderr = _sys.stderr if stderr is None else stderr\n try:\n nextFile = findNextFile(args.folder, prefix=args.prefix, suffix=args.suffix, maxattempts=args.max_attempts, base=args.base)\n stdout.write(nextFile + '\\n')\n except OSError as e:\n stderr.write(_os.strerror(e.errno) + '\\n')\n _sys.exit(e.errno)"} +{"i": 542, "got": "def _errstr(value):\n \"\"\"pass\"\"\"\n value = str(value)\n if len(value) > MAX_ERROR_STR_LEN:\n return value[:MAX_ERROR_STR_LEN] + '...'\n else:\n return value"} +{"i": 543, "got": "def _getStrippedValue(value, strip):\n \"\"\"pass\"\"\"\n if strip is None:\n value = value.strip()\n elif isinstance(strip, str):\n value = value.strip(strip)\n elif strip is False:\n pass\n return value"} +{"i": 544, "got": "def _raiseValidationException(standardExcMsg, customExcMsg=None):\n \"\"\"pass\"\"\"\n if customExcMsg is None:\n raise ValidationException(str(standardExcMsg))\n else:\n raise ValidationException(str(customExcMsg))"} +{"i": 545, "got": "def _prevalidationCheck(value, blank, strip, allowlistRegexes, blocklistRegexes, excMsg=None):\n \"\"\"pass\"\"\"\n value = str(value)\n value = _getStrippedValue(value, strip)\n if not blank and value == '':\n _raiseValidationException(_('Blank values are not allowed.'), excMsg)\n elif blank and value == '':\n return (True, value)\n if allowlistRegexes is not None:\n for regex in allowlistRegexes:\n if isinstance(regex, re.Pattern):\n if regex.search(value, re.IGNORECASE) is not None:\n return (True, value)\n else:\n if re.search(regex, value, re.IGNORECASE) is not None:\n return (True, value)\n elif blocklistRegexes is not None:\n for blocklistRegexItem in blocklistRegexes:\n if isinstance(blocklistRegexItem, str):\n regex, response = (blocklistRegexItem, DEFAULT_BLOCKLIST_RESPONSE)\n else:\n regex, response = blocklistRegexItem\n if isinstance(regex, re.Pattern) and regex.search(value, re.IGNORECASE) is not None:\n _raiseValidationException(response, excMsg)\n elif re.search(regex, value, re.IGNORECASE) is not None:\n _raiseValidationException(response, excMsg)\n return (False, value)"} +{"i": 546, "got": "def _validateGenericParameters(blank, strip, allowlistRegexes, blocklistRegexes):\n \"\"\"pass\"\"\"\n if not isinstance(blank, bool):\n raise PySimpleValidateException('blank argument must be a bool')\n if not isinstance(strip, (bool, str, type(None))):\n raise PySimpleValidateException('strip argument must be a bool, None, or str')\n if allowlistRegexes is None:\n allowlistRegexes = []\n try:\n len(allowlistRegexes)\n except:\n raise PySimpleValidateException('allowlistRegexes must be a sequence of regex_strs')\n for response in allowlistRegexes:\n if not isinstance(response[0], str):\n raise PySimpleValidateException('allowlistRegexes must be a sequence of regex_strs')\n if blocklistRegexes is None:\n blocklistRegexes = []\n try:\n len(blocklistRegexes)\n except:\n raise PySimpleValidateException('blocklistRegexes must be a sequence of (regex_str, str) tuples or regex_strs')\n for response in blocklistRegexes:\n if not isinstance(response, str):\n if len(response) != 2:\n raise PySimpleValidateException('blocklistRegexes must be a sequence of (regex_str, str) tuples or regex_strs')\n if not (isinstance(response[0], str) and isinstance(response[1], str)):\n raise PySimpleValidateException('blocklistRegexes must be a sequence of (regex_str, str) tuples or regex_strs')"} +{"i": 547, "got": "def _validateParamsFor_validateNum(min=None, max=None, lessThan=None, greaterThan=None):\n \"\"\"pass\"\"\"\n if min is not None and greaterThan is not None:\n raise PySimpleValidateException('only one argument for min or greaterThan can be passed, not both')\n elif max is not None and lessThan is not None:\n raise PySimpleValidateException('only one argument for max or lessThan can be passed, not both')\n if min is not None and max is not None and (min > max):\n raise PySimpleValidateException('the min argument must be less than or equal to the max argument')\n elif min is not None and lessThan is not None and (min >= lessThan):\n raise PySimpleValidateException('the min argument must be less than the lessThan argument')\n elif max is not None and greaterThan is not None and (max <= greaterThan):\n raise PySimpleValidateException('the max argument must be greater than the greaterThan argument')\n for name, val in [('min', min), ('max', max), ('lessThan', lessThan), ('greaterThan', greaterThan)]:\n if not isinstance(val, (int, float, type(None))):\n raise PySimpleValidateException(name + ' argument must be int, float, or NoneType')"} +{"i": 548, "got": "def filter_transform_response(get_response, params):\n \"\"\"pass\"\"\"\n\n async def decorated_filter(request, *args, **kwargs):\n response = await get_response(request, *args, **kwargs)\n if isinstance(response, HTTPResponse) and (not isinstance(response, Response)):\n return response\n if not isinstance(response, Response):\n response = Response(response)\n return response\n return decorated_filter"} +{"i": 549, "got": "def initialize(self, maxsize, history=None):\n \"\"\"pass\"\"\"\n super().__init__()\n self.maxsize = int(maxsize)\n self.history = deque(maxlen=self.maxsize)\n if history is not None:\n for key, value in history:\n self.insert(key, value)"} +{"i": 550, "got": "def insert(self, key, value):\n \"\"\"pass\"\"\"\n if len(self.history) == self.maxsize:\n expectorate = self.history[0]\n else:\n expectorate = None\n self.history.append((key, value))\n if key in self:\n super().__getitem__(key).append(value)\n else:\n super().__setitem__(key, [value])\n if expectorate is not None:\n old_key, old_value = expectorate\n super().__getitem__(old_key).pop(0)\n if len(super().__getitem__(old_key)) == 0:\n super().__delitem__(old_key)\n return (old_key, old_value)"} +{"i": 551, "got": "def up_to(self, key):\n \"\"\"pass\"\"\"\n for okey, ovalue in reversed(self.history):\n if okey == key:\n break\n yield ovalue"} +{"i": 552, "got": "def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n page_id = int(page_id) if page_id is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if page_id is None:\n page_id = get_page_id(session, rev_id)\n current_and_past_revs = list(n_edits_before(session, rev_id, page_id, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, page_id))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_edits_after(session, rev_id + 1, page_id, radius, {before}, rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 553, "got": "def check_deleted(session, rev_id, title=None, timestamp=defaults.RADIUS, radius=None, before=None, window=None, rvprop=None):\n \"\"\"pass\"\"\"\n rev_id = int(rev_id)\n radius = int(radius)\n if radius < 1:\n raise TypeError('invalid radius. Expected a positive integer.')\n title = str(title) if title is not None else None\n before = Timestamp(before) if before is not None else None\n rvprop = set(rvprop) if rvprop is not None else set()\n if title is None or timestamp is None:\n title, timestamp = get_deleted_title_and_timestamp(session, rev_id)\n current_and_past_revs = list(n_deleted_edits_before(session, rev_id, title, timestamp, radius + 1, {'sha1', 'timestamp', 'ids'} | rvprop))\n if len(current_and_past_revs) < 1:\n raise KeyError('Revision {0} not found in page {1}.'.format(rev_id, title))\n current_rev, past_revs = (current_and_past_revs[-1], current_and_past_revs[:-1])\n if window is not None and before is None:\n before = Timestamp(current_rev['timestamp']) + window\n future_revs = list(n_deleted_edits_after(session, rev_id + 1, title, timestamp, radius, before, {'sha1', 'timestamp', 'ids'} | rvprop))\n return build_revert_tuple(rev_id, past_revs, current_rev, future_revs, radius)"} +{"i": 554, "got": "def get_commits(repo_dir, old_commit, new_commit, hide_merges=True):\n \"\"\"pass\"\"\"\n repo = Repo(repo_dir)\n commits = repo.iter_commits(rev='{0}..{1}'.format(old_commit, new_commit))\n if hide_merges:\n return [x for x in commits if not x.summary.startswith('Merge ')]\n else:\n return list(commits)"} +{"i": 555, "got": "def get_commit_url(repo_url):\n \"\"\"pass\"\"\"\n if 'github.com' in repo_url:\n return repo_url[:-4] if repo_url.endswith('.git') else repo_url\n elif 'git.openstack.org' in repo_url:\n uri = '/'.join(repo_url.split('/')[-2:])\n return 'https://github.com/{0}'.format(uri)\n else:\n return repo_url"} +{"i": 556, "got": "def get_projects(osa_repo_dir, commit):\n \"\"\"pass\"\"\"\n repo = Repo(osa_repo_dir)\n checkout(repo, commit)\n yaml_files = glob.glob('{0}/playbooks/defaults/repo_packages/*.yml'.format(osa_repo_dir))\n yaml_parsed = []\n for yaml_file in yaml_files:\n with open(yaml_file, 'r') as f:\n yaml_parsed.append(yaml.load(f))\n merged_dicts = {k: v for d in yaml_parsed for k, v in d.items()}\n return normalize_yaml(merged_dicts)"} +{"i": 557, "got": "def checkout(repo, ref):\n \"\"\"pass\"\"\"\n if ref in repo.branches:\n log.warn('Removing local branch {b} for repo {r}'.format(b=ref, r=repo))\n repo.head.reset(index=True, working_tree=True)\n repo.git.checkout(repo.head.commit.hexsha)\n repo.delete_head(ref, '--force')\n log.info('Checkout out repo {repo} to ref {ref}'.format(repo=repo, ref=ref))\n repo.head.reset(index=True, working_tree=True)\n repo.git.checkout(ref)\n repo.head.reset(index=True, working_tree=True)\n sha = repo.head.commit.hexsha\n log.info('Current SHA for repo {repo} is {sha}'.format(repo=repo, sha=sha))"} +{"i": 558, "got": "def get_roles(osa_repo_dir, commit, role_requirements):\n \"\"\"pass\"\"\"\n repo = Repo(osa_repo_dir)\n checkout(repo, commit)\n log.info('Looking for file {f} in repo {r}'.format(r=osa_repo_dir, f=role_requirements))\n filename = '{0}/{1}'.format(osa_repo_dir, role_requirements)\n with open(filename, 'r') as f:\n roles_yaml = yaml.load(f)\n return normalize_yaml(roles_yaml)"} +{"i": 559, "got": "def make_osa_report(repo_dir, old_commit, new_commit, args):\n \"\"\"pass\"\"\"\n update_repo(repo_dir, args.osa_repo_url, args.update)\n validate_commits(repo_dir, [old_commit, new_commit])\n validate_commit_range(repo_dir, old_commit, new_commit)\n commits = get_commits(repo_dir, old_commit, new_commit)\n template_vars = {'args': args, 'repo': 'openstack-ansible', 'commits': commits, 'commit_base_url': get_commit_url(args.osa_repo_url), 'old_sha': old_commit, 'new_sha': new_commit}\n return render_template('offline-header.j2', template_vars)"} +{"i": 560, "got": "def _homogenize_data_filter(dfilter):\n \"\"\"pass\"\"\"\n if isinstance(dfilter, tuple) and len(dfilter) == 1:\n dfilter = (dfilter[0], None)\n if dfilter is None or dfilter == (None, None) or dfilter == (None,):\n dfilter = (None, None)\n elif isinstance(dfilter, dict):\n dfilter = (dfilter, None)\n elif not (isinstance(dfilter, (list, str)) and (not (isinstance(dfilter, bool) and isinstance(dfilter, int)))) or (isinstance(dfilter[0], dict) or (filter is None and isinstance(dfilter[1], dict))):\n pass\n else:\n dfilter = (dfilter[1], dfilter[0])\n return dfilter"} +{"i": 561, "got": "def _tofloat(obj):\n \"\"\"pass\"\"\"\n if 'inf' in obj.lower().strip():\n return obj\n try:\n return int(obj)\n except ValueError:\n try:\n return float(obj)\n except ValueError:\n return obj"} +{"i": 562, "got": "def _in_header(self, col):\n \"\"\"pass\"\"\"\n if not self._has_header:\n icol_ex = pexdoc.exh.addex(RuntimeError, 'Invalid column specification')\n hnf_ex = pexdoc.exh.addex(ValueError, 'Column *[column_identifier]* not found')\n col_list = [col] if isinstance(col, (str, int)) else col\n for col in col_list:\n edata = {'field': 'column_identifier', 'value': col}\n if not self._has_header:\n icol_ex(not isinstance(col, int))\n hnf_ex(col < 0 or col > len(self._header) - 1, edata)\n else:\n hnf_ex(isinstance(col, int) and (col < 0 or col > self._data_cols) or (isinstance(col, str) and col.upper() not in self._header_upper), edata)\n return col_list"} +{"i": 563, "got": "def with_reactor(*dec_args, **dec_kwargs):\n \"\"\"pass\"\"\"\n if len(dec_args) == 1 and callable(dec_args[0]) and (not dec_kwargs):\n callee = dec_args[0]\n dec_args = ()\n dec_kwargs = {}\n\n @functools.wraps(callee)\n def wrapper(*call_args, **call_kwargs):\n return _twisted_test_sync(callee, call_args, call_kwargs)\n return wrapper\n else:\n\n def decorator(callee):\n\n @functools.wraps(callee)\n def wrapper(*call_args, **call_kwargs):\n return _twisted_test_sync(callee, call_args, call_kwargs, *dec_args, **dec_kwargs)\n return wrapper\n return decorator"} +{"i": 564, "got": "def _ensure_reactor_running():\n \"\"\"pass\"\"\"\n if not reactor.running:\n signal_registrations = []\n\n def signal_capture(*args, **kwargs):\n signal_registrations.append((orig_signal, args, kwargs))\n\n def set_wakeup_fd_capture(*args, **kwargs):\n signal_registrations.append((orig_set_wakeup_fd, args, kwargs))\n orig_signal = signal.signal\n signal.signal = signal_capture\n orig_set_wakeup_fd = signal.set_wakeup_fd\n signal.set_wakeup_fd = set_wakeup_fd_capture\n reactor_thread = threading.Thread(target=reactor.run, name='reactor')\n reactor_thread.daemon = True\n reactor_thread.start()\n while not reactor.running:\n time.sleep(0.01)\n time.sleep(0.01)\n signal.signal = orig_signal\n signal.set_wakeup_fd = orig_set_wakeup_fd\n for func, args, kwargs in signal_registrations:\n func(*args, **kwargs)"} +{"i": 565, "got": "def _timeoutDeferred(deferred, timeout):\n \"\"\"pass\"\"\"\n delayedCall = reactor.callLater(timeout, deferred.cancel)\n\n def gotResult(result):\n if delayedCall.active():\n delayedCall.cancel()\n return result\n deferred.addBoth(gotResult)"} +{"i": 566, "got": "def _get_json(value):\n \"\"\"pass\"\"\"\n if hasattr(value, 'replace'):\n value = value.replace('\\n', ' ')\n try:\n return json.loads(value)\n except json.JSONDecodeError:\n if hasattr(value, 'replace'):\n value = value.replace('\"', '\\\\\"')\n return json.loads('\"{}\"'.format(value))"} +{"i": 567, "got": "def save_list(key, *values):\n \"\"\"pass\"\"\"\n return json.dumps({key: [_get_json(value) for value in values]})"} +{"i": 568, "got": "def save_file(key, file_path, *refs):\n \"\"\"pass\"\"\"\n if not os.path.isfile(file_path):\n return error(\"Output '{}' set to a missing file: '{}'.\".format(key, file_path))\n result = {key: {'file': file_path}}\n if refs:\n missing_refs = [ref for ref in refs if (not os.path.isfile(ref)) and (not os.path.isdir(ref))]\n if len(missing_refs) > 0:\n return error(\"Output '{}' set to missing references: '{}'.\".format(key, ', '.join(missing_refs)))\n result[key]['refs'] = refs\n return json.dumps(result)"} +{"i": 569, "got": "def save_file_list(key, *files_refs):\n \"\"\"pass\"\"\"\n file_list = []\n for file_refs in files_refs:\n if ':' in file_refs:\n try:\n file_name, refs = file_refs.split(':')\n except ValueError as e:\n return error(\"Only one colon ':' allowed in file-refs specification.\")\n else:\n file_name, refs = (file_refs, None)\n if not os.path.isfile(file_name):\n return error(\"Output '{}' set to a missing file: '{}'.\".format(key, file_name))\n file_obj = {'file': file_name}\n if refs:\n refs = [ref_path.strip() for ref_path in refs.split(',')]\n missing_refs = [ref for ref in refs if not os.path.isfile(ref) and (not os.path.isdir(ref))]\n if len(missing_refs) > 0:\n return error(\"Output '{}' set to missing references: '{}'.\".format(key, ', '.join(missing_refs)))\n file_obj['refs'] = refs\n file_list.append(file_obj)\n return json.dumps({key: file_list})"} +{"i": 570, "got": "def save_dir(key, dir_path, *refs):\n \"\"\"pass\"\"\"\n if not os.path.isdir(dir_path):\n return error(\"Output '{}' set to a missing directory: '{}'.\".format(key, dir_path))\n result = {key: {'dir': dir_path}}\n if refs:\n missing_refs = [ref for ref in refs if (not os.path.isfile(ref)) and (not os.path.isdir(ref))]\n if len(missing_refs) > 0:\n return error(\"Output '{}' set to missing references: '{}'.\".format(key, ', '.join(missing_refs)))\n result[key]['refs'] = refs\n return json.dumps(result)"} +{"i": 571, "got": "def save_dir_list(key, *dirs_refs):\n \"\"\"pass\"\"\"\n dir_list = []\n for dir_refs in dirs_refs:\n if ':' in dir_refs:\n try:\n dir_path, refs = dir_refs.split(':')\n except ValueError as e:\n return error(\"Only one colon ':' allowed in dir-refs specification.\")\n else:\n dir_path, refs = (dir_refs, None)\n if not os.path.isdir(dir_path):\n return error(\"Output '{}' set to a missing directory: '{}'.\".format(key, dir_path))\n dir_obj = {'dir': dir_path}\n if refs:\n refs = [ref_path.strip() for ref_path in refs.split(',')]\n missing_refs = [ref for ref in refs if not os.path.isfile(ref) and (not os.path.isdir(ref))]\n if len(missing_refs) > 0:\n return error(\"Output '{}' set to missing references: '{}'.\".format(key, ', '.join(missing_refs)))\n dir_obj['refs'] = refs\n dir_list.append(dir_obj)\n return json.dumps({key: dir_list})"} +{"i": 572, "got": "def n_day(date_string):\n \"\"\"pass\"\"\"\n today = datetime.date.today()\n match = re.match('(\\\\d{1,3}|a) days? ago', date_string)\n groups = match.groups()\n if groups:\n decrement = groups[0]\n if decrement == 'a':\n decrement = 1\n return today - datetime.timedelta(days=int(decrement))"} +{"i": 573, "got": "def encloses(self, location: FileLocation) -> Optional[FunctionDesc]:\n \"\"\"pass\"\"\"\n for func in self.in_file(location.filename):\n if location in func.location:\n return func\n return None"} +{"i": 574, "got": "def in_file(self, filename: str) -> Iterator[FunctionDesc]:\n \"\"\"pass\"\"\"\n yield from self.__filename_to_functions.get(filename, [])"} +{"i": 575, "got": "def parse_config(args):\n \"\"\"pass\"\"\"\n config_path = path.expanduser(args.config_file)\n if not path.exists(config_path):\n if args.config_file != DEFAULT_JOURNAL_RC:\n print(\"journal: error: config file '\" + args.config_file + \"' not found\")\n sys.exit()\n else:\n return DEFAULT_JOURNAL\n config = ConfigParser.SafeConfigParser({'journal': {'default': '__journal'}, '__journal': {'location': DEFAULT_JOURNAL}})\n config.read(config_path)\n journal_location = config.get(config.get('journal', 'default'), 'location')\n if args.journal:\n journal_location = config.get(args.journal, 'location')\n return journal_location"} +{"i": 576, "got": "def record_entries(journal_location, entries):\n \"\"\"pass\"\"\"\n check_journal_dest(journal_location)\n current_date = datetime.datetime.today()\n date_header = current_date.strftime('%a %H:%M:%S %Y-%m-%d') + '\\n'\n with open(build_journal_path(journal_location, current_date), 'a') as date_file:\n entry_output = date_header\n entry_output += '-' + ' '.join(entries) + '\\n'\n entry_output += '\\n'\n date_file.write(entry_output)"} +{"i": 577, "got": "def get_entry(journal_location, date):\n \"\"\"pass\"\"\"\n if not isinstance(date, datetime.date):\n return None\n try:\n with open(build_journal_path(journal_location, date), 'r') as entry_file:\n return entry_file.read()\n except IOError:\n pass"} +{"i": 578, "got": "def TemplateValidator(value):\n \"\"\"pass\"\"\"\n try:\n Template(value)\n except Exception as e:\n raise ValidationError(_('Cannot compile template (%(exception)s)'), params={'exception': e})"} +{"i": 579, "got": "def get_lbry_api_function_docs(url=LBRY_API_RAW_JSON_URL):\n \"\"\"pass\"\"\"\n try:\n docs_page = urlopen(url)\n contents = docs_page.read().decode('utf-8')\n return loads(contents)\n except URLError as UE:\n print(UE)\n return []\n except Exception as E:\n print(E)\n return []"} +{"i": 580, "got": "def generate_method_definition(func):\n \"\"\"pass\"\"\"\n indent = 4\n method_definition = ' ' * indent + 'def ' + func['name']\n params_required = [param for param in func['arguments'] if param['is_required']]\n params_optional = [param for param in func['arguments'] if not param['is_required']]\n method_definition += '(self, '\n for param in params_required:\n method_definition += param['name']\n method_definition += ', '\n for param in params_optional:\n method_definition += param['name']\n method_definition += '=None, '\n method_definition = method_definition.rstrip(', ') + '):\\n'\n indent += 4\n method_definition += ' ' * indent\n method_definition += '\"\"\"' + func['description']\n method_definition += '\\n\\n' + ' ' * indent\n for param in params_required + params_optional:\n method_definition += ':param ' + DTYPE_MAPPING[param['type'].lower()]\n method_definition += ' ' + param['name'] + ': '\n method_definition += param['description']\n method_definition += '\\n' if param['is_required'] else ' (Optional)\\n'\n method_definition += ' ' * indent\n open_index = func['returns'].find('(')\n close_index = func['returns'].find(')', open_index > -1 and open_index or 0)\n func['returns'] = func['returns'].replace('\\t', ' ')\n return_string = func['returns'].replace('\\n', '')\n if open_index < close_index:\n if func['returns'][open_index + 1:close_index] in DTYPE_MAPPING:\n method_definition += ':rtype: ' + DTYPE_MAPPING[func['returns'][open_index + 1:close_index]]\n func['returns'] = func['returns'].replace(func['returns'][open_index:close_index + 1], '')\n method_definition += '\\n' + ' ' * indent\n method_definition += ':return: ' + return_string\n for i in range(0, len(return_string) + 1, 80 - (indent + 2)):\n method_definition += return_string[i:i + 80 - (indent + 2)] + '\\n' + ' ' * indent\n method_definition += '\"\"\"\\n' + ' ' * indent\n params_map = '__params_map = {'\n params_indent, num_params = (len(params_map), len(params_required) + len(params_optional))\n method_definition += params_map\n for i, param in enumerate(params_required + params_optional):\n method_definition += \"'\" + param['name'] + \"': \" + param['name']\n if not param['is_required']:\n method_definition += ' if ' + param['name'] + 'is not None else None'\n method_definition += ',\\n' + ' ' * (indent + 1) + ' ' * params_indent\n method_definition += '}\\n\\n' + ' ' * indent\n method_definition += \"return self.make_request(SERVER_ADDRESS, '\" + func['name'] + \"', \" + params_map.rstrip(' = {') + ', timeout=self.timeout)\\n\\n'\n return method_definition"} +{"i": 581, "got": "def generate_lbryd_wrapper(url=LBRY_API_RAW_JSON_URL, read_file=__LBRYD_BASE_FPATH__, write_file=LBRYD_FPATH):\n \"\"\"pass\"\"\"\n functions = get_lbry_api_function_docs(url)\n with open(write_file, 'w') as lbry_file:\n lbry_file.write('# This file was generated at build time using the generator function\\n')\n lbry_file.write('# You may edit but do so with caution\\n')\n with open(read_file, 'r') as template:\n header = template.read()\n lbry_file.write(header)\n for func in functions:\n method_definition = generate_method_definition(func)\n lbry_file.write(method_definition)\n try:\n from yapf.yapflib.yapf_api import FormatFile\n FormatFile(write_file, in_place=True)\n except ImportError as IE:\n print('[Warning]: yapf is not installed, so the generated code will not follow an easy-to-read standard')\n print(IE)"} +{"i": 582, "got": "def get(self, style):\n \"\"\"pass\"\"\"\n level = len(self.stack) - 1\n while level >= 0:\n if style in self.stack[level]:\n return self.stack[level][style]\n else:\n level = level - 1\n return None"} +{"i": 583, "got": "def enforce_type(self, attr, val):\n \"\"\"pass\"\"\"\n if not attr in self.types:\n return utfstr(val)\n elif self.types[attr] == 'int':\n return int(float(val))\n elif self.types[attr] == 'float':\n return float(val)\n else:\n return utfstr(val)"} +{"i": 584, "got": "def to_escpos(self):\n \"\"\"pass\"\"\"\n cmd = ''\n ordered_cmds = self.cmds.keys()\n ordered_cmds.sort(lambda x, y: cmp(self.cmds[x]['_order'], self.cmds[y]['_order']))\n for style in ordered_cmds:\n cmd += self.cmds[style][self.get(style)]\n return cmd"} +{"i": 585, "got": "def start_inline(self, stylestack=None):\n \"\"\"pass\"\"\"\n self.stack.append('inline')\n if self.dirty:\n self.escpos._raw(' ')\n if stylestack:\n self.style(stylestack)"} +{"i": 586, "got": "def start_block(self, stylestack=None):\n \"\"\"pass\"\"\"\n if self.dirty:\n self.escpos._raw('\\n')\n self.dirty = False\n self.stack.append('block')\n if stylestack:\n self.style(stylestack)"} +{"i": 587, "got": "def end_entity(self):\n \"\"\"pass\"\"\"\n if self.stack[-1] == 'block' and self.dirty:\n self.escpos._raw('\\n')\n self.dirty = False\n if len(self.stack) > 1:\n self.stack = self.stack[:-1]"} +{"i": 588, "got": "def _pinyin_generator(chars, format):\n \"\"\"pass\"\"\"\n for char in chars:\n key = '%X' % ord(char)\n pinyin = pinyin_dict.get(key, char)\n tone = pinyin_tone.get(key, 0)\n if tone == 0 or format == 'strip':\n pass\n elif format == 'numerical':\n pinyin += str(tone)\n elif format == 'diacritical':\n vowels = itertools.chain((c for c in pinyin if c in 'aeo'), (c for c in pinyin if c in 'iuv'))\n vowel = pinyin.index(next(vowels)) + 1\n pinyin = pinyin[:vowel] + tonemarks[tone] + pinyin[vowel:]\n else:\n error = 'Format must be one of: numerical/diacritical/strip'\n raise ValueError(error)\n yield unicodedata.normalize('NFC', pinyin)"} +{"i": 589, "got": "def get(s, delimiter='', format='diacritical'):\n \"\"\"pass\"\"\"\n return delimiter.join(_pinyin_generator(u(s), format=format))"} +{"i": 590, "got": "def get_initial(s, delimiter=' '):\n \"\"\"pass\"\"\"\n initials = (p[0] for p in _pinyin_generator(u(s), format='strip'))\n return delimiter.join(initials)"} +{"i": 591, "got": "def _add_to_tree(tree, word, meaning):\n \"\"\"pass\"\"\"\n if len(word) == 0:\n tree[''] = meaning\n else:\n _add_to_tree(tree[word[0]], word[1:], meaning)"} +{"i": 592, "got": "def init():\n \"\"\"pass\"\"\"\n global dictionaries, trees\n dictionaries = {'traditional': {}, 'simplified': {}}\n trees = {'traditional': Tree(), 'simplified': Tree()}\n lines = gzip.open(os.path.join(os.path.dirname(__file__), 'cedict.txt.gz'), mode='rt', encoding='utf-8')\n exp = re.compile('^([^ ]+) ([^ ]+) \\\\[(.*)\\\\] /(.+)/')\n parsed_lines = (exp.match(line).groups() for line in lines if line[0] != '#')\n for traditional, simplified, pinyin, meaning in parsed_lines:\n meaning = meaning.split('/')\n dictionaries['traditional'][traditional] = meaning\n dictionaries['simplified'][simplified] = meaning\n _add_to_tree(trees['traditional'], traditional, meaning)\n _add_to_tree(trees['simplified'], simplified, meaning)"} +{"i": 593, "got": "def translate_word(word, dictionary=['simplified']):\n \"\"\"pass\"\"\"\n global dictionaries\n if not dictionaries:\n init()\n for d in dictionary:\n if word in dictionaries[d]:\n return dictionaries[d][word]"} +{"i": 594, "got": "def get_status_key(self, instance):\n \"\"\"pass\"\"\"\n key_id = 'inst_%s' % id(instance) if instance.pk is None else instance.pk\n return '%s.%s-%s-%s' % (instance._meta.app_label, get_model_name(instance), key_id, self.field.name)"} +{"i": 595, "got": "def get_status(self, instance):\n \"\"\"pass\"\"\"\n status_key, status = self._get_status(instance)\n if status['state'] in ['complete', 'error']:\n cache.delete(status_key)\n return status"} +{"i": 596, "got": "def set_status(self, instance, status):\n \"\"\"pass\"\"\"\n status_key = self.get_status_key(instance)\n cache.set(status_key, status, timeout=300)"} +{"i": 597, "got": "def get_mode(self, old_mode=None):\n \"\"\"pass\"\"\"\n if self.mode is not None:\n return self.mode\n assert self.can_write, 'This format does not have a supported output mode.'\n if old_mode is None:\n return self.output_modes[0]\n if old_mode in self.output_modes:\n return old_mode\n try:\n idx = PILLOW_MODES.index(old_mode)\n except ValueError:\n return self.output_modes[0]\n for mode in PILLOW_MODES[idx + 1:]:\n if mode in self.output_modes:\n return mode\n opposite = PILLOW_MODES[:idx]\n opposite.reverse()\n for mode in opposite:\n if mode in self.output_modes:\n return mode"} +{"i": 598, "got": "def token_at_cursor(code, pos=0):\n \"\"\"pass\"\"\"\n l = len(code)\n end = start = pos\n while end < l and code[end].isalpha():\n end += 1\n while start > 0 and code[start - 1].isalpha():\n start -= 1\n if start > 0 and code[start - 1] == '%':\n start -= 1\n return (code[start:end], start)"} +{"i": 599, "got": "def _send(self, data, msg_type='ok', silent=False):\n \"\"\"pass\"\"\"\n if data is not None:\n try:\n self._klog.debug('msg to frontend (%d): %.160s...', silent, data)\n except Exception as e:\n self._klog.warn(\"can't log response: %s\", e)\n if not silent:\n if msg_type != 'raw':\n data = data_msg(data, mtype=msg_type)\n self.send_response(self.iopub_socket, 'display_data', data)\n return {'status': 'error' if msg_type == 'error' else 'ok', 'execution_count': self.execution_count, 'payload': [], 'user_expressions': {}}"} diff --git a/harness/README.md b/harness/README.md new file mode 100644 index 0000000000000000000000000000000000000000..31a47aa24e75106da9a170ac5c64d6d9e072291e --- /dev/null +++ b/harness/README.md @@ -0,0 +1,181 @@ +# PyBytecode evaluation harness + +Grades Python 3.12 decompilations under a **sound** oracle: recompile the prediction and require +the resulting code object to be byte-identical to the reference's, recursively, including +docstrings and `co_exceptiontable`. A pass is a proof, not a plausibility judgement. + +Its limits are real and are documented in **[`../ORACLE-LIMITS.md`](../ORACLE-LIMITS.md)**: +a 0.33% false-reject floor on foreign `.pyc`, a hard dependency on matching the producer's +optimization level, and the fact that the 100% pre-flight this harness prints proves far less +than it looks like it does. Read that before quoting any number from here. + +**Everything here runs from a fresh clone with the Python standard library alone.** No model, no +GPU, no network, no API key, no PyLingual, and no path outside the clone. Verified — see +*Fresh-clone verification* below. + +--- + +## Requirements + +| To do this | You need | +|---|---| +| Grade cached generations (every published number) | CPython **3.12.x**. Nothing else. | +| Generate new predictions | the above + any OpenAI-compatible server | +| Rebuild a benchmark from its source dataset | the above + `pip install -r requirements.txt` + authenticated `gh` | +| Compare against PyLingual | the above + the optional extra (`requirements-pylingual.txt`) | + +CPython 3.12 is not a preference. The benchmark is 3.12 bytecode; on 3.11 or 3.13 the reference +`.pyc` files will not compare and pre-flight will fail loudly rather than score silently. + +Configuration is environment-only — `PYBYTECODE_ENDPOINT`, `PYBYTECODE_MODEL`, +`PYBYTECODE_API_KEY` (see `config.py`). Nothing is hard-coded to a machine. + +--- + +## Reproduce every published number, from cache + +No model, no GPU, no network. The expensive part — the generations — is cached in this bundle, so +every number below is re-derivable for the cost of a few CPU-minutes. + +```bash +cd harness +B=../benchmarks/csn-3.12-licensed/bench.jsonl +G=../generations + +# 1. Prove the harness is sound before believing any score it prints. +python3 grade.py --bench $B --self-test-only --out ../results/selftest_csn.json + +# 2. Full scoring: tuned greedy, untuned-base control, verified best-of-N, +# with repo-clustered confidence intervals and per-row verdicts. +python3 analyze_scores.py --bench $B \ + --greedy $G/gen_v3_csn600.jsonl \ + --samples $G/boN_v3_csn600.jsonl \ + --base $G/gen_base_csn600.jsonl \ + --out ../results/scores_csn600.json --rows-out ../results/rows_csn600.jsonl +``` + +`../results/scores_csn600.json` holds the aggregates and intervals; +`../results/rows_csn600.jsonl` holds a per-row verdict for all 600 rows — repo, function, commit +SHA, SPDX, instruction count, whether tuned greedy certified, whether the untuned base certified, +and the index of the first passing sample. Every headline number is recomputable from that file +alone. + +The MBPP set is graded the same way: + +```bash +python3 grade.py --bench ../benchmarks/mbpp-ood/bench.jsonl \ + --self-test-only --out ../results/selftest_mbpp.json +``` + +### Confidence intervals are repo-clustered + +Rows from the same repository are not independent — shared author, house style, shared helpers — +so a plain binomial interval understates uncertainty. `analyze_scores.py` resamples +**repositories** with replacement (the cluster bootstrap, 10,000 draws) and reports the 2.5th and +97.5th percentiles, alongside the naive binomial interval and the design effect so the cost of +clustering is visible rather than assumed. + +This is meaningful here only because the benchmark caps any repository at ~1% of rows. On the +superseded 400-row set, one repository supplied 15% and a clustered interval would have been the +only honest one to quote — and none was. + +## Generate predictions (needs a model) + +```bash +export PYBYTECODE_ENDPOINT=http://localhost:1234/v1 +export PYBYTECODE_MODEL=pybytecode-v3-1.5b + +python3 generate.py --bench ../benchmarks/csn-3.12-licensed/bench.jsonl --out gen.jsonl +python3 generate.py --bench ../benchmarks/csn-3.12-licensed/bench.jsonl \ + --out boN.jsonl --temperature 0.8 --samples 32 # for best-of-N +python3 grade.py --bench ../benchmarks/csn-3.12-licensed/bench.jsonl \ + --gen gen.jsonl --out ../results/mine.json +``` + +`generate.py` is resumable: an interrupted run is completed by re-running the same command. + +--- + +## PyLingual — optional, user-installed, never vendored + +PyLingual is `GPL-3.0-only`. It is **not** a dependency of this harness and is **not** included +in this repository in any form. We import exactly one symbol from it, +`pylingual.equivalence_check.compare_pyc`, and only at grading time, so that the head-to-head +comparison uses *their* definition of a perfect decompilation rather than our reimplementation of +it. Nobody can say we loosened their bar. + +Without it: `dual_oracle.py` runs and reports `pylingual_available: false`, with their-oracle +columns `null` — explicitly absent, never silently zeroed. `grade.py --oracle theirs` exits with +an explanation. Everything else is unaffected. + +Install instructions and the exact commit we measured: `requirements-pylingual.txt`. + +--- + +## The self-tests, and why they can refuse + +Two gates run before any score is printed: + +- **Pre-flight** — grade every reference label against itself. A byte-perfect model must score + 100%. Anything less means the harness is broken, not that the model is bad. + **It is trivial by construction and is NOT evidence of soundness**: it compares `compile(x)` + with `compile(x)`, so any deterministic function of the source scores 100%, including a stub + that ignores the bytecode. It detects a broken harness (mismatched `.pyc`, wrong Python minor, + corrupt row) and nothing more. Soundness evidence is the mutation test and the 18 blind-spot + probes — see `../ORACLE-LIMITS.md` §1. +- **Mutation test** — corrupt each label (swap `+`/`-`, flip a comparison, break a `return`) and + confirm the oracle kills it. A grader that passes mutants is a stub and its scores are noise. + +If either is below 100% the command **refuses to print a score**. That is intended behaviour. + +Mutation candidates that do not change the program's AST are discarded rather than counted, so a +comment-only rewrite cannot be mistaken for a surviving mutant. This matters: the original harness +generated `return None` → `return None #None` and would have scored that as a survivor. +It reported 131/131 only because no row in its sample had a bare `return None`; the new 600-row +benchmark has three, and the un-filtered generator scored 97.48% and correctly refused to run. +The fix is in the mutation generator; the oracle was never loosened. + +Measured on the current benchmarks: + +| Benchmark | Pre-flight | Mutation kill rate | +|---|---|---| +| `csn-3.12-licensed` (n=600) | 600/600 = 100% | 116/116 = 100% | +| `mbpp-ood` (n=383) | 383/383 = 100% | 199/199 = 100% | + +--- + +## Fresh-clone verification + +Performed 2026-08-04. `git clone` into a scratch directory, no `PYBYTECODE_*` variables set, no +PyLingual installed (`ModuleNotFoundError`), no model running, working directory not the original +path: + +``` +1. self-test csn-3.12-licensed PRE-FLIGHT 600/600 = 100.0% MUTATION 116/116 = 100.0% SOUND +2. dual_oracle on cached CSN n=400 ours 335 = 83.75% pylingual_available: false +3. bestofn_grade on cached CSN greedy 335 certified@32 373 = 93.25% +``` + +Identical to the published values. Git LFS is required to materialise the cached generations — +see `../RELEASE-BLOCKERS.md`, which records the state of the LFS objects on the remote. + +--- + +## Files + +``` +config.py paths + endpoint; the only environment-aware module +common.py oracles, fence stripping, pre-flight, mutation test +grade.py score under one oracle (ours by default), self-tests first +dual_oracle.py score under both oracles; degrades gracefully without PyLingual +bestofn_grade.py verified best-of-N from cached samples +generate.py the only script that needs a model +pybytecode_core/ verify.py + rep.py, copied verbatim from scripts/pybytecode/ +``` + +`pybytecode_core/` is a byte-identical copy so the harness is self-contained. Verify it: + +``` +sha256 45ca921f86c73622d5b46295b9264e4a68bd697dce94e27a786c73f4416319b9 verify.py +sha256 1ba81c307c72e83d2c6a6eceb9936bf3f13645d267df3c7c676d421b9b2f43d9 rep.py +``` diff --git a/harness/analyze_scores.py b/harness/analyze_scores.py new file mode 100644 index 0000000000000000000000000000000000000000..789482eb6c3cbb37e763e1ab165894acf66656a7 --- /dev/null +++ b/harness/analyze_scores.py @@ -0,0 +1,190 @@ +#!/usr/bin/env python3 +"""Score the licensed benchmark with REPO-CLUSTERED confidence intervals, and emit per-row verdicts. + +Why clustered. Rows drawn from the same repository are not independent: they share an author, a +house style, and often helper functions, so a plain binomial interval understates uncertainty. +The old 400-row benchmark took 15% of its rows from a single repo, which made clustering so +severe that a clustered interval would have been the only honest one to quote — and none was. +The licensed benchmark caps any repo at ~1%, so the cluster effect is small, but it is reported +rather than assumed small. + +Method: the cluster bootstrap. Resample REPOSITORIES with replacement (not rows), recompute the +accuracy over the resampled repos, and take the 2.5th/97.5th percentiles. This is the standard +non-parametric interval for clustered binary data and needs no normality assumption. The design +effect (clustered variance / binomial variance) is reported so a reader can see how much the +clustering actually cost. + + ./analyze_scores.py --bench ../benchmarks/csn-3.12-licensed/bench.jsonl \\ + --greedy ../generations/gen_v3_csn600.jsonl \\ + --samples ../generations/boN_v3_csn600.jsonl \\ + --base ../generations/gen_base_csn600.jsonl \\ + --out ../results/scores_csn600.json --rows-out ../results/rows_csn600.jsonl +""" +from __future__ import annotations + +import argparse +import json +import math +import random +import sys +from collections import defaultdict +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +from common import load_bench, load_jsonl, ours_ok, require_sound, self_test, strip_fences # noqa: E402 + +BOOT = 10000 +SEED = 20260804 + + +def cluster_bootstrap(per_repo: dict[str, list[int]], boot: int = BOOT, seed: int = SEED): + """95% CI for the mean of clustered binary outcomes, by resampling repos with replacement.""" + repos = list(per_repo) + rng = random.Random(seed) + n_all = sum(len(v) for v in per_repo.values()) + point = sum(sum(v) for v in per_repo.values()) / n_all + means = [] + for _ in range(boot): + num = den = 0 + for _ in range(len(repos)): + v = per_repo[repos[rng.randrange(len(repos))]] + num += sum(v) + den += len(v) + if den: + means.append(num / den) + means.sort() + lo = means[int(0.025 * len(means))] + hi = means[int(0.975 * len(means))] + + # design effect vs the naive binomial interval + binom_se = math.sqrt(point * (1 - point) / n_all) if 0 < point < 1 else 0.0 + clust_se = (hi - lo) / (2 * 1.96) if hi > lo else 0.0 + deff = (clust_se / binom_se) ** 2 if binom_se > 0 else float("nan") + return { + "point": round(100 * point, 2), + "ci95_lo": round(100 * lo, 2), + "ci95_hi": round(100 * hi, 2), + "half_width_pp": round(100 * (hi - lo) / 2, 2), + "binomial_ci95_lo": round(100 * max(0.0, point - 1.96 * binom_se), 2), + "binomial_ci95_hi": round(100 * min(1.0, point + 1.96 * binom_se), 2), + "design_effect": round(deff, 2) if deff == deff else None, + "n": n_all, + "clusters": len(repos), + } + + +def main() -> None: + ap = argparse.ArgumentParser() + ap.add_argument("--bench", required=True) + ap.add_argument("--greedy", required=True) + ap.add_argument("--samples") + ap.add_argument("--base", help="untuned-base control generations") + ap.add_argument("--out", required=True) + ap.add_argument("--rows-out") + ap.add_argument("--label", default="") + a = ap.parse_args() + + bench, _ = load_bench(a.bench) + st = self_test(bench, "ours") + print(f"self-test: preflight {st['preflight_pct']}% mutation kill " + f"{st['mutation_kill_rate_pct']}%", file=sys.stderr, flush=True) + require_sound(st) + + greedy = {r["i"]: r for r in load_jsonl(a.greedy)} + base = {r["i"]: r for r in load_jsonl(a.base)} if a.base else {} + samples: dict[int, dict[int, str]] = defaultdict(dict) + if a.samples and Path(a.samples).exists(): + for r in load_jsonl(a.samples): + samples[r["i"]][r["s"]] = r["got"] + + Ns = (1, 2, 4, 8, 16, 32) + rows = [] + for i in sorted(bench): + exp = bench[i]["expected"] + g_ok = i in greedy and ours_ok(strip_fences(greedy[i]["got"]), exp) + b_ok = i in base and ours_ok(strip_fences(base[i]["got"]), exp) + first = None + if not g_ok: + for s in sorted(samples.get(i, {})): + if ours_ok(strip_fences(samples[i][s]), exp): + first = s + break + rows.append({ + "i": i, + "repo": bench[i]["provenance"]["repo"], + "func": bench[i]["provenance"]["func_name"], + "commit_sha": bench[i]["provenance"]["commit_sha"], + "spdx": bench[i]["license"]["spdx"], + "n_instr": bench[i]["n_instr"], + "tuned_greedy_certified": bool(g_ok), + "base_greedy_certified": bool(b_ok), + "first_passing_sample": first, + "certified_at_32": bool(g_ok or (first is not None and first <= 30)), + }) + + def by_repo(key): + d = defaultdict(list) + for r in rows: + d[r["repo"]].append(1 if r[key] else 0) + return d + + report = { + "label": a.label, + "bench": str(a.bench), + "n": len(rows), + "repos": len({r["repo"] for r in rows}), + "oracle": "strict L1: byte-identical code object incl. docstrings and co_exceptiontable", + "self_test": {k: st[k] for k in ("preflight_pct", "mutation_kill_rate_pct", "SOUND")}, + "tuned_greedy": cluster_bootstrap(by_repo("tuned_greedy_certified")), + "certified_at_32": cluster_bootstrap(by_repo("certified_at_32")), + } + if base: + report["base_greedy_UNTUNED_CONTROL"] = cluster_bootstrap(by_repo("base_greedy_certified")) + t = sum(r["tuned_greedy_certified"] for r in rows) + b = sum(r["base_greedy_certified"] for r in rows) + # paired: rows where exactly one of the two certified + b01 = sum(1 for r in rows if r["tuned_greedy_certified"] and not r["base_greedy_certified"]) + b10 = sum(1 for r in rows if r["base_greedy_certified"] and not r["tuned_greedy_certified"]) + report["fine_tune_effect"] = { + "tuned_certified": t, "base_certified": b, + "absolute_gain_pp": round(100 * (t - b) / len(rows), 2), + "tuned_only": b01, "base_only": b10, + "note": "paired discordant counts; McNemar exact p below", + } + # exact McNemar (binomial on the discordant pairs) + n_d = b01 + b10 + if n_d: + # Exact binomial two-sided p on the discordant pairs. Computed in LOG space: with a + # few hundred discordant pairs the direct ratio underflows to 0.0, and reporting a + # p-value of exactly zero would be a floating-point artefact presented as a result. + log2_p = math.log2(2.0) + math.log2( + sum(math.comb(n_d, k) for k in range(min(b01, b10) + 1))) - n_d + p = 2 ** log2_p + if p >= 1e-12: + report["fine_tune_effect"]["mcnemar_exact_p"] = round(min(1.0, p), 12) + else: + # report the magnitude honestly instead of collapsing it to 0 + report["fine_tune_effect"]["mcnemar_exact_p"] = f"< 1e-12 (log10 p ~ {log2_p * math.log10(2):.0f})" + + # N is a budget of N TOTAL attempts: the greedy decode, then N-1 sampled candidates. So the + # sampled candidates admitted at budget N are indices 0..N-2, and certified@1 is greedy alone. + # (Indexing this as `<= N - 1` counts N+1 attempts and makes certified@1 report a two-attempt + # number, which overstates every point on the curve.) + curve = {} + for N in Ns: + c = sum(1 for r in rows if r["tuned_greedy_certified"] + or (r["first_passing_sample"] is not None and r["first_passing_sample"] <= N - 2)) + curve[str(N)] = {"certified": c, "pct": round(100 * c / len(rows), 2), + "budget": f"1 greedy + {N - 1} sampled"} + report["certified_curve"] = curve + + Path(a.out).parent.mkdir(parents=True, exist_ok=True) + Path(a.out).write_text(json.dumps(report, indent=2)) + if a.rows_out: + Path(a.rows_out).write_text("".join(json.dumps(r) + "\n" for r in rows)) + print(json.dumps(report, indent=2)) + + +if __name__ == "__main__": + main() diff --git a/harness/bestofn_gen.py b/harness/bestofn_gen.py new file mode 100644 index 0000000000000000000000000000000000000000..2cccc43a1200d0e1b1be3c5c69185178a3d3db5f --- /dev/null +++ b/harness/bestofn_gen.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python3 +"""Generate best-of-N candidates for the rows greedy decoding failed, with verified early stop. + +Sampling every row would be waste: a row the greedy answer already certifies needs no candidates, +because certification is a PROOF and nothing is gained by a second opinion. So this samples only +the greedy failures, and stops as soon as one candidate certifies -- the certified@N curve depends +only on the INDEX of the first passing sample, so stopping after it is lossless for every N. + +That early stop is why the published run averaged ~3.8 generations per failed input rather than 31. + + PYBYTECODE_ENDPOINT=... PYBYTECODE_MODEL=... ./bestofn_gen.py \\ + --bench ../benchmarks/csn-3.12-licensed/bench.jsonl \\ + --greedy gen.jsonl --out boN.jsonl --max-samples 31 + +Resumable: rows already present in --out are skipped. +""" +from __future__ import annotations + +import argparse +import json +import sys +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +from common import load_bench, load_jsonl, ours_ok, strip_fences # noqa: E402 +from config import ENDPOINT, MODEL # noqa: E402 +from generate import INSTRUCTION, complete # noqa: E402 + + +def main() -> None: + ap = argparse.ArgumentParser() + ap.add_argument("--bench", required=True) + ap.add_argument("--greedy", required=True) + ap.add_argument("--out", required=True) + ap.add_argument("--max-samples", type=int, default=31) + ap.add_argument("--temperature", type=float, default=0.8) + ap.add_argument("--max-tokens", type=int, default=2048) + a = ap.parse_args() + + bench, _ = load_bench(a.bench) + greedy = {r["i"]: r for r in load_jsonl(a.greedy)} + + failed = [ + i for i in sorted(bench) + if not (i in greedy and ours_ok(strip_fences(greedy[i]["got"]), bench[i]["expected"])) + ] + print(f"greedy certified {len(bench) - len(failed)}/{len(bench)}; " + f"sampling {len(failed)} failures", file=sys.stderr, flush=True) + + out_path = Path(a.out) + done: set[int] = set() + if out_path.exists(): + for r in load_jsonl(out_path): + done.add(r["i"]) + print(f"resuming: {len(done)} rows already sampled", file=sys.stderr) + + gen_count = 0 + recovered = 0 + with out_path.open("a") as f: + for n, i in enumerate(failed): + if i in done: + continue + prompt = f"{INSTRUCTION}\n\n{bench[i]['input']}" + for s in range(a.max_samples): + got = complete(prompt, a.temperature, a.max_tokens, s) + gen_count += 1 + f.write(json.dumps({"i": i, "s": s, "got": got}) + "\n") + f.flush() + if ours_ok(strip_fences(got), bench[i]["expected"]): + recovered += 1 + break # lossless: certified@N depends only on this index + if n % 10 == 0: + print(f" {n}/{len(failed)} failures processed, {gen_count} generations, " + f"{recovered} recovered", file=sys.stderr, flush=True) + + print(f"DONE: {gen_count} generations, {recovered}/{len(failed)} recovered " + f"(mean {gen_count / max(1, len(failed)):.2f} gens/failed input)", file=sys.stderr) + + +if __name__ == "__main__": + main() diff --git a/harness/bestofn_grade.py b/harness/bestofn_grade.py new file mode 100644 index 0000000000000000000000000000000000000000..8b1d3817ea8dbbeb63999de3c98db9ee93352d23 --- /dev/null +++ b/harness/bestofn_grade.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +"""Verified best-of-N, graded from the cached samples. No model, no GPU, no network. + +certified@N = the greedy (temperature 0) answer verifies, OR any of the first N-1 sampled +candidates verifies -- all under the strict oracle (byte-identical code object, docstrings and +exception tables included). + +This is the number that matters for a decompiler product rather than for a leaderboard: because +the oracle is SOUND, a certified answer is proven correct, so best-of-N buys real accuracy rather +than a better guess. The uncertified remainder is reported as unknown, never as wrong. + + ./bestofn_grade.py --bench --greedy --samples \\ + --name CSN-3.12 --out ../results/bestofn.json +""" +from __future__ import annotations + +import argparse +import json +import sys +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +from common import load_bench, load_jsonl, ours_ok, self_test, require_sound, strip_fences # noqa: E402 + +DEFAULT_NS = (1, 4, 8, 16, 32) + + +def grade(name: str, bench_p: str, greedy_p: str, samples_p: str, Ns=DEFAULT_NS) -> dict: + bench, _ = load_bench(bench_p) + greedy = {r["i"]: r for r in load_jsonl(greedy_p)} + n = len(bench) + + greedy_pass = { + i for i in bench + if i in greedy and ours_ok(strip_fences(greedy[i]["got"]), bench[i]["expected"]) + } + + samples: dict[int, dict[int, str]] = {} + for r in load_jsonl(samples_p): + samples.setdefault(r["i"], {})[r["s"]] = r["got"] + + first_pass: dict[int, int | None] = {} + diversity: dict[int, tuple[int, int]] = {} + for i in bench: + if i in greedy_pass: + continue + exp = bench[i]["expected"] + fp, seen = None, set() + smap = samples.get(i, {}) + for s in sorted(smap): + src = strip_fences(smap[s]) + seen.add(src) + if fp is None and ours_ok(src, exp): + fp = s + first_pass[i] = fp + diversity[i] = (len(seen), len(smap)) + + curve = {} + for N in Ns: + cert = len(greedy_pass) + sum(1 for fp in first_pass.values() if fp is not None and fp <= N - 1) + curve[str(N)] = { + "certified": cert, + "pct": round(100 * cert / n, 2), + "recovered_from_sampling": sum( + 1 for fp in first_pass.values() if fp is not None and fp <= N - 1), + } + + return { + "benchmark": name, + "n": n, + "oracle": "strict: byte-identical code object incl. docstrings and co_exceptiontable", + "greedy_pass": len(greedy_pass), + "greedy_pass_pct": round(100 * len(greedy_pass) / n, 2), + "greedy_fail": len(first_pass), + "ever_recovered_by_sampling": sum(1 for fp in first_pass.values() if fp is not None), + "curve": curve, + "avg_unique_candidates_per_failed_input": + round(sum(d[0] for d in diversity.values()) / max(1, len(diversity)), 2), + "avg_samples_generated_per_failed_input": + round(sum(d[1] for d in diversity.values()) / max(1, len(diversity)), 2), + } + + +def main() -> None: + ap = argparse.ArgumentParser() + ap.add_argument("--bench", required=True) + ap.add_argument("--greedy", required=True, help="temperature-0 generations") + ap.add_argument("--samples", required=True, help="sampled generations, each row carrying `s`") + ap.add_argument("--name", default="benchmark") + ap.add_argument("--out", required=True) + ap.add_argument("--skip-self-test", action="store_true", + help="only for iterating; a reported number must never use it") + a = ap.parse_args() + + if not a.skip_self_test: + bench, _ = load_bench(a.bench) + st = self_test(bench, "ours") + print(f"self-test: preflight {st['preflight_pct']}% mutation kill " + f"{st['mutation_kill_rate_pct']}%", file=sys.stderr, flush=True) + require_sound(st) + + res = grade(a.name, a.bench, a.greedy, a.samples) + Path(a.out).parent.mkdir(parents=True, exist_ok=True) + Path(a.out).write_text(json.dumps(res, indent=2)) + print(json.dumps(res, indent=2)) + + +if __name__ == "__main__": + main() diff --git a/harness/common.py b/harness/common.py new file mode 100644 index 0000000000000000000000000000000000000000..f1509cc53de0fdb745f6f677719cd0af33c62a83 --- /dev/null +++ b/harness/common.py @@ -0,0 +1,221 @@ +#!/usr/bin/env python3 +"""Shared pieces: loading, fence stripping, the two oracles, and the mandatory harness self-tests. + +Two oracles are applied to the SAME predictions on the SAME benchmark, so the delta between them +is a measurement rather than an opinion. + + OURS -- `pybytecode_core.verify.code_fingerprint`. Recompile the prediction and require the + resulting code object to be byte-identical to the reference's, recursively, INCLUDING + docstrings and `co_exceptiontable`. Sound: a pass is a proof, never a guess. + THEIRS -- `pylingual.equivalence_check.compare_pyc`, imported not reimplemented, so no one can + say we loosened their bar. CFG-coarsened and docstring-blind (measured, not assumed). + OPTIONAL: absent PyLingual, everything below still runs on our oracle alone. + +Two self-tests gate every score this harness prints, per standing foundry discipline: + + PRE-FLIGHT grade every reference label against itself. A byte-perfect model MUST score 100%. + Anything less means the harness is broken and no score may be quoted. + MUTATION TEST deliberately corrupt each label and confirm the oracle KILLS it. A grader that + passes mutants is a stub and its scores are meaningless. +""" +from __future__ import annotations + +import ast +import json +import py_compile +import re +import sys +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +from config import resolve_bench_asset # noqa: E402 +from pybytecode_core.verify import code_fingerprint # noqa: E402 + +FENCE = re.compile(r"```(?:python|py)?\s*\n(.*?)(?:```|\Z)", re.S) + + +def strip_fences(text: str) -> str: + m = FENCE.search(text or "") + return (m.group(1) if m else (text or "")).strip() + + +def load_jsonl(path: str | Path) -> list[dict]: + return [json.loads(l) for l in Path(path).read_text().splitlines() if l.strip()] + + +def load_bench(path: str | Path) -> tuple[dict[int, dict], Path]: + """Return {i: row} with every row's `pyc_path` rewritten to a path that exists HERE.""" + bench_file = Path(path).resolve() + rows = {} + for r in load_jsonl(bench_file): + r["pyc_path"] = str(resolve_bench_asset(bench_file, r.get("pyc_path", ""), "pyc", r["i"])) + r["src_path"] = str(resolve_bench_asset(bench_file, r.get("src_path", ""), "src", r["i"])) + rows[r["i"]] = r + return rows, bench_file + + +# ------------------------------------------------------------------ our oracle +def ours_ok(pred_src: str, expected_src: str) -> bool: + """Byte-identical code object, docstrings and exception tables included.""" + try: + g = compile(pred_src, "", "exec", dont_inherit=True, optimize=0) + w = compile(expected_src, "", "exec", dont_inherit=True, optimize=0) + return code_fingerprint(g) == code_fingerprint(w) + except Exception: # noqa: BLE001 + return False + + +# ---------------------------------------------------------------- their oracle +_compare_pyc = None + + +def pylingual_available() -> bool: + global _compare_pyc + if _compare_pyc is None: + try: + from pylingual.equivalence_check import compare_pyc + _compare_pyc = compare_pyc + except Exception: # noqa: BLE001 + _compare_pyc = False + return _compare_pyc is not False + + +def theirs_ok(pred_src: str, ref_pyc: Path, tmp: Path, tag: str) -> tuple[bool, str]: + """PyLingual's own definition of Perfect: recompile, compare_pyc, all-or-nothing.""" + if not pylingual_available(): + return False, "pylingual not installed" + if not pred_src.strip(): + return False, "empty" + try: + ast.parse(pred_src) + except SyntaxError: + return False, "syntax error" + p, c = tmp / f"{tag}.py", tmp / f"{tag}.pyc" + try: + p.write_text(pred_src, encoding="utf-8") + py_compile.compile(str(p), cfile=str(c), doraise=True, optimize=0) + except Exception: # noqa: BLE001 + return False, "does not compile" + try: + results = _compare_pyc(Path(ref_pyc), c) + except Exception as e: # noqa: BLE001 + return False, f"oracle error: {type(e).__name__}" + if not results: + return False, "oracle returned no results" + if all(r.success for r in results): + return True, "PERFECT" + notes = [str(getattr(r, "note", "")) for r in results if not r.success] + return False, "semantic error: " + "; ".join(n for n in notes[:2] if n)[:120] + + +# ------------------------------------------------------------------ docstrings +def docstrings_of(src: str) -> list[str]: + out = [] + try: + tree = ast.parse(src) + except SyntaxError: + return out + for n in ast.walk(tree): + if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef, ast.Module)): + d = ast.get_docstring(n, clean=False) + if d is not None: + out.append(d) + return out + + +# ------------------------------------------------------------------ self-tests +def mutations(src: str) -> list[tuple[str, str]]: + """Semantically REAL corruptions of `src`, each of which a sound oracle must reject. + + Candidates that do not actually change the program are discarded rather than counted. The + `return_none` rewrite turns `return x` into `return None #x`, which is a genuine change -- + but applied to a bare `return None` it produces `return None #None`, differing only by a + comment. Counting that as a surviving mutant would blame the oracle for being right; the + original harness scored 131/131 only because no row in its first 120 had a bare + `return None`, and this benchmark has three. + + The no-op filter compares ASTs, NOT the oracle under test, so it cannot launder a real + mutant into a discarded one: `ast.dump` is blind to comments and formatting and to nothing + else. + """ + try: + base = ast.dump(ast.parse(src)) + except SyntaxError: + return [] + + candidates = [] + for name, a, b in (("plus_to_minus", " + ", " - "), ("eq_to_ne", " == ", " != "), + ("lt_to_gt", " < ", " > "), ("and_to_or", " and ", " or ")): + if a in src: + candidates.append((name, src.replace(a, b, 1))) + if "return " in src: + candidates.append(("return_none", src.replace("return ", "return None #", 1))) + + out = [] + for name, m in candidates: + try: + if ast.dump(ast.parse(m)) != base: + out.append((name, m)) + except SyntaxError: + continue # a mutant that does not parse tests nothing about the oracle + return out + + +def self_test(bench: dict[int, dict], oracle: str = "ours", mutation_rows: int = 120) -> dict: + """Pre-flight + mutation test. `oracle` is "ours" or "theirs".""" + import tempfile + + with tempfile.TemporaryDirectory() as td: + tmp = Path(td) + + def ok(src: str, row: dict, tag: str) -> bool: + if oracle == "ours": + return ours_ok(src, row["expected"]) + return theirs_ok(src, Path(row["pyc_path"]), tmp, tag)[0] + + pf_pass, pf_fail, failures = 0, 0, [] + for i, r in bench.items(): + if ok(r["expected"], r, f"pf{i}"): + pf_pass += 1 + else: + pf_fail += 1 + if len(failures) < 5: + failures.append({"i": i, "func": r.get("csn_func", "")}) + + killed = survived = 0 + survivors = [] + for i, r in list(bench.items())[:mutation_rows]: + for name, m in mutations(r["expected"]): + if ok(m, r, f"mut{i}"): + survived += 1 + if len(survivors) < 5: + survivors.append({"i": i, "mutation": name}) + else: + killed += 1 + + total = killed + survived + return { + "oracle": oracle, + "preflight_n": len(bench), + "preflight_perfect": pf_pass, + "preflight_failed": pf_fail, + "preflight_pct": round(100 * pf_pass / max(1, len(bench)), 2), + "preflight_failures": failures, + "mutation_total": total, + "mutation_killed": killed, + "mutation_survived": survived, + "mutation_kill_rate_pct": round(100 * killed / max(1, total), 2), + "mutation_survivors": survivors, + "SOUND": pf_fail == 0 and survived == 0, + } + + +def require_sound(st: dict) -> None: + """A harness that fails either self-test may not report a score. Refuse, loudly.""" + if not st["SOUND"]: + print(json.dumps(st, indent=2), file=sys.stderr) + raise SystemExit( + f"REFUSING TO SCORE: preflight {st['preflight_perfect']}/{st['preflight_n']}, " + f"mutation kill rate {st['mutation_kill_rate_pct']}%. Both must be 100%." + ) diff --git a/harness/config.py b/harness/config.py new file mode 100644 index 0000000000000000000000000000000000000000..6dc39d96c758a93a60a3e78b71db97112642b417 --- /dev/null +++ b/harness/config.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +"""Everything environment-specific, in one place. + +The first version of this harness hard-coded absolute build-machine paths, a scratch directory +under /tmp, `http://localhost:1234/v1` and one model name, so nobody else could run it: measured +2026-08-04, 46 such lines across 22 scripts, plus 679 benchmark rows whose `pyc_path` pointed into +a scratch directory that no longer exists. Nothing here is hard-coded to a machine: paths are +resolved relative to this file, and the model endpoint comes from the environment. + + PYBYTECODE_ENDPOINT OpenAI-compatible base URL (default http://localhost:1234/v1) + PYBYTECODE_MODEL model name at that endpoint (default pybytecode-v3-1.5b) + PYBYTECODE_API_KEY bearer token, if the server wants one (default "not-needed") + +Only `generate.py` reads the endpoint. Every grading path is offline: given the cached +generations in this repository, all published numbers reproduce with no model and no GPU. +""" +from __future__ import annotations + +import os +from pathlib import Path + +HARNESS_DIR = Path(__file__).resolve().parent +RELEASE_DIR = HARNESS_DIR.parent +BENCHMARKS_DIR = RELEASE_DIR / "benchmarks" +GENERATIONS_DIR = RELEASE_DIR / "generations" +RESULTS_DIR = RELEASE_DIR / "results" + +ENDPOINT = os.environ.get("PYBYTECODE_ENDPOINT", "http://localhost:1234/v1") +MODEL = os.environ.get("PYBYTECODE_MODEL", "pybytecode-v3-1.5b") +API_KEY = os.environ.get("PYBYTECODE_API_KEY", "not-needed") + + +def resolve_bench_asset(bench_file: Path, stored_path: str, kind: str, index: int) -> Path: + """Resolve a row's .pyc / .py path RELATIVE TO ITS OWN bench.jsonl. + + Benchmarks built by the original harness stored absolute scratch-directory paths, which do + not exist on any other machine (and no longer exist on the build machine either). The files + themselves have always been committed next to bench.jsonl, so the stored string is ignored + whenever the co-located file exists. A stored RELATIVE path is honoured as written. + + `kind` is "pyc" or "src"; `index` is the row's `i`. + """ + bench_dir = bench_file.resolve().parent + if stored_path and not stored_path.startswith("/"): + p = bench_dir / stored_path + if p.exists(): + return p + ext = ".pyc" if kind == "pyc" else ".py" + p = bench_dir / kind / f"{index:05d}{ext}" + if p.exists(): + return p + # last resort: trust the stored absolute path, so a failure names the real missing file + return Path(stored_path) if stored_path else p + + +def have_pylingual() -> bool: + """PyLingual is an OPTIONAL, user-installed extra. It is GPL-3.0 and is never vendored.""" + try: + import pylingual.equivalence_check # noqa: F401 + return True + except Exception: # noqa: BLE001 + return False diff --git a/harness/dual_oracle.py b/harness/dual_oracle.py new file mode 100644 index 0000000000000000000000000000000000000000..c0c6d0175cdce5851f62eac51e058ec5f6a95261 --- /dev/null +++ b/harness/dual_oracle.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python3 +"""Score a prediction file under BOTH oracles on the SAME benchmark. + +PyLingual is OPTIONAL. Without it this still runs and still reports every number that depends +only on our oracle; the columns that need theirs are reported as null with an explicit +`pylingual_available: false`, never silently omitted and never quietly zeroed. + + ./dual_oracle.py --gen ../generations/gen_v3_csn.jsonl \\ + --bench ../benchmarks/csn-3.12-licensed/bench.jsonl \\ + --out ../results/dual_ours_csn.json --label "ours / CSN" +""" +from __future__ import annotations + +import argparse +import json +import sys +import tempfile +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +from common import ( # noqa: E402 + docstrings_of, load_bench, load_jsonl, ours_ok, pylingual_available, strip_fences, theirs_ok, +) + + +def main() -> None: + ap = argparse.ArgumentParser() + ap.add_argument("--gen", required=True) + ap.add_argument("--bench", required=True) + ap.add_argument("--out", required=True) + ap.add_argument("--label", default="") + a = ap.parse_args() + + bench, _ = load_bench(a.bench) + gen = load_jsonl(a.gen) + have_pyl = pylingual_available() + if not have_pyl: + print("NOTE: pylingual is not installed — their-oracle columns will be null. " + "Our-oracle scoring is unaffected. See harness/README.md.", file=sys.stderr) + + n = ours = pyl = pyl_ok_ours_fail = 0 + doc_total = doc_recovered = 0 + with tempfile.TemporaryDirectory() as td: + tmp = Path(td) + for g in gen: + i = g["i"] + if i not in bench: + continue + n += 1 + ref = bench[i] + src = strip_fences(g["got"]) + + o_ok = ours_ok(src, ref["expected"]) + ours += o_ok + + if have_pyl: + p_ok, _ = theirs_ok(src, Path(ref["pyc_path"]), tmp, f"g{i}") + pyl += p_ok + if p_ok and not o_ok: + pyl_ok_ours_fail += 1 + + # docstring recovery, over references carrying a REAL docstring + # (the CSN normal form rewrites docstrings to the literal 'pass' — not a real one) + ref_docs = [d for d in docstrings_of(ref["expected"]) if d != "pass"] + if ref_docs: + doc_total += 1 + got = docstrings_of(src) + if all(d in got for d in ref_docs): + doc_recovered += 1 + + rep = { + "label": a.label, + "n": n, + "pylingual_available": have_pyl, + "PERFECT_our_oracle_docstring_strict": ours, + "PERFECT_our_oracle_pct": round(100 * ours / max(1, n), 2), + "PERFECT_their_oracle": pyl if have_pyl else None, + "PERFECT_their_oracle_pct": round(100 * pyl / max(1, n), 2) if have_pyl else None, + "passes_THEIRS_but_fails_OURS": pyl_ok_ours_fail if have_pyl else None, + "samples_with_real_docstring": doc_total, + "docstrings_exactly_recovered": doc_recovered, + "docstring_recovery_pct": round(100 * doc_recovered / max(1, doc_total), 2), + } + Path(a.out).parent.mkdir(parents=True, exist_ok=True) + Path(a.out).write_text(json.dumps(rep, indent=2)) + print(json.dumps(rep, indent=2)) + + +if __name__ == "__main__": + main() diff --git a/harness/generate.py b/harness/generate.py new file mode 100644 index 0000000000000000000000000000000000000000..6757079cd15606cbdf6460856ab52ba38506d8f0 --- /dev/null +++ b/harness/generate.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python3 +"""Generate predictions from an OpenAI-compatible endpoint. The ONLY script here that needs a model. + +Every published number reproduces from the cached generations without ever running this — see +harness/README.md. This exists so the cache can be regenerated, or a different model evaluated. + + PYBYTECODE_ENDPOINT=http://localhost:1234/v1 PYBYTECODE_MODEL=my-model \\ + ./generate.py --bench ../benchmarks/csn-3.12-licensed/bench.jsonl --out gen.jsonl + +Resumable: an existing --out is read first and completed rows are skipped, so an interrupted run +costs nothing. Output is streamed and flushed per row, never accumulated in memory. +""" +from __future__ import annotations + +import argparse +import json +import sys +import urllib.error +import urllib.request +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +from common import load_bench # noqa: E402 +from config import API_KEY, ENDPOINT, MODEL # noqa: E402 + +INSTRUCTION = ( + "Decompile this Python 3.12 bytecode disassembly back into the original Python source code. " + "Output only the source code." +) + + +def complete(prompt: str, temperature: float, max_tokens: int, seed: int | None) -> str: + body = { + "model": MODEL, + "messages": [{"role": "user", "content": prompt}], + "temperature": temperature, + "max_tokens": max_tokens, + } + if seed is not None: + body["seed"] = seed + req = urllib.request.Request( + f"{ENDPOINT.rstrip('/')}/chat/completions", + data=json.dumps(body).encode(), + headers={"Content-Type": "application/json", "Authorization": f"Bearer {API_KEY}"}, + ) + with urllib.request.urlopen(req, timeout=600) as r: + return json.loads(r.read())["choices"][0]["message"]["content"] + + +def main() -> None: + ap = argparse.ArgumentParser() + ap.add_argument("--bench", required=True) + ap.add_argument("--out", required=True) + ap.add_argument("--temperature", type=float, default=0.0) + ap.add_argument("--samples", type=int, default=1, help=">1 emits an `s` field per sample") + ap.add_argument("--max-tokens", type=int, default=2048) + ap.add_argument("--limit", type=int, default=0) + a = ap.parse_args() + + bench, _ = load_bench(a.bench) + out_path = Path(a.out) + done: set[tuple[int, int]] = set() + if out_path.exists(): + for line in out_path.read_text().splitlines(): + if line.strip(): + r = json.loads(line) + done.add((r["i"], r.get("s", 0))) + print(f"resuming: {len(done)} generations already present", file=sys.stderr) + + todo = sorted(bench)[: a.limit or None] + print(f"endpoint={ENDPOINT} model={MODEL} rows={len(todo)} samples={a.samples}", file=sys.stderr) + + with out_path.open("a") as f: + for i in todo: + for s in range(a.samples): + if (i, s) in done: + continue + prompt = f"{INSTRUCTION}\n\n{bench[i]['input']}" + try: + got = complete(prompt, a.temperature, a.max_tokens, None if a.samples == 1 else s) + except (urllib.error.URLError, OSError) as e: + raise SystemExit( + f"cannot reach {ENDPOINT}: {e}\n" + "Set PYBYTECODE_ENDPOINT to your OpenAI-compatible server, or use the " + "cached generations and skip this script entirely." + ) + rec = {"i": i, "got": got} + if a.samples > 1: + rec["s"] = s + f.write(json.dumps(rec) + "\n") + f.flush() + if i % 25 == 0: + print(f" {i}/{len(todo)}", file=sys.stderr, flush=True) + + +if __name__ == "__main__": + main() diff --git a/harness/grade.py b/harness/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..322bf546d361040604012fd4f155f52067c15c35 --- /dev/null +++ b/harness/grade.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 +"""Grade a prediction file under ONE oracle, with the harness self-tests run first. + + ./grade.py --bench --gen --out # our oracle + ./grade.py --bench --gen --oracle theirs --out ... # PyLingual's + ./grade.py --bench --self-test-only --out preflight.json + +`--oracle ours` needs nothing but the Python standard library. `--oracle theirs` needs the +optional, user-installed PyLingual extra and exits with a clear message if it is absent. + +Pre-flight and the mutation test run before any score is computed. If either is not 100% the +command REFUSES to print a score. +""" +from __future__ import annotations + +import argparse +import json +import sys +import tempfile +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +from common import ( # noqa: E402 + load_bench, load_jsonl, ours_ok, pylingual_available, require_sound, self_test, strip_fences, + theirs_ok, +) + + +def main() -> None: + ap = argparse.ArgumentParser() + ap.add_argument("--bench", required=True) + ap.add_argument("--gen") + ap.add_argument("--out", required=True) + ap.add_argument("--oracle", choices=("ours", "theirs"), default="ours") + ap.add_argument("--label", default="") + ap.add_argument("--self-test-only", action="store_true") + a = ap.parse_args() + + if a.oracle == "theirs" and not pylingual_available(): + raise SystemExit( + "--oracle theirs needs the optional PyLingual extra, which is not installed.\n" + "It is GPL-3.0 and is never vendored here; install it yourself (harness/README.md),\n" + "or use --oracle ours, which reproduces every number of ours without it." + ) + + bench, _ = load_bench(a.bench) + print(f"self-testing the {a.oracle} oracle on {len(bench)} labels...", file=sys.stderr, flush=True) + st = self_test(bench, a.oracle) + print(f" PRE-FLIGHT {st['preflight_perfect']}/{st['preflight_n']} = {st['preflight_pct']}% " + f"MUTATION {st['mutation_killed']}/{st['mutation_total']} killed = " + f"{st['mutation_kill_rate_pct']}%", file=sys.stderr, flush=True) + require_sound(st) + + rep = {"label": a.label, "bench": str(a.bench), **st} + Path(a.out).parent.mkdir(parents=True, exist_ok=True) + + if a.self_test_only or not a.gen: + Path(a.out).write_text(json.dumps(rep, indent=2)) + print(json.dumps({k: v for k, v in rep.items() + if k not in ("preflight_failures", "mutation_survivors")}, indent=2)) + return + + gen = load_jsonl(a.gen) + n = perfect = 0 + why_counts: dict[str, int] = {} + rows = [] + with tempfile.TemporaryDirectory() as td: + tmp = Path(td) + for g in gen: + i = g["i"] + if i not in bench: + continue + n += 1 + src = strip_fences(g["got"]) + if a.oracle == "ours": + ok = ours_ok(src, bench[i]["expected"]) + why = "PERFECT" if ok else "not byte-identical" + else: + ok, why = theirs_ok(src, Path(bench[i]["pyc_path"]), tmp, f"g{i}") + perfect += ok + if not ok: + key = why.split(":")[0] + why_counts[key] = why_counts.get(key, 0) + 1 + rows.append({"i": i, "perfect": ok, "why": why, + "func": bench[i].get("csn_func", ""), "n_instr": bench[i].get("n_instr")}) + + rep.update({ + "gen": str(a.gen), + "scored_n": n, + "PERFECT": perfect, + "PERFECT_pct": round(100 * perfect / max(1, n), 2), + "failure_profile": dict(sorted(why_counts.items(), key=lambda x: -x[1])), + }) + Path(a.out).write_text(json.dumps({**rep, "rows": rows}, indent=2)) + print(json.dumps({k: v for k, v in rep.items() + if k not in ("preflight_failures", "mutation_survivors")}, indent=2)) + + +if __name__ == "__main__": + main() diff --git a/harness/requirements-pylingual.txt b/harness/requirements-pylingual.txt new file mode 100644 index 0000000000000000000000000000000000000000..edc2648bc3b0db3fc9f5589ff950a4634f489435 --- /dev/null +++ b/harness/requirements-pylingual.txt @@ -0,0 +1,15 @@ +# OPTIONAL EXTRA — PyLingual, the comparison decompiler. GPL-3.0-only. +# +# NEVER VENDORED AND NEVER A HARD DEPENDENCY. Install it yourself if you want the head-to-head +# columns; the harness runs and grades our own results without it. Nothing in this repository is +# a derivative work of it — we import exactly one symbol, +# `pylingual.equivalence_check.compare_pyc`, at grading time only. +# +# git clone https://github.com/syssec-utd/pylingual +# cd pylingual +# git checkout 6a31b227c9f7ccb85e08c9781b33598b312a715e # the commit we measured +# python3.12 -m venv pylenv +# ./pylenv/bin/pip install -e . +# +# Environment as measured: Python 3.12.13, torch 2.13.0+cu130, 91 packages. +# The ~5.1 GB venv is not committed anywhere: it is regenerable and it contains GPL code. diff --git a/harness/requirements.txt b/harness/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..6c059cbb17e6c2bb413c3acc99a586e6a1eb7711 --- /dev/null +++ b/harness/requirements.txt @@ -0,0 +1,20 @@ +# GRADING NEEDS NOTHING FROM THIS FILE. +# Every published number reproduces from the cached generations using the Python standard library +# alone, on CPython 3.12.x. Verified on 3.12.3. `pip install -r` is not a prerequisite for +# `make reproduce`; it is only needed to REBUILD a benchmark from its source dataset. +# +# python3 -m venv .venv && . .venv/bin/activate && pip install -r harness/requirements.txt + +# --- benchmark construction only (tools/) --- +pyarrow==23.0.1 # reads the CodeSearchNet parquet directly +datasets==4.8.4 # MBPP; pinned because the CSN streaming reader in this version aborts +huggingface-hub==1.10.1 +fsspec==2026.2.0 +numpy==1.26.4 +pandas==3.0.2 +requests==2.33.1 + +# --- also required by tools/resolve_licenses.py, NOT installable via pip --- +# GitHub CLI `gh`, authenticated (`gh auth login`). Verified with gh 2.45.0. +# Used only to resolve repository licences at a commit; the built benchmark needs neither gh nor +# a network connection. diff --git a/harness/size_curve.py b/harness/size_curve.py new file mode 100644 index 0000000000000000000000000000000000000000..8a4c4e03826e79930423e8ac5b86f8fedbe777c5 --- /dev/null +++ b/harness/size_curve.py @@ -0,0 +1,143 @@ +#!/usr/bin/env python3 +"""Stratify certification by UNIT SIZE. CPU only; no model, no network. + +The model's binding limit is the size of the unit you hand it, not the Python version. This +script is the instrument behind the size guidance on the model card, and it runs on the PUBLISHED +benchmark from the PUBLISHED generations, so every bucket on the card is recomputable from files +you downloaded. + +Size axis is REPRESENTATION LINES: the number of lines in the disassembly text handed to the +model. That is literally the model's input length, it is already stored in each benchmark row's +`input` field, and you can measure your own input the same way before you run anything: + + rep_lines = disassemble_v2(code_object).count("\\n") + +Buckets match the ones used in the pooled cross-benchmark analysis so the two are comparable. + + ./size_curve.py --bench ../benchmarks/csn-3.12-licensed/bench.jsonl \\ + --greedy ../generations/gen_v3_csn600.jsonl \\ + --samples ../generations/boN_v3_csn600.jsonl \\ + --base ../generations/gen_base_csn600.jsonl \\ + --out ../results/size_curve_csn600.json +""" +from __future__ import annotations + +import argparse +import json +import sys +from collections import defaultdict +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +from analyze_scores import cluster_bootstrap # noqa: E402 +from common import load_bench, load_jsonl, ours_ok, require_sound, self_test, strip_fences # noqa: E402 + +BUCKETS = [(0, 50), (50, 100), (100, 200), (200, 300), (300, 400), (400, 600), (600, 10**9)] +KNEE = 200 # where the greedy curve turns, per the pooled analysis + + +def label(lo: int, hi: int) -> str: + return f"{lo}-{hi - 1}" if hi < 10**9 else f"{lo}+" + + +def main() -> None: + ap = argparse.ArgumentParser() + ap.add_argument("--bench", required=True) + ap.add_argument("--greedy", required=True) + ap.add_argument("--samples") + ap.add_argument("--base") + ap.add_argument("--out", required=True) + a = ap.parse_args() + + bench, _ = load_bench(a.bench) + st = self_test(bench, "ours") + print(f"self-test: preflight {st['preflight_pct']}% mutation kill " + f"{st['mutation_kill_rate_pct']}%", file=sys.stderr, flush=True) + require_sound(st) + + greedy = {r["i"]: r for r in load_jsonl(a.greedy)} + base = {r["i"]: r for r in load_jsonl(a.base)} if a.base else {} + samples: dict[int, dict[int, str]] = defaultdict(dict) + have_samples = bool(a.samples and Path(a.samples).exists()) + if have_samples: + for r in load_jsonl(a.samples): + samples[r["i"]][r["s"]] = r["got"] + + rows = [] + for i in sorted(bench): + exp = bench[i]["expected"] + g_ok = i in greedy and ours_ok(strip_fences(greedy[i]["got"]), exp) + first = None + if not g_ok: + for s in sorted(samples.get(i, {})): + if ours_ok(strip_fences(samples[i][s]), exp): + first = s + break + rows.append({ + "i": i, + "repo": bench[i]["provenance"]["repo"], + # the representation the model is actually given, one line per disassembly line + "rep_lines": bench[i]["input"].count("\n"), + "n_instr": bench[i]["n_instr"], + "v3_greedy": bool(g_ok), + "v3_boN32": bool(g_ok or (first is not None and first <= 30)), + "base_greedy": bool(i in base and ours_ok(strip_fences(base[i]["got"]), exp)), + }) + + systems = ["v3_greedy", "base_greedy"] + (["v3_boN32"] if have_samples else []) + + out = { + "bench": str(a.bench), + "n": len(rows), + "size_axis": "rep_lines = lines of the disassembly handed to the model (bench row `input`)", + "best_of_n_included": have_samples, + "self_test": {k: st[k] for k in ("preflight_pct", "mutation_kill_rate_pct", "SOUND")}, + "rep_lines_distribution": {}, + "by_rep_lines": [], + "share_of_certifications_below_knee": {}, + } + + vals = sorted(r["rep_lines"] for r in rows) + def pct(p): return vals[min(len(vals) - 1, int(p * len(vals)))] + out["rep_lines_distribution"] = { + "min": vals[0], "p25": pct(.25), "median": pct(.5), "p75": pct(.75), + "p90": pct(.9), "p99": pct(.99), "max": vals[-1], + } + + for lo, hi in BUCKETS: + sel = [r for r in rows if lo <= r["rep_lines"] < hi] + e = {"bucket": label(lo, hi), "n": len(sel)} + for s in systems: + c = sum(r[s] for r in sel) + e[s] = {"certified": c, "n": len(sel), + "pct": round(100 * c / len(sel), 2) if sel else None} + # A clustered CI needs enough repos to resample; below that it is noise dressed as + # precision, so it is omitted rather than printed. + if len(sel) >= 30 and len({r["repo"] for r in sel}) >= 10: + d = defaultdict(list) + for r in sel: + d[r["repo"]].append(1 if r[s] else 0) + ci = cluster_bootstrap(d) + e[s]["ci95"] = [ci["ci95_lo"], ci["ci95_hi"]] + e[s]["ci_method"] = "repo-clustered bootstrap" + else: + e[s]["ci95"] = None + e[s]["ci_method"] = "omitted: too few rows/repos to estimate" + out["by_rep_lines"].append(e) + + for s in systems: + tot = sum(r[s] for r in rows) + small = sum(r[s] for r in rows if r["rep_lines"] < KNEE) + out["share_of_certifications_below_knee"][s] = { + "knee_rep_lines": KNEE, "certified_total": tot, "certified_below": small, + "pct": round(100 * small / tot, 2) if tot else None, + } + + Path(a.out).parent.mkdir(parents=True, exist_ok=True) + Path(a.out).write_text(json.dumps(out, indent=2)) + print(json.dumps(out, indent=2)) + + +if __name__ == "__main__": + main() diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000000000000000000000000000000000000..5156d16d17de89d07d7ef20789c1569123f67413 --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,30 @@ +{ + "add_prefix_space": false, + "backend": "tokenizers", + "bos_token": null, + "clean_up_tokenization_spaces": false, + "eos_token": "<|im_end|>", + "errors": "replace", + "extra_special_tokens": [ + "<|im_start|>", + "<|im_end|>", + "<|object_ref_start|>", + "<|object_ref_end|>", + "<|box_start|>", + "<|box_end|>", + "<|quad_start|>", + "<|quad_end|>", + "<|vision_start|>", + "<|vision_end|>", + "<|vision_pad|>", + "<|image_pad|>", + "<|video_pad|>" + ], + "is_local": false, + "local_files_only": false, + "model_max_length": 32768, + "pad_token": "<|endoftext|>", + "split_special_tokens": false, + "tokenizer_class": "Qwen2Tokenizer", + "unk_token": null +}