prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>get_binary.py<|end_file_name|><|fim▁begin|>""" CMSIS-DAP Interface Firmware Copyright (c) 2009-2013 ARM Limited 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. Extract and patch the interface without bootloader """ from options import get_options from paths import get_interface_path, TMP_DIR from utils import gen_binary, is_lpc, split_path from os.path import join if __name__ == '__main__': <|fim_middle|> <|fim▁end|>
options = get_options() in_path = get_interface_path(options.interface, options.target, bootloader=False) _, name, _ = split_path(in_path) out_path = join(TMP_DIR, name + '.bin') print '\nELF: %s' % in_path gen_binary(in_path, out_path, is_lpc(options.interface)) print "\nBINARY: %s" % out_path
<|file_name|>opening.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python <|fim▁hole|> for i in range(100): handler.put(i, 'numbers') handler.close()<|fim▁end|>
from hdf5handler import HDF5Handler handler = HDF5Handler('mydata.hdf5') handler.open()
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0] def __getitem__(self, word): return self.get_cluster(word) <|fim▁hole|> """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters)<|fim▁end|>
def get_cluster(self, word):
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): <|fim_middle|> <|fim▁end|>
def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0] def __getitem__(self, word): return self.get_cluster(word) def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters)
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): <|fim_middle|> def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0] def __getitem__(self, word): return self.get_cluster(word) def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters) <|fim▁end|>
self.vocab = vocab self.clusters = clusters
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): <|fim_middle|> def __getitem__(self, word): return self.get_cluster(word) def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters) <|fim▁end|>
""" Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0]
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0] def __getitem__(self, word): <|fim_middle|> def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters) <|fim▁end|>
return self.get_cluster(word)
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0] def __getitem__(self, word): return self.get_cluster(word) def get_cluster(self, word): <|fim_middle|> def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters) <|fim▁end|>
""" Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx]
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0] def __getitem__(self, word): return self.get_cluster(word) def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): <|fim_middle|> @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters) <|fim▁end|>
return self.vocab[self.clusters == cluster]
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0] def __getitem__(self, word): return self.get_cluster(word) def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): <|fim_middle|> <|fim▁end|>
vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters)
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: <|fim_middle|> else: return temp[0] def __getitem__(self, word): return self.get_cluster(word) def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters) <|fim▁end|>
raise KeyError("Word not in vocabulary")
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: <|fim_middle|> def __getitem__(self, word): return self.get_cluster(word) def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters) <|fim▁end|>
return temp[0]
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def <|fim_middle|>(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0] def __getitem__(self, word): return self.get_cluster(word) def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters) <|fim▁end|>
__init__
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def <|fim_middle|>(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0] def __getitem__(self, word): return self.get_cluster(word) def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters) <|fim▁end|>
ix
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0] def <|fim_middle|>(self, word): return self.get_cluster(word) def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters) <|fim▁end|>
__getitem__
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0] def __getitem__(self, word): return self.get_cluster(word) def <|fim_middle|>(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters) <|fim▁end|>
get_cluster
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0] def __getitem__(self, word): return self.get_cluster(word) def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def <|fim_middle|>(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def from_text(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters) <|fim▁end|>
get_words_on_cluster
<|file_name|>wordclusters.py<|end_file_name|><|fim▁begin|>import numpy as np class WordClusters(object): def __init__(self, vocab, clusters): self.vocab = vocab self.clusters = clusters def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0] def __getitem__(self, word): return self.get_cluster(word) def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx] def get_words_on_cluster(self, cluster): return self.vocab[self.clusters == cluster] @classmethod def <|fim_middle|>(cls, fname): vocab = np.genfromtxt(fname, dtype=str, delimiter=" ", usecols=0) clusters = np.genfromtxt(fname, dtype=int, delimiter=" ", usecols=1) return cls(vocab=vocab, clusters=clusters) <|fim▁end|>
from_text
<|file_name|>generate-certs.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # Copyright (c) 2016 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ A chain with four possible intermediates with different notBefore and notAfter dates, for testing path bulding prioritization. """ import sys sys.path += ['../..'] import gencerts DATE_A = '150101120000Z' DATE_B = '150102120000Z' DATE_C = '180101120000Z' DATE_D = '180102120000Z' root = gencerts.create_self_signed_root_certificate('Root') root.set_validity_range(DATE_A, DATE_D) int_ac = gencerts.create_intermediate_certificate('Intermediate', root) int_ac.set_validity_range(DATE_A, DATE_C) int_ad = gencerts.create_intermediate_certificate('Intermediate', root) int_ad.set_validity_range(DATE_A, DATE_D) int_ad.set_key(int_ac.get_key()) int_bc = gencerts.create_intermediate_certificate('Intermediate', root) int_bc.set_validity_range(DATE_B, DATE_C) int_bc.set_key(int_ac.get_key()) int_bd = gencerts.create_intermediate_certificate('Intermediate', root) int_bd.set_validity_range(DATE_B, DATE_D) int_bd.set_key(int_ac.get_key()) target = gencerts.create_end_entity_certificate('Target', int_ac)<|fim▁hole|>gencerts.write_chain('The root', [root], out_pem='root.pem') gencerts.write_chain('Intermediate with validity range A..C', [int_ac], out_pem='int_ac.pem') gencerts.write_chain('Intermediate with validity range A..D', [int_ad], out_pem='int_ad.pem') gencerts.write_chain('Intermediate with validity range B..C', [int_bc], out_pem='int_bc.pem') gencerts.write_chain('Intermediate with validity range B..D', [int_bd], out_pem='int_bd.pem') gencerts.write_chain('The target', [target], out_pem='target.pem')<|fim▁end|>
target.set_validity_range(DATE_A, DATE_D)
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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<|fim▁hole|># # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush()<|fim▁end|>
# # http://www.apache.org/licenses/LICENSE-2.0
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 <|fim_middle|> def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html))
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): <|fim_middle|> def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
write(msg, 'TRACE', html)
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): <|fim_middle|> def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
write(msg, 'DEBUG', html)
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): <|fim_middle|> def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
write(msg, 'INFO', html) if also_console: console(msg)
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): <|fim_middle|> def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
write(msg, 'WARN', html)
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): <|fim_middle|> def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
write(msg, 'ERROR', html)
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): <|fim_middle|> <|fim▁end|>
msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush()
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): <|fim_middle|> if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
msg = unic(msg)
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): <|fim_middle|> if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
raise DataError("Invalid log level '%s'." % level)
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: <|fim_middle|> def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
LOGGER.log_message(Message(msg, level, html))
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: <|fim_middle|> def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
console(msg)
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: <|fim_middle|> stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
msg += '\n'
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def <|fim_middle|>(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
write
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def <|fim_middle|>(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
trace
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def <|fim_middle|>(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
debug
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def <|fim_middle|>(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
info
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def <|fim_middle|>(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
warn
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def <|fim_middle|>(msg, html=False): write(msg, 'ERROR', html) def console(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
error
<|file_name|>librarylogger.py<|end_file_name|><|fim▁begin|># Copyright 2008-2015 Nokia Solutions and Networks # # 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. """Implementation of the public test library logging API. This is exposed via :py:mod:`robot.api.logger`. Implementation must reside here to avoid cyclic imports. """ import sys import threading from robot.errors import DataError from robot.utils import unic, encode_output from .logger import LOGGER from .loggerhelper import Message LOGGING_THREADS = ('MainThread', 'RobotFrameworkTimeoutThread') def write(msg, level, html=False): # Callable messages allow lazy logging internally, but we don't want to # expose this functionality publicly. See the following issue for details: # http://code.google.com/p/robotframework/issues/detail?id=1505 if callable(msg): msg = unic(msg) if level.upper() not in ('TRACE', 'DEBUG', 'INFO', 'HTML', 'WARN', 'ERROR'): raise DataError("Invalid log level '%s'." % level) if threading.currentThread().getName() in LOGGING_THREADS: LOGGER.log_message(Message(msg, level, html)) def trace(msg, html=False): write(msg, 'TRACE', html) def debug(msg, html=False): write(msg, 'DEBUG', html) def info(msg, html=False, also_console=False): write(msg, 'INFO', html) if also_console: console(msg) def warn(msg, html=False): write(msg, 'WARN', html) def error(msg, html=False): write(msg, 'ERROR', html) def <|fim_middle|>(msg, newline=True, stream='stdout'): msg = unic(msg) if newline: msg += '\n' stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__ stream.write(encode_output(msg)) stream.flush() <|fim▁end|>
console
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST'])<|fim▁hole|> """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
def update_newvsimtest_info_table():
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arr<|fim_middle|> rray(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
ayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_a
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) <|fim_middle|> _name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else:<|fim_middle|> et_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.g
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: <|fim_middle|> (field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJso<|fim_middle|> e='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
nData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_nam
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'<|fim_middle|> <|fim▁end|>
err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo' <|fim_middle|> _util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
: '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @ap <|fim_middle|> rray(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
i.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_a
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法! <|fim_middle|> ult) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.defa
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/ <|fim_middle|> _name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': <|fim_middle|> i.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
[]} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @ap
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newv <|fim_middle|> et_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
simtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.g
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} <|fim_middle|> insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_i <|fim_middle|> (field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
nfo_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} retu <|fim_middle|> vsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
rn json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_new
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/ <|fim_middle|> e='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_nam
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.du <|fim_middle|> <|fim▁end|>
mps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) <|fim_middle|> <|fim▁end|>
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManul<|fim_middle|>data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
eVsimSrc(array_
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSr<|fim_middle|>ayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
c(array_data=arr
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_da<|fim_middle|> else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
ta=arrayData)
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(arra<|fim_middle|> returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
y_data=arrayData) else:
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=ar<|fim_middle|>eturnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
rayData) else: r
<|file_name|>webModifySqlAPI.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ webModifySqlAPI ~~~~~~~~~~~~~~ 为web应用与后台数据库操作(插入,更新,删除操作)的接口 api_functions 中的DataApiFunc.py为其接口函数汇聚点,所有全局变量设置都在此;所有后台函数调用都在此设置 Implementation helpers for the JSON support in Flask. :copyright: (c) 2015 by Armin kissf lu. :license: ukl, see LICENSE for more details. """ from . import api from flask import json from flask import request from bson import json_util # DataApiFunc 为数据库更新、插入、删除数据等操作函数 from api_functions.DataApiFunc import (deleManuleVsimSrc, insertManuleVsimSrc, updateManuleVsimSrc, deleteNewVsimTestInfo, insertNewVsimTestInfo, updateNewVsimTestInfo) @api.route('/delet_manulVsim/', methods=['POST']) def delet_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_manulVsim/', methods=['POST']) def insert_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_manulVsim/', methods=['POST']) def update_manulVsim(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateManuleVsimSrc(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/delet_newvsimtest_info_table/', methods=['POST']) def delet_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return deleteNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/insert_newvsimtest_info_table/', methods=['POST']) def insert_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return insertNewVsimTestInfo(array_data=arrayData) else: returnJsonData = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default) @api.route('/update_newvsimtest_info_table/', methods=['POST']) def update_newvsimtest_info_table(): """ :return: """ if request.method == 'POST': arrayData = request.get_array(field_name='file') return updateNewVsimTestInfo(array_data=arrayData) <|fim_middle|>ata = {'err': True, 'errinfo': '操作违法!', 'data': []} return json.dumps(returnJsonData, sort_keys=True, indent=4, default=json_util.default)<|fim▁end|>
else: returnJsonD
<|file_name|>app.py<|end_file_name|><|fim▁begin|>import sys sys.path.append("helper") import web from helper import session <|fim▁hole|> urls = ( "/", "controller.start.index", "/1", "controller.start.one", "/2", "controller.start.two", ) app = web.application(urls, globals()) sessions = session.Sessions() if __name__ == "__main__": app.run()<|fim▁end|>
web.config.debug = False
<|file_name|>app.py<|end_file_name|><|fim▁begin|>import sys sys.path.append("helper") import web from helper import session web.config.debug = False urls = ( "/", "controller.start.index", "/1", "controller.start.one", "/2", "controller.start.two", ) app = web.application(urls, globals()) sessions = session.Sessions() if __name__ == "__main__": <|fim_middle|> <|fim▁end|>
app.run()
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter():<|fim▁hole|> def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename)<|fim▁end|>
raise NotImplementedError @staticmethod
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): <|fim_middle|> class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
@staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene)
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): <|fim_middle|> @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
raise NotImplementedError
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): <|fim_middle|> @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
raise NotImplementedError
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): <|fim_middle|> @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
raise NotImplementedError
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): <|fim_middle|> @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
raise NotImplementedError
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): <|fim_middle|> @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
raise NotImplementedError
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): <|fim_middle|> @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end()
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): <|fim_middle|> class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene)
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): <|fim_middle|> class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png")
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): <|fim_middle|> @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
return QtGui.QPixmap(int(size.width()), int(size.height()))
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): <|fim_middle|> @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height())
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): <|fim_middle|> @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
buffer.save(filename, "png")
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): <|fim_middle|> @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): <|fim_middle|> class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
buffer = exporter.export(toBytes=True) buffer.save(filename, "png")
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): <|fim_middle|> class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata)
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): <|fim_middle|> @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
QApplication.clipboard().setPixmap(buffer)
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): <|fim_middle|> class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata)
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): <|fim_middle|> <|fim▁end|>
EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename)
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): <|fim_middle|> @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): <|fim_middle|> @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
return QtCore.QRectF(0, 0, source.width(), source.height())
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): <|fim_middle|> @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
pass
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): <|fim_middle|> @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): <|fim_middle|> <|fim▁end|>
exporter.export(filename)
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): <|fim_middle|> elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
rect = scene.sceneRect()
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): <|fim_middle|> rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
rect = scene.rect()
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: <|fim_middle|> cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
scene = scene['scene']
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: <|fim_middle|> except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base))
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def <|fim_middle|>(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
_get_buffer
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def <|fim_middle|>(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
_get_target
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def <|fim_middle|>(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
_save_buffer
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def <|fim_middle|>(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
_get_exporter
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def <|fim_middle|>(self, exporter, filename): raise NotImplementedError @classmethod def write_image(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
_export
<|file_name|>io.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtGui, QtCore, QtSvg from PyQt4.QtCore import QMimeData from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication from Orange.data.io import FileFormat class ImgFormat(FileFormat): @staticmethod def _get_buffer(size, filename): raise NotImplementedError @staticmethod def _get_target(scene, painter, buffer): raise NotImplementedError @staticmethod def _save_buffer(buffer, filename): raise NotImplementedError @staticmethod def _get_exporter(): raise NotImplementedError @staticmethod def _export(self, exporter, filename): raise NotImplementedError @classmethod def <|fim_middle|>(cls, filename, scene): try: scene = scene.scene() scenerect = scene.sceneRect() #preserve scene bounding rectangle viewrect = scene.views()[0].sceneRect() scene.setSceneRect(viewrect) backgroundbrush = scene.backgroundBrush() #preserve scene background brush scene.setBackgroundBrush(QtCore.Qt.white) exporter = cls._get_exporter() cls._export(exporter(scene), filename) scene.setBackgroundBrush(backgroundbrush) # reset scene background brush scene.setSceneRect(scenerect) # reset scene bounding rectangle except Exception: if isinstance(scene, (QGraphicsScene, QGraphicsView)): rect = scene.sceneRect() elif isinstance(scene, QWidget): rect = scene.rect() rect = rect.adjusted(-15, -15, 15, 15) buffer = cls._get_buffer(rect.size(), filename) painter = QtGui.QPainter() painter.begin(buffer) painter.setRenderHint(QtGui.QPainter.Antialiasing) target = cls._get_target(scene, painter, buffer, rect) try: scene.render(painter, target, rect) except TypeError: scene.render(painter) # PyQt4 QWidget.render() takes different params cls._save_buffer(buffer, filename) painter.end() @classmethod def write(cls, filename, scene): if type(scene) == dict: scene = scene['scene'] cls.write_image(filename, scene) class PngFormat(ImgFormat): EXTENSIONS = ('.png',) DESCRIPTION = 'Portable Network Graphics' PRIORITY = 50 @staticmethod def _get_buffer(size, filename): return QtGui.QPixmap(int(size.width()), int(size.height())) @staticmethod def _get_target(scene, painter, buffer, source): try: brush = scene.backgroundBrush() if brush.style() == QtCore.Qt.NoBrush: brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) except AttributeError: # not a QGraphicsView/Scene brush = QtGui.QBrush(QtCore.Qt.white) painter.fillRect(buffer.rect(), brush) return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): buffer.save(filename, "png") @staticmethod def _get_exporter(): from pyqtgraph.exporters.ImageExporter import ImageExporter return ImageExporter @staticmethod def _export(exporter, filename): buffer = exporter.export(toBytes=True) buffer.save(filename, "png") class ClipboardFormat(PngFormat): EXTENSIONS = () DESCRIPTION = 'System Clipboard' PRIORITY = 50 @staticmethod def _save_buffer(buffer, _): QApplication.clipboard().setPixmap(buffer) @staticmethod def _export(exporter, _): buffer = exporter.export(toBytes=True) mimedata = QMimeData() mimedata.setData("image/png", buffer) QApplication.clipboard().setMimeData(mimedata) class SvgFormat(ImgFormat): EXTENSIONS = ('.svg',) DESCRIPTION = 'Scalable Vector Graphics' PRIORITY = 100 @staticmethod def _get_buffer(size, filename): buffer = QtSvg.QSvgGenerator() buffer.setFileName(filename) buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) return buffer @staticmethod def _get_target(scene, painter, buffer, source): return QtCore.QRectF(0, 0, source.width(), source.height()) @staticmethod def _save_buffer(buffer, filename): pass @staticmethod def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter @staticmethod def _export(exporter, filename): exporter.export(filename) <|fim▁end|>
write_image