prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: <|fim_middle|> def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
return max(values)
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): <|fim_middle|> def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y)
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): <|fim_middle|> def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y)
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': <|fim_middle|> if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width)
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': <|fim_middle|> if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height)
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): <|fim_middle|> except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj)
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): <|fim_middle|> def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
dia.active_display().add_update_all() dia.active_display().flush()
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: <|fim_middle|> else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
win = ResizeWindow(group, data) win.show()
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: <|fim_middle|> dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
dia.message(gtk.MESSAGE_INFO, "Please select a group of objects")
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def <|fim_middle|>(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
__init__
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def <|fim_middle|>(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
initWindow
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def <|fim_middle|>(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
dimensionsFrame
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def <|fim_middle|>(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
enableValueEntry
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def <|fim_middle|>(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
contentsFrameWidth
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def <|fim_middle|>(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
contentsFrameHeight
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def <|fim_middle|>(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
dialogContents
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def <|fim_middle|>(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
getSelectedGroupOption
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def <|fim_middle|>(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
getValue
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def <|fim_middle|>(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
adjustWidth
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def <|fim_middle|>(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
adjustHeight
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def <|fim_middle|>(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
toFloat
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def <|fim_middle|>(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
clickAplicar
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def <|fim_middle|>(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
show
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def <|fim_middle|>(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
hide
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def <|fim_middle|>(self): return self.dlg.run() def dia_group_resize_db (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
run
<|file_name|>group_resize.py<|end_file_name|><|fim▁begin|># # -*- coding: utf-8 -*- # Dia Group Resize Plugin # Copyright (c) 2015, Alexandre Machado <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys, dia import os import pygtk pygtk.require("2.0") import gtk import locale class ResizeWindow(object): def __init__(self, group, data): self.group = group self.data = data self.initWindow() def initWindow(self): self.dlg = gtk.Dialog() self.dlg.set_title('Group Resize') self.dlg.set_border_width(6) self.dlg.vbox.pack_start(self.dialogContents(), fill=True, expand=True, padding=5) self.dlg.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.dlg.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.dlg.set_has_separator(True) self.dlg.set_modal(False) self.dlg.get_widget_for_response(gtk.RESPONSE_CLOSE).connect("clicked", self.hide, None) self.dlg.get_widget_for_response(gtk.RESPONSE_APPLY).connect("clicked", self.clickAplicar, None) def dimensionsFrame(self, label): frame = gtk.Frame(label) table = gtk.Table(rows=4, columns=2) ignore = gtk.RadioButton(group=None, label="do not change") ignore.show() smallest = gtk.RadioButton(group=ignore, label="shrink to smallest") smallest.show() largest = gtk.RadioButton(group=ignore, label="enlarge to largest") largest.show() specify = gtk.RadioButton(group=ignore, label="resize to:") specify.show() value = gtk.Entry() value.show() specify.connect("toggled", self.enableValueEntry, value) self.enableValueEntry(specify, value) table.attach (ignore, 0, 1, 0, 1) table.attach (smallest, 0, 1, 1, 2) table.attach (largest, 0, 1, 2, 3) table.attach (specify, 0, 1, 3, 4) table.attach (value, 1, 2, 3, 4) frame.add(table) table.show() frame.show() options = { 'ignore': ignore, 'smallest': smallest, 'largest': largest, 'specify': specify, 'value': value } return frame, options def enableValueEntry(self, radioSpecify, entrySpecify, *args): entrySpecify.set_sensitive(radioSpecify.get_active()) def contentsFrameWidth(self): frame, self.widthOptions = self.dimensionsFrame('Width') return frame def contentsFrameHeight(self): frame, self.heightOptions = self.dimensionsFrame('Height') return frame def dialogContents(self): contents = gtk.VBox(spacing=5) contents.pack_start(self.contentsFrameWidth(), fill=True, expand=True) contents.pack_start(self.contentsFrameHeight(), fill=True, expand=True) contents.show() return contents def getSelectedGroupOption(self, options): value = options['value'].get_text() for opt in 'ignore', 'smallest', 'largest', 'specify': if options[opt].get_active(): return (opt,value) return ('ignore',value) def getValue(self, opt, value, elProperty): if opt == 'specify': return self.toFloat(value) else: values = [ x.properties[elProperty].value for x in self.group if x.properties.has_key(elProperty) ] if opt == 'smallest': return min(values) else: return max(values) def adjustWidth(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_width"): difference = value - obj.properties['elem_width'].value handleLeft = obj.handles[3] handleRight = obj.handles[4] amount = difference/2 obj.move_handle(handleLeft, (handleLeft.pos.x - amount, handleLeft.pos.y), 0, 0) obj.move_handle(handleRight, (handleRight.pos.x + amount, handleRight.pos.y), 0, 0) obj.move(pos.x, pos.y) def adjustHeight(self, value): for obj in self.group: pos = obj.properties['obj_pos'].value if obj.properties.has_key("elem_height"): difference = value - obj.properties['elem_height'].value handleTop = obj.handles[1] handleBottom = obj.handles[6] amount = difference/2 obj.move_handle(handleTop, (handleTop.pos.x, handleTop.pos.y - amount), 0, 0) obj.move_handle(handleBottom, (handleBottom.pos.x, handleBottom.pos.y + amount), 0, 0) obj.move(pos.x, pos.y) def toFloat(self, valor): return locale.atof(valor) def clickAplicar(self, *args): optWidth = self.getSelectedGroupOption(self.widthOptions) optHeight = self.getSelectedGroupOption(self.heightOptions) try: if optWidth[0] != 'ignore': width = self.getValue(optWidth[0], optWidth[1], 'elem_width') self.adjustWidth(width) if optHeight[0] != 'ignore': height = self.getValue(optHeight[0], optHeight[1], 'elem_height') self.adjustHeight(height) if dia.active_display(): diagram = dia.active_display().diagram for obj in self.group: diagram.update_connections(obj) except Exception,e: dia.message(gtk.MESSAGE_ERROR, repr(e)) if dia.active_display(): dia.active_display().add_update_all() dia.active_display().flush() def show(self): self.dlg.show() def hide(self, *args): self.dlg.hide() def run(self): return self.dlg.run() def <|fim_middle|> (data,flags): diagram = dia.active_display().diagram group = diagram.get_sorted_selected() if len(group) > 0: win = ResizeWindow(group, data) win.show() else: dia.message(gtk.MESSAGE_INFO, "Please select a group of objects") dia.register_action("ObjectGroupResize", "Group Resize", "/DisplayMenu/Objects/ObjectsExtensionStart", dia_group_resize_db) <|fim▁end|>
dia_group_resize_db
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># -*- encoding: utf-8 -*- from . import res_partner_bank<|fim▁hole|><|fim▁end|>
from . import account_bank_statement_import
<|file_name|>sam_to_fastq.py<|end_file_name|><|fim▁begin|><|fim▁hole|> cut=line.split('\t') if len(cut)<11: continue print ">"+cut[0] print cut[9] print "+" print cut[10]<|fim▁end|>
#!/usr/bin/env python2.7 import sys for line in open(sys.argv[1]):
<|file_name|>sam_to_fastq.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2.7 import sys for line in open(sys.argv[1]): cut=line.split('\t') if len(cut)<11: <|fim_middle|> print ">"+cut[0] print cut[9] print "+" print cut[10] <|fim▁end|>
continue
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() <|fim▁hole|> return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules)<|fim▁end|>
@home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements"""
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): <|fim_middle|> @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules) <|fim▁end|>
"""Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles())
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): <|fim_middle|> @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules) <|fim▁end|>
"""Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK'
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): <|fim_middle|> @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules) <|fim▁end|>
"""Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK'
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): <|fim_middle|> @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules) <|fim▁end|>
"""Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK'
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): <|fim_middle|> @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules) <|fim▁end|>
"""Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK'
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): <|fim_middle|> <|fim▁end|>
"""Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules)
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: <|fim_middle|> for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules) <|fim▁end|>
raise Exception("No elements in the list")
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: <|fim_middle|> home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules) <|fim▁end|>
rule['id'] = None
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def <|fim_middle|>(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules) <|fim▁end|>
profiles
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def <|fim_middle|>(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules) <|fim▁end|>
update_element
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def <|fim_middle|>(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules) <|fim▁end|>
update_elements
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def <|fim_middle|>(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules) <|fim▁end|>
delete_element
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def <|fim_middle|>(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules) <|fim▁end|>
timerules
<|file_name|>home_endpoints.py<|end_file_name|><|fim▁begin|># Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def <|fim_middle|>(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules) <|fim▁end|>
get_timerules
<|file_name|>hmm.py<|end_file_name|><|fim▁begin|>hmm = [ "https://media3.giphy.com/media/TPl5N4Ci49ZQY/giphy.gif", "https://media0.giphy.com/media/l14qxlCgJ0zUk/giphy.gif", "https://media4.giphy.com/media/MsWnkCVSXz73i/giphy.gif", "https://media1.giphy.com/media/l2JJEIMLgrXPEbDGM/giphy.gif", "https://media0.giphy.com/media/dgK22exekwOLm/giphy.gif"<|fim▁hole|><|fim▁end|>
]
<|file_name|>0005_auto__add_field_idea_color.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm):<|fim▁hole|> self.gf('django.db.models.fields.CharField')(default='', max_length=100, blank=True), keep_default=False) def backwards(self, orm): # Deleting field 'Idea.color' db.delete_column(u'brainstorming_idea', 'color') models = { u'brainstorming.brainstorming': { 'Meta': {'ordering': "['-created']", 'object_name': 'Brainstorming'}, 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'creator_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'details': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'question': ('django.db.models.fields.CharField', [], {'max_length': '200'}) }, u'brainstorming.brainstormingwatcher': { 'Meta': {'ordering': "['-created']", 'unique_together': "(('brainstorming', 'email'),)", 'object_name': 'BrainstormingWatcher'}, 'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) }, u'brainstorming.emailverification': { 'Meta': {'ordering': "['-created']", 'object_name': 'EmailVerification'}, 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) }, u'brainstorming.idea': { 'Meta': {'ordering': "['-created']", 'object_name': 'Idea'}, 'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}), 'color': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'creator_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'ratings': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'text': ('django.db.models.fields.TextField', [], {}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}) } } complete_apps = ['brainstorming']<|fim▁end|>
# Adding field 'Idea.color' db.add_column(u'brainstorming_idea', 'color',
<|file_name|>0005_auto__add_field_idea_color.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): <|fim_middle|> <|fim▁end|>
def forwards(self, orm): # Adding field 'Idea.color' db.add_column(u'brainstorming_idea', 'color', self.gf('django.db.models.fields.CharField')(default='', max_length=100, blank=True), keep_default=False) def backwards(self, orm): # Deleting field 'Idea.color' db.delete_column(u'brainstorming_idea', 'color') models = { u'brainstorming.brainstorming': { 'Meta': {'ordering': "['-created']", 'object_name': 'Brainstorming'}, 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'creator_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'details': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'question': ('django.db.models.fields.CharField', [], {'max_length': '200'}) }, u'brainstorming.brainstormingwatcher': { 'Meta': {'ordering': "['-created']", 'unique_together': "(('brainstorming', 'email'),)", 'object_name': 'BrainstormingWatcher'}, 'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) }, u'brainstorming.emailverification': { 'Meta': {'ordering': "['-created']", 'object_name': 'EmailVerification'}, 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) }, u'brainstorming.idea': { 'Meta': {'ordering': "['-created']", 'object_name': 'Idea'}, 'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}), 'color': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'creator_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'ratings': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'text': ('django.db.models.fields.TextField', [], {}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}) } } complete_apps = ['brainstorming']
<|file_name|>0005_auto__add_field_idea_color.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'Idea.color' <|fim_middle|> def backwards(self, orm): # Deleting field 'Idea.color' db.delete_column(u'brainstorming_idea', 'color') models = { u'brainstorming.brainstorming': { 'Meta': {'ordering': "['-created']", 'object_name': 'Brainstorming'}, 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'creator_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'details': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'question': ('django.db.models.fields.CharField', [], {'max_length': '200'}) }, u'brainstorming.brainstormingwatcher': { 'Meta': {'ordering': "['-created']", 'unique_together': "(('brainstorming', 'email'),)", 'object_name': 'BrainstormingWatcher'}, 'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) }, u'brainstorming.emailverification': { 'Meta': {'ordering': "['-created']", 'object_name': 'EmailVerification'}, 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) }, u'brainstorming.idea': { 'Meta': {'ordering': "['-created']", 'object_name': 'Idea'}, 'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}), 'color': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'creator_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'ratings': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'text': ('django.db.models.fields.TextField', [], {}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}) } } complete_apps = ['brainstorming']<|fim▁end|>
db.add_column(u'brainstorming_idea', 'color', self.gf('django.db.models.fields.CharField')(default='', max_length=100, blank=True), keep_default=False)
<|file_name|>0005_auto__add_field_idea_color.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'Idea.color' db.add_column(u'brainstorming_idea', 'color', self.gf('django.db.models.fields.CharField')(default='', max_length=100, blank=True), keep_default=False) def backwards(self, orm): # Deleting field 'Idea.color' <|fim_middle|> models = { u'brainstorming.brainstorming': { 'Meta': {'ordering': "['-created']", 'object_name': 'Brainstorming'}, 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'creator_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'details': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'question': ('django.db.models.fields.CharField', [], {'max_length': '200'}) }, u'brainstorming.brainstormingwatcher': { 'Meta': {'ordering': "['-created']", 'unique_together': "(('brainstorming', 'email'),)", 'object_name': 'BrainstormingWatcher'}, 'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) }, u'brainstorming.emailverification': { 'Meta': {'ordering': "['-created']", 'object_name': 'EmailVerification'}, 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) }, u'brainstorming.idea': { 'Meta': {'ordering': "['-created']", 'object_name': 'Idea'}, 'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}), 'color': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'creator_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'ratings': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'text': ('django.db.models.fields.TextField', [], {}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}) } } complete_apps = ['brainstorming']<|fim▁end|>
db.delete_column(u'brainstorming_idea', 'color')
<|file_name|>0005_auto__add_field_idea_color.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def <|fim_middle|>(self, orm): # Adding field 'Idea.color' db.add_column(u'brainstorming_idea', 'color', self.gf('django.db.models.fields.CharField')(default='', max_length=100, blank=True), keep_default=False) def backwards(self, orm): # Deleting field 'Idea.color' db.delete_column(u'brainstorming_idea', 'color') models = { u'brainstorming.brainstorming': { 'Meta': {'ordering': "['-created']", 'object_name': 'Brainstorming'}, 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'creator_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'details': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'question': ('django.db.models.fields.CharField', [], {'max_length': '200'}) }, u'brainstorming.brainstormingwatcher': { 'Meta': {'ordering': "['-created']", 'unique_together': "(('brainstorming', 'email'),)", 'object_name': 'BrainstormingWatcher'}, 'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) }, u'brainstorming.emailverification': { 'Meta': {'ordering': "['-created']", 'object_name': 'EmailVerification'}, 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) }, u'brainstorming.idea': { 'Meta': {'ordering': "['-created']", 'object_name': 'Idea'}, 'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}), 'color': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'creator_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'ratings': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'text': ('django.db.models.fields.TextField', [], {}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}) } } complete_apps = ['brainstorming']<|fim▁end|>
forwards
<|file_name|>0005_auto__add_field_idea_color.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'Idea.color' db.add_column(u'brainstorming_idea', 'color', self.gf('django.db.models.fields.CharField')(default='', max_length=100, blank=True), keep_default=False) def <|fim_middle|>(self, orm): # Deleting field 'Idea.color' db.delete_column(u'brainstorming_idea', 'color') models = { u'brainstorming.brainstorming': { 'Meta': {'ordering': "['-created']", 'object_name': 'Brainstorming'}, 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'creator_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'details': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'question': ('django.db.models.fields.CharField', [], {'max_length': '200'}) }, u'brainstorming.brainstormingwatcher': { 'Meta': {'ordering': "['-created']", 'unique_together': "(('brainstorming', 'email'),)", 'object_name': 'BrainstormingWatcher'}, 'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) }, u'brainstorming.emailverification': { 'Meta': {'ordering': "['-created']", 'object_name': 'EmailVerification'}, 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}) }, u'brainstorming.idea': { 'Meta': {'ordering': "['-created']", 'object_name': 'Idea'}, 'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}), 'color': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'creator_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), 'ratings': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'text': ('django.db.models.fields.TextField', [], {}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}) } } complete_apps = ['brainstorming']<|fim▁end|>
backwards
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|><|fim▁hole|><|fim▁end|>
# -*- coding: utf-8 -*- from exceptions import DropPage, AbortProcess
<|file_name|>pretty.py<|end_file_name|><|fim▁begin|># # Copyright (c) 2021 Project CHIP Authors # # 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. # """Pretty print logging.""" import logging import pprint from typing import Any <|fim▁hole|> for line in pprint.pformat(x).split('\n'): logging.log(level, line) def info(x: Any) -> None: log(logging.INFO, x) def debug(x: Any) -> None: log(logging.DEBUG, x)<|fim▁end|>
def log(level: int, x: Any) -> None: if logging.getLogger(None).isEnabledFor(level):
<|file_name|>pretty.py<|end_file_name|><|fim▁begin|># # Copyright (c) 2021 Project CHIP Authors # # 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. # """Pretty print logging.""" import logging import pprint from typing import Any def log(level: int, x: Any) -> None: <|fim_middle|> def info(x: Any) -> None: log(logging.INFO, x) def debug(x: Any) -> None: log(logging.DEBUG, x) <|fim▁end|>
if logging.getLogger(None).isEnabledFor(level): for line in pprint.pformat(x).split('\n'): logging.log(level, line)
<|file_name|>pretty.py<|end_file_name|><|fim▁begin|># # Copyright (c) 2021 Project CHIP Authors # # 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. # """Pretty print logging.""" import logging import pprint from typing import Any def log(level: int, x: Any) -> None: if logging.getLogger(None).isEnabledFor(level): for line in pprint.pformat(x).split('\n'): logging.log(level, line) def info(x: Any) -> None: <|fim_middle|> def debug(x: Any) -> None: log(logging.DEBUG, x) <|fim▁end|>
log(logging.INFO, x)
<|file_name|>pretty.py<|end_file_name|><|fim▁begin|># # Copyright (c) 2021 Project CHIP Authors # # 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. # """Pretty print logging.""" import logging import pprint from typing import Any def log(level: int, x: Any) -> None: if logging.getLogger(None).isEnabledFor(level): for line in pprint.pformat(x).split('\n'): logging.log(level, line) def info(x: Any) -> None: log(logging.INFO, x) def debug(x: Any) -> None: <|fim_middle|> <|fim▁end|>
log(logging.DEBUG, x)
<|file_name|>pretty.py<|end_file_name|><|fim▁begin|># # Copyright (c) 2021 Project CHIP Authors # # 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. # """Pretty print logging.""" import logging import pprint from typing import Any def log(level: int, x: Any) -> None: if logging.getLogger(None).isEnabledFor(level): <|fim_middle|> def info(x: Any) -> None: log(logging.INFO, x) def debug(x: Any) -> None: log(logging.DEBUG, x) <|fim▁end|>
for line in pprint.pformat(x).split('\n'): logging.log(level, line)
<|file_name|>pretty.py<|end_file_name|><|fim▁begin|># # Copyright (c) 2021 Project CHIP Authors # # 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. # """Pretty print logging.""" import logging import pprint from typing import Any def <|fim_middle|>(level: int, x: Any) -> None: if logging.getLogger(None).isEnabledFor(level): for line in pprint.pformat(x).split('\n'): logging.log(level, line) def info(x: Any) -> None: log(logging.INFO, x) def debug(x: Any) -> None: log(logging.DEBUG, x) <|fim▁end|>
log
<|file_name|>pretty.py<|end_file_name|><|fim▁begin|># # Copyright (c) 2021 Project CHIP Authors # # 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. # """Pretty print logging.""" import logging import pprint from typing import Any def log(level: int, x: Any) -> None: if logging.getLogger(None).isEnabledFor(level): for line in pprint.pformat(x).split('\n'): logging.log(level, line) def <|fim_middle|>(x: Any) -> None: log(logging.INFO, x) def debug(x: Any) -> None: log(logging.DEBUG, x) <|fim▁end|>
info
<|file_name|>pretty.py<|end_file_name|><|fim▁begin|># # Copyright (c) 2021 Project CHIP Authors # # 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. # """Pretty print logging.""" import logging import pprint from typing import Any def log(level: int, x: Any) -> None: if logging.getLogger(None).isEnabledFor(level): for line in pprint.pformat(x).split('\n'): logging.log(level, line) def info(x: Any) -> None: log(logging.INFO, x) def <|fim_middle|>(x: Any) -> None: log(logging.DEBUG, x) <|fim▁end|>
debug
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from quotes.models import Quote from django.contrib import admin class QuoteAdmin(admin.ModelAdmin): list_display = ('message', 'name', 'program', 'class_of',<|fim▁hole|> 'submission_time') admin.site.register(Quote, QuoteAdmin)<|fim▁end|>
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from quotes.models import Quote from django.contrib import admin class QuoteAdmin(admin.ModelAdmin): <|fim_middle|> admin.site.register(Quote, QuoteAdmin) <|fim▁end|>
list_display = ('message', 'name', 'program', 'class_of', 'submission_time')
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def get_user_login_shell(username=None): """ Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: username = getuser() if not isinstance(username, str_cls): username = username.decode('utf-8') if not isinstance(username, str_cls): raise TypeError('username must be a unicode string, not %s' % type_name(username)) if username not in _login_shells: error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): raise OSError('Error!') query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo,<|fim▁hole|> unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): raise OSError('Error!') num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref) _login_shells[username] = login_shell return _login_shells.get(username)<|fim▁end|>
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def get_user_login_shell(username=None): <|fim_middle|> <|fim▁end|>
""" Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: username = getuser() if not isinstance(username, str_cls): username = username.decode('utf-8') if not isinstance(username, str_cls): raise TypeError('username must be a unicode string, not %s' % type_name(username)) if username not in _login_shells: error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): raise OSError('Error!') query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo, unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): raise OSError('Error!') num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref) _login_shells[username] = login_shell return _login_shells.get(username)
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def get_user_login_shell(username=None): """ Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: <|fim_middle|> if not isinstance(username, str_cls): raise TypeError('username must be a unicode string, not %s' % type_name(username)) if username not in _login_shells: error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): raise OSError('Error!') query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo, unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): raise OSError('Error!') num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref) _login_shells[username] = login_shell return _login_shells.get(username) <|fim▁end|>
username = getuser() if not isinstance(username, str_cls): username = username.decode('utf-8')
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def get_user_login_shell(username=None): """ Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: username = getuser() if not isinstance(username, str_cls): <|fim_middle|> if not isinstance(username, str_cls): raise TypeError('username must be a unicode string, not %s' % type_name(username)) if username not in _login_shells: error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): raise OSError('Error!') query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo, unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): raise OSError('Error!') num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref) _login_shells[username] = login_shell return _login_shells.get(username) <|fim▁end|>
username = username.decode('utf-8')
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def get_user_login_shell(username=None): """ Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: username = getuser() if not isinstance(username, str_cls): username = username.decode('utf-8') if not isinstance(username, str_cls): <|fim_middle|> if username not in _login_shells: error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): raise OSError('Error!') query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo, unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): raise OSError('Error!') num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref) _login_shells[username] = login_shell return _login_shells.get(username) <|fim▁end|>
raise TypeError('username must be a unicode string, not %s' % type_name(username))
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def get_user_login_shell(username=None): """ Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: username = getuser() if not isinstance(username, str_cls): username = username.decode('utf-8') if not isinstance(username, str_cls): raise TypeError('username must be a unicode string, not %s' % type_name(username)) if username not in _login_shells: <|fim_middle|> return _login_shells.get(username) <|fim▁end|>
error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): raise OSError('Error!') query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo, unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): raise OSError('Error!') num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref) _login_shells[username] = login_shell
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def get_user_login_shell(username=None): """ Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: username = getuser() if not isinstance(username, str_cls): username = username.decode('utf-8') if not isinstance(username, str_cls): raise TypeError('username must be a unicode string, not %s' % type_name(username)) if username not in _login_shells: error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): <|fim_middle|> node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): raise OSError('Error!') query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo, unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): raise OSError('Error!') num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref) _login_shells[username] = login_shell return _login_shells.get(username) <|fim▁end|>
raise OSError('Error!')
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def get_user_login_shell(username=None): """ Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: username = getuser() if not isinstance(username, str_cls): username = username.decode('utf-8') if not isinstance(username, str_cls): raise TypeError('username must be a unicode string, not %s' % type_name(username)) if username not in _login_shells: error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): <|fim_middle|> query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo, unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): raise OSError('Error!') num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref) _login_shells[username] = login_shell return _login_shells.get(username) <|fim▁end|>
raise OSError('Error!')
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def get_user_login_shell(username=None): """ Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: username = getuser() if not isinstance(username, str_cls): username = username.decode('utf-8') if not isinstance(username, str_cls): raise TypeError('username must be a unicode string, not %s' % type_name(username)) if username not in _login_shells: error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): raise OSError('Error!') query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo, unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): <|fim_middle|> results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): raise OSError('Error!') num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref) _login_shells[username] = login_shell return _login_shells.get(username) <|fim▁end|>
raise OSError('Error!')
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def get_user_login_shell(username=None): """ Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: username = getuser() if not isinstance(username, str_cls): username = username.decode('utf-8') if not isinstance(username, str_cls): raise TypeError('username must be a unicode string, not %s' % type_name(username)) if username not in _login_shells: error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): raise OSError('Error!') query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo, unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): <|fim_middle|> login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): raise OSError('Error!') num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref) _login_shells[username] = login_shell return _login_shells.get(username) <|fim▁end|>
raise OSError('Error!')
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def get_user_login_shell(username=None): """ Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: username = getuser() if not isinstance(username, str_cls): username = username.decode('utf-8') if not isinstance(username, str_cls): raise TypeError('username must be a unicode string, not %s' % type_name(username)) if username not in _login_shells: error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): raise OSError('Error!') query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo, unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: <|fim_middle|> _login_shells[username] = login_shell return _login_shells.get(username) <|fim▁end|>
od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): raise OSError('Error!') num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref)
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def get_user_login_shell(username=None): """ Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: username = getuser() if not isinstance(username, str_cls): username = username.decode('utf-8') if not isinstance(username, str_cls): raise TypeError('username must be a unicode string, not %s' % type_name(username)) if username not in _login_shells: error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): raise OSError('Error!') query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo, unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): <|fim_middle|> num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref) _login_shells[username] = login_shell return _login_shells.get(username) <|fim▁end|>
raise OSError('Error!')
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def get_user_login_shell(username=None): """ Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: username = getuser() if not isinstance(username, str_cls): username = username.decode('utf-8') if not isinstance(username, str_cls): raise TypeError('username must be a unicode string, not %s' % type_name(username)) if username not in _login_shells: error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): raise OSError('Error!') query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo, unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): raise OSError('Error!') num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: <|fim_middle|> _login_shells[username] = login_shell return _login_shells.get(username) <|fim▁end|>
string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref)
<|file_name|>open_directory.py<|end_file_name|><|fim▁begin|># coding: utf-8 from __future__ import unicode_literals, division, absolute_import, print_function from getpass import getuser import ctypes from ctypes.util import find_library from ctypes import c_void_p, c_uint32, POINTER, c_bool, byref from .core_foundation import CoreFoundation, unicode_to_cfstring, cfstring_to_unicode from .._types import str_cls, type_name od_path = find_library('OpenDirectory') OpenDirectory = ctypes.CDLL(od_path, use_errno=True) ODAttributeType = CoreFoundation.CFStringRef ODMatchType = c_uint32 ODRecordType = CoreFoundation.CFStringRef ODSessionRef = c_void_p ODNodeRef = c_void_p ODQueryRef = c_void_p ODRecordRef = c_void_p OpenDirectory.ODSessionCreate.argtypes = [ CoreFoundation.CFAllocatorRef, CoreFoundation.CFDictionaryRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODSessionCreate.restype = ODSessionRef OpenDirectory.ODNodeCreateWithName.argtypes = [ CoreFoundation.CFAllocatorRef, ODSessionRef, CoreFoundation.CFStringRef, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODNodeCreateWithName.restype = ODNodeRef OpenDirectory.ODQueryCreateWithNode.argtypes = [ CoreFoundation.CFAllocatorRef, ODNodeRef, CoreFoundation.CFTypeRef, ODAttributeType, ODMatchType, CoreFoundation.CFTypeRef, CoreFoundation.CFTypeRef, CoreFoundation.CFIndex, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCreateWithNode.restype = ODQueryRef OpenDirectory.ODQueryCopyResults.argtypes = [ ODQueryRef, c_bool, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODQueryCopyResults.restype = CoreFoundation.CFArrayRef OpenDirectory.ODRecordCopyValues.argtypes = [ ODRecordRef, ODAttributeType, POINTER(CoreFoundation.CFErrorRef) ] OpenDirectory.ODRecordCopyValues.restype = CoreFoundation.CFArrayRef kODMatchEqualTo = ODMatchType(0x2001) kODRecordTypeUsers = ODRecordType.in_dll(OpenDirectory, 'kODRecordTypeUsers') kODAttributeTypeRecordName = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeRecordName') kODAttributeTypeUserShell = ODAttributeType.in_dll(OpenDirectory, 'kODAttributeTypeUserShell') _login_shells = {} def <|fim_middle|>(username=None): """ Uses OS X's OpenDirectory.framework to get the user's login shell :param username: A unicode string of the user to get the shell for - None for the current user :return: A unicode string of the user's login shell """ if username is None: username = getuser() if not isinstance(username, str_cls): username = username.decode('utf-8') if not isinstance(username, str_cls): raise TypeError('username must be a unicode string, not %s' % type_name(username)) if username not in _login_shells: error_ref = CoreFoundation.CFErrorRef() session = OpenDirectory.ODSessionCreate( CoreFoundation.kCFAllocatorDefault, None, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') node = OpenDirectory.ODNodeCreateWithName( CoreFoundation.kCFAllocatorDefault, session, unicode_to_cfstring("/Local/Default"), byref(error_ref) ) if bool(error_ref): raise OSError('Error!') query = OpenDirectory.ODQueryCreateWithNode( CoreFoundation.kCFAllocatorDefault, node, kODRecordTypeUsers, kODAttributeTypeRecordName, kODMatchEqualTo, unicode_to_cfstring(username), kODAttributeTypeUserShell, 1, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') results = OpenDirectory.ODQueryCopyResults( query, False, byref(error_ref) ) if bool(error_ref): raise OSError('Error!') login_shell = None num_results = CoreFoundation.CFArrayGetCount(results) if num_results == 1: od_record = CoreFoundation.CFArrayGetValueAtIndex(results, 0) attributes = OpenDirectory.ODRecordCopyValues(od_record, kODAttributeTypeUserShell, byref(error_ref)) if bool(error_ref): raise OSError('Error!') num_attributes = CoreFoundation.CFArrayGetCount(results) if num_attributes == 1: string_ref = CoreFoundation.CFArrayGetValueAtIndex(attributes, 0) login_shell = cfstring_to_unicode(string_ref) _login_shells[username] = login_shell return _login_shells.get(username) <|fim▁end|>
get_user_login_shell
<|file_name|>plano.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from django import forms from django.utils.translation import ugettext_lazy as _ from django.forms import inlineformset_factory from djangosige.apps.financeiro.models import PlanoContasGrupo, PlanoContasSubgrupo class PlanoContasGrupoForm(forms.ModelForm): class Meta:<|fim▁hole|> widgets = { 'descricao': forms.TextInput(attrs={'class': 'form-control'}), 'tipo_grupo': forms.Select(attrs={'class': 'form-control'}), } labels = { 'descricao': _('Descrição'), 'tipo_grupo': _('Tipo de lançamento'), } class PlanoContasSubgrupoForm(forms.ModelForm): class Meta: model = PlanoContasSubgrupo fields = ('descricao',) widgets = { 'descricao': forms.TextInput(attrs={'class': 'form-control'}), } labels = { 'descricao': _('Descrição'), } PlanoContasSubgrupoFormSet = inlineformset_factory( PlanoContasGrupo, PlanoContasSubgrupo, form=PlanoContasSubgrupoForm, fk_name='grupo', extra=1, can_delete=True)<|fim▁end|>
model = PlanoContasGrupo fields = ('tipo_grupo', 'descricao',)
<|file_name|>plano.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from django import forms from django.utils.translation import ugettext_lazy as _ from django.forms import inlineformset_factory from djangosige.apps.financeiro.models import PlanoContasGrupo, PlanoContasSubgrupo class PlanoContasGrupoForm(forms.ModelForm): <|fim_middle|> class PlanoContasSubgrupoForm(forms.ModelForm): class Meta: model = PlanoContasSubgrupo fields = ('descricao',) widgets = { 'descricao': forms.TextInput(attrs={'class': 'form-control'}), } labels = { 'descricao': _('Descrição'), } PlanoContasSubgrupoFormSet = inlineformset_factory( PlanoContasGrupo, PlanoContasSubgrupo, form=PlanoContasSubgrupoForm, fk_name='grupo', extra=1, can_delete=True) <|fim▁end|>
class Meta: model = PlanoContasGrupo fields = ('tipo_grupo', 'descricao',) widgets = { 'descricao': forms.TextInput(attrs={'class': 'form-control'}), 'tipo_grupo': forms.Select(attrs={'class': 'form-control'}), } labels = { 'descricao': _('Descrição'), 'tipo_grupo': _('Tipo de lançamento'), }
<|file_name|>plano.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from django import forms from django.utils.translation import ugettext_lazy as _ from django.forms import inlineformset_factory from djangosige.apps.financeiro.models import PlanoContasGrupo, PlanoContasSubgrupo class PlanoContasGrupoForm(forms.ModelForm): class Meta: <|fim_middle|> class PlanoContasSubgrupoForm(forms.ModelForm): class Meta: model = PlanoContasSubgrupo fields = ('descricao',) widgets = { 'descricao': forms.TextInput(attrs={'class': 'form-control'}), } labels = { 'descricao': _('Descrição'), } PlanoContasSubgrupoFormSet = inlineformset_factory( PlanoContasGrupo, PlanoContasSubgrupo, form=PlanoContasSubgrupoForm, fk_name='grupo', extra=1, can_delete=True) <|fim▁end|>
model = PlanoContasGrupo fields = ('tipo_grupo', 'descricao',) widgets = { 'descricao': forms.TextInput(attrs={'class': 'form-control'}), 'tipo_grupo': forms.Select(attrs={'class': 'form-control'}), } labels = { 'descricao': _('Descrição'), 'tipo_grupo': _('Tipo de lançamento'), }
<|file_name|>plano.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from django import forms from django.utils.translation import ugettext_lazy as _ from django.forms import inlineformset_factory from djangosige.apps.financeiro.models import PlanoContasGrupo, PlanoContasSubgrupo class PlanoContasGrupoForm(forms.ModelForm): class Meta: model = PlanoContasGrupo fields = ('tipo_grupo', 'descricao',) widgets = { 'descricao': forms.TextInput(attrs={'class': 'form-control'}), 'tipo_grupo': forms.Select(attrs={'class': 'form-control'}), } labels = { 'descricao': _('Descrição'), 'tipo_grupo': _('Tipo de lançamento'), } class PlanoContasSubgrupoForm(forms.ModelForm): cla<|fim_middle|> anoContasSubgrupoFormSet = inlineformset_factory( PlanoContasGrupo, PlanoContasSubgrupo, form=PlanoContasSubgrupoForm, fk_name='grupo', extra=1, can_delete=True) <|fim▁end|>
ss Meta: model = PlanoContasSubgrupo fields = ('descricao',) widgets = { 'descricao': forms.TextInput(attrs={'class': 'form-control'}), } labels = { 'descricao': _('Descrição'), } Pl
<|file_name|>plano.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from django import forms from django.utils.translation import ugettext_lazy as _ from django.forms import inlineformset_factory from djangosige.apps.financeiro.models import PlanoContasGrupo, PlanoContasSubgrupo class PlanoContasGrupoForm(forms.ModelForm): class Meta: model = PlanoContasGrupo fields = ('tipo_grupo', 'descricao',) widgets = { 'descricao': forms.TextInput(attrs={'class': 'form-control'}), 'tipo_grupo': forms.Select(attrs={'class': 'form-control'}), } labels = { 'descricao': _('Descrição'), 'tipo_grupo': _('Tipo de lançamento'), } class PlanoContasSubgrupoForm(forms.ModelForm): class Meta: mod<|fim_middle|> anoContasSubgrupoFormSet = inlineformset_factory( PlanoContasGrupo, PlanoContasSubgrupo, form=PlanoContasSubgrupoForm, fk_name='grupo', extra=1, can_delete=True) <|fim▁end|>
el = PlanoContasSubgrupo fields = ('descricao',) widgets = { 'descricao': forms.TextInput(attrs={'class': 'form-control'}), } labels = { 'descricao': _('Descrição'), } Pl
<|file_name|>para_training_local.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # setup of the grid parameters <|fim▁hole|> # the queue that is used solely for the final ISV training step isv_training_queue = { 'queue':'q1wm', 'memfree':'32G', 'pe_opt':'pe_mth 4', 'hvmem':'8G' } # number of audio files that one job should preprocess number_of_audio_files_per_job = 1000 preprocessing_queue = {} # number of features that one job should extract number_of_features_per_job = 600 extraction_queue = { 'queue':'q1d', 'memfree':'8G' } # number of features that one job should project number_of_projections_per_job = 600 projection_queue = { 'queue':'q1d', 'hvmem':'8G', 'memfree':'8G' } # number of models that one job should enroll number_of_models_per_enrol_job = 20 enrol_queue = { 'queue':'q1d', 'memfree':'4G', 'io_big':True } # number of models that one score job should process number_of_models_per_score_job = 20 score_queue = { 'queue':'q1d', 'memfree':'4G', 'io_big':True } grid_type = 'local' # on Idiap grid<|fim▁end|>
# default queue used for training training_queue = { 'queue':'q1dm', 'memfree':'16G', 'pe_opt':'pe_mth 2', 'hvmem':'8G', 'io_big':True }
<|file_name|>tests.py<|end_file_name|><|fim▁begin|>TESTS = { "Level_1": [ { "input": [1, 2, 3], "answer": 2, "explanation": "3-1=2" }, { "input": [5, -5], "answer": 10, "explanation": "5-(-5)=10" }, { "input": [10.2, -2.2, 0, 1.1, 0.5], "answer": 12.4, "explanation": "10.2-(-2.2)=12.4" }, { "input": [], "answer": 0, "explanation": "Empty" }, {"input": [-99.9, 99.9], "answer": 199.8, "explanation": "99.9-(-99.9)"}, {"input": [1, 1], "answer": 0, "explanation": "1-1"}, {"input": [0, 0, 0, 0], "answer": 0, "explanation": "0-0"}, {"input": [36.0, -26.0, -7.5, 0.9, 0.53, -6.6, -71.0, 0.53, -48.0, 57.0, 69.0, 0.063, -4.7, 0.01, 9.2], "answer": 140.0, "explanation": "69.0-(-71.0)"}, {"input": [-0.035, 0.0, -0.1, 83.0, 0.28, 60.0], "answer": 83.1, "explanation": "83.0-(-0.1)"}, {"input": [0.02, 0.93, 0.066, -94.0, -0.91, -21.0, -7.2, -0.018, 26.0], "answer": 120.0, "explanation": "26.0-(-94.0)"}, {"input": [89.0, 0.014, 2.9, -1.2, 5.8], "answer": 90.2, "explanation": "89.0-(-1.2)"}, {"input": [-69.0, 0.0, 0.0, -0.051, -0.021, -0.81], "answer": 69.0, "explanation": "0.0-(-69.0)"}, {"input": [-0.07], "answer": 0.0, "explanation": "-0.07-(-0.07)"}, {"input": [0.074, 0.12, -0.4, 4.0, -1.7, 3.0, -5.1, 0.57, -54.0, -41.0, -5.2, -5.6, 3.8, 0.054, -35.0, -5.0, -0.005, 0.034], "answer": 58.0, "explanation": "4.0-(-54.0)"}, {"input": [29.0, 0.47, -4.5, -6.7, -0.051, -0.82, -0.074, -4.0, -0.015, -0.015, -8.0, -0.43],<|fim▁hole|> {"input": [-0.036, -0.11, -0.55, -64.0], "answer": 63.964, "explanation": "-0.036-(-64.0)"}, {"input": [-0.092, -0.079, -0.31, -0.87, -28.0, -6.2, -0.097, -5.8, -0.025, -28.0, -4.7, -2.9, -8.0, -0.093, -13.0, -73.0], "answer": 72.975, "explanation": "-0.025-(-73.0)"}, {"input": [-0.015, 7.6], "answer": 7.615, "explanation": "7.6-(-0.015)"}, {"input": [-46.0, 0.19, -0.08, -4.0, 4.4, 0.071, -0.029, -0.034, 28.0, 0.043, -97.0], "answer": 125.0, "explanation": "28.0-(-97.0)"}, {"input": [32.0, -0.07, -0.056, -6.4, 0.084], "answer": 38.4, "explanation": "32.0-(-6.4)"}, {"input": [0.017, 0.015, 0.69, 0.78], "answer": 0.765, "explanation": "0.78-0.015"}, ] }<|fim▁end|>
"answer": 37.0, "explanation": "29.0-(-8.0)"},
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """ Copyright (c) 2006-2016 sqlmap developers (http://sqlmap.org/) See the file 'doc/COPYING' for copying permission """ <|fim▁hole|>from plugins.dbms.maxdb.enumeration import Enumeration from plugins.dbms.maxdb.filesystem import Filesystem from plugins.dbms.maxdb.fingerprint import Fingerprint from plugins.dbms.maxdb.syntax import Syntax from plugins.dbms.maxdb.takeover import Takeover from plugins.generic.misc import Miscellaneous class MaxDBMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Takeover): """ This class defines SAP MaxDB methods """ def __init__(self): self.excludeDbsList = MAXDB_SYSTEM_DBS Syntax.__init__(self) Fingerprint.__init__(self) Enumeration.__init__(self) Filesystem.__init__(self) Miscellaneous.__init__(self) Takeover.__init__(self) unescaper[DBMS.MAXDB] = Syntax.escape<|fim▁end|>
from lib.core.enums import DBMS from lib.core.settings import MAXDB_SYSTEM_DBS from lib.core.unescaper import unescaper
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """ Copyright (c) 2006-2016 sqlmap developers (http://sqlmap.org/) See the file 'doc/COPYING' for copying permission """ from lib.core.enums import DBMS from lib.core.settings import MAXDB_SYSTEM_DBS from lib.core.unescaper import unescaper from plugins.dbms.maxdb.enumeration import Enumeration from plugins.dbms.maxdb.filesystem import Filesystem from plugins.dbms.maxdb.fingerprint import Fingerprint from plugins.dbms.maxdb.syntax import Syntax from plugins.dbms.maxdb.takeover import Takeover from plugins.generic.misc import Miscellaneous class MaxDBMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Takeover): <|fim_middle|> <|fim▁end|>
""" This class defines SAP MaxDB methods """ def __init__(self): self.excludeDbsList = MAXDB_SYSTEM_DBS Syntax.__init__(self) Fingerprint.__init__(self) Enumeration.__init__(self) Filesystem.__init__(self) Miscellaneous.__init__(self) Takeover.__init__(self) unescaper[DBMS.MAXDB] = Syntax.escape
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """ Copyright (c) 2006-2016 sqlmap developers (http://sqlmap.org/) See the file 'doc/COPYING' for copying permission """ from lib.core.enums import DBMS from lib.core.settings import MAXDB_SYSTEM_DBS from lib.core.unescaper import unescaper from plugins.dbms.maxdb.enumeration import Enumeration from plugins.dbms.maxdb.filesystem import Filesystem from plugins.dbms.maxdb.fingerprint import Fingerprint from plugins.dbms.maxdb.syntax import Syntax from plugins.dbms.maxdb.takeover import Takeover from plugins.generic.misc import Miscellaneous class MaxDBMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Takeover): """ This class defines SAP MaxDB methods """ def __init__(self): <|fim_middle|> unescaper[DBMS.MAXDB] = Syntax.escape <|fim▁end|>
self.excludeDbsList = MAXDB_SYSTEM_DBS Syntax.__init__(self) Fingerprint.__init__(self) Enumeration.__init__(self) Filesystem.__init__(self) Miscellaneous.__init__(self) Takeover.__init__(self)
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """ Copyright (c) 2006-2016 sqlmap developers (http://sqlmap.org/) See the file 'doc/COPYING' for copying permission """ from lib.core.enums import DBMS from lib.core.settings import MAXDB_SYSTEM_DBS from lib.core.unescaper import unescaper from plugins.dbms.maxdb.enumeration import Enumeration from plugins.dbms.maxdb.filesystem import Filesystem from plugins.dbms.maxdb.fingerprint import Fingerprint from plugins.dbms.maxdb.syntax import Syntax from plugins.dbms.maxdb.takeover import Takeover from plugins.generic.misc import Miscellaneous class MaxDBMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Takeover): """ This class defines SAP MaxDB methods """ def <|fim_middle|>(self): self.excludeDbsList = MAXDB_SYSTEM_DBS Syntax.__init__(self) Fingerprint.__init__(self) Enumeration.__init__(self) Filesystem.__init__(self) Miscellaneous.__init__(self) Takeover.__init__(self) unescaper[DBMS.MAXDB] = Syntax.escape <|fim▁end|>
__init__
<|file_name|>pkg_config.py<|end_file_name|><|fim▁begin|>from __future__ import print_function import shlex import subprocess import sys from .config import Configuration class PkgConfig(object): class Error(Exception): """Raised when information could not be obtained from pkg-config.""" def __init__(self, package_name): """Query pkg-config for information about a package. :type package_name: str :param package_name: The name of the package to query. :raises PkgConfig.Error: When a call to pkg-config fails. """ self.package_name = package_name self._cflags = self._call("--cflags") self._cflags_only_I = self._call("--cflags-only-I") self._cflags_only_other = self._call("--cflags-only-other") self._libs = self._call("--libs") self._libs_only_l = self._call("--libs-only-l") self._libs_only_L = self._call("--libs-only-L") self._libs_only_other = self._call("--libs-only-other") def _call(self, *pkg_config_args): try: cmd = [Configuration.current.pkg_config] + list(pkg_config_args) + [self.package_name] print("Executing command '{}'".format(cmd), file=sys.stderr) return shlex.split(subprocess.check_output(cmd).decode('utf-8')) except subprocess.CalledProcessError as e: raise self.Error("pkg-config exited with error code {}".format(e.returncode)) <|fim▁hole|> def swiftc_flags(self): """Flags for this package in a format suitable for passing to `swiftc`. :rtype: list[str] """ return ( ["-Xcc {}".format(s) for s in self._cflags_only_other] + ["-Xlinker {}".format(s) for s in self._libs_only_other] + self._cflags_only_I + self._libs_only_L + self._libs_only_l) @property def cflags(self): """CFLAGS for this package. :rtype: list[str] """ return self._cflags @property def ldflags(self): """LDFLAGS for this package. :rtype: list[str] """ return self._libs<|fim▁end|>
@property
<|file_name|>pkg_config.py<|end_file_name|><|fim▁begin|>from __future__ import print_function import shlex import subprocess import sys from .config import Configuration class PkgConfig(object): <|fim_middle|> <|fim▁end|>
class Error(Exception): """Raised when information could not be obtained from pkg-config.""" def __init__(self, package_name): """Query pkg-config for information about a package. :type package_name: str :param package_name: The name of the package to query. :raises PkgConfig.Error: When a call to pkg-config fails. """ self.package_name = package_name self._cflags = self._call("--cflags") self._cflags_only_I = self._call("--cflags-only-I") self._cflags_only_other = self._call("--cflags-only-other") self._libs = self._call("--libs") self._libs_only_l = self._call("--libs-only-l") self._libs_only_L = self._call("--libs-only-L") self._libs_only_other = self._call("--libs-only-other") def _call(self, *pkg_config_args): try: cmd = [Configuration.current.pkg_config] + list(pkg_config_args) + [self.package_name] print("Executing command '{}'".format(cmd), file=sys.stderr) return shlex.split(subprocess.check_output(cmd).decode('utf-8')) except subprocess.CalledProcessError as e: raise self.Error("pkg-config exited with error code {}".format(e.returncode)) @property def swiftc_flags(self): """Flags for this package in a format suitable for passing to `swiftc`. :rtype: list[str] """ return ( ["-Xcc {}".format(s) for s in self._cflags_only_other] + ["-Xlinker {}".format(s) for s in self._libs_only_other] + self._cflags_only_I + self._libs_only_L + self._libs_only_l) @property def cflags(self): """CFLAGS for this package. :rtype: list[str] """ return self._cflags @property def ldflags(self): """LDFLAGS for this package. :rtype: list[str] """ return self._libs
<|file_name|>pkg_config.py<|end_file_name|><|fim▁begin|>from __future__ import print_function import shlex import subprocess import sys from .config import Configuration class PkgConfig(object): class Error(Exception): <|fim_middle|> def __init__(self, package_name): """Query pkg-config for information about a package. :type package_name: str :param package_name: The name of the package to query. :raises PkgConfig.Error: When a call to pkg-config fails. """ self.package_name = package_name self._cflags = self._call("--cflags") self._cflags_only_I = self._call("--cflags-only-I") self._cflags_only_other = self._call("--cflags-only-other") self._libs = self._call("--libs") self._libs_only_l = self._call("--libs-only-l") self._libs_only_L = self._call("--libs-only-L") self._libs_only_other = self._call("--libs-only-other") def _call(self, *pkg_config_args): try: cmd = [Configuration.current.pkg_config] + list(pkg_config_args) + [self.package_name] print("Executing command '{}'".format(cmd), file=sys.stderr) return shlex.split(subprocess.check_output(cmd).decode('utf-8')) except subprocess.CalledProcessError as e: raise self.Error("pkg-config exited with error code {}".format(e.returncode)) @property def swiftc_flags(self): """Flags for this package in a format suitable for passing to `swiftc`. :rtype: list[str] """ return ( ["-Xcc {}".format(s) for s in self._cflags_only_other] + ["-Xlinker {}".format(s) for s in self._libs_only_other] + self._cflags_only_I + self._libs_only_L + self._libs_only_l) @property def cflags(self): """CFLAGS for this package. :rtype: list[str] """ return self._cflags @property def ldflags(self): """LDFLAGS for this package. :rtype: list[str] """ return self._libs <|fim▁end|>
"""Raised when information could not be obtained from pkg-config."""
<|file_name|>pkg_config.py<|end_file_name|><|fim▁begin|>from __future__ import print_function import shlex import subprocess import sys from .config import Configuration class PkgConfig(object): class Error(Exception): """Raised when information could not be obtained from pkg-config.""" def __init__(self, package_name): <|fim_middle|> def _call(self, *pkg_config_args): try: cmd = [Configuration.current.pkg_config] + list(pkg_config_args) + [self.package_name] print("Executing command '{}'".format(cmd), file=sys.stderr) return shlex.split(subprocess.check_output(cmd).decode('utf-8')) except subprocess.CalledProcessError as e: raise self.Error("pkg-config exited with error code {}".format(e.returncode)) @property def swiftc_flags(self): """Flags for this package in a format suitable for passing to `swiftc`. :rtype: list[str] """ return ( ["-Xcc {}".format(s) for s in self._cflags_only_other] + ["-Xlinker {}".format(s) for s in self._libs_only_other] + self._cflags_only_I + self._libs_only_L + self._libs_only_l) @property def cflags(self): """CFLAGS for this package. :rtype: list[str] """ return self._cflags @property def ldflags(self): """LDFLAGS for this package. :rtype: list[str] """ return self._libs <|fim▁end|>
"""Query pkg-config for information about a package. :type package_name: str :param package_name: The name of the package to query. :raises PkgConfig.Error: When a call to pkg-config fails. """ self.package_name = package_name self._cflags = self._call("--cflags") self._cflags_only_I = self._call("--cflags-only-I") self._cflags_only_other = self._call("--cflags-only-other") self._libs = self._call("--libs") self._libs_only_l = self._call("--libs-only-l") self._libs_only_L = self._call("--libs-only-L") self._libs_only_other = self._call("--libs-only-other")
<|file_name|>pkg_config.py<|end_file_name|><|fim▁begin|>from __future__ import print_function import shlex import subprocess import sys from .config import Configuration class PkgConfig(object): class Error(Exception): """Raised when information could not be obtained from pkg-config.""" def __init__(self, package_name): """Query pkg-config for information about a package. :type package_name: str :param package_name: The name of the package to query. :raises PkgConfig.Error: When a call to pkg-config fails. """ self.package_name = package_name self._cflags = self._call("--cflags") self._cflags_only_I = self._call("--cflags-only-I") self._cflags_only_other = self._call("--cflags-only-other") self._libs = self._call("--libs") self._libs_only_l = self._call("--libs-only-l") self._libs_only_L = self._call("--libs-only-L") self._libs_only_other = self._call("--libs-only-other") def _call(self, *pkg_config_args): <|fim_middle|> @property def swiftc_flags(self): """Flags for this package in a format suitable for passing to `swiftc`. :rtype: list[str] """ return ( ["-Xcc {}".format(s) for s in self._cflags_only_other] + ["-Xlinker {}".format(s) for s in self._libs_only_other] + self._cflags_only_I + self._libs_only_L + self._libs_only_l) @property def cflags(self): """CFLAGS for this package. :rtype: list[str] """ return self._cflags @property def ldflags(self): """LDFLAGS for this package. :rtype: list[str] """ return self._libs <|fim▁end|>
try: cmd = [Configuration.current.pkg_config] + list(pkg_config_args) + [self.package_name] print("Executing command '{}'".format(cmd), file=sys.stderr) return shlex.split(subprocess.check_output(cmd).decode('utf-8')) except subprocess.CalledProcessError as e: raise self.Error("pkg-config exited with error code {}".format(e.returncode))
<|file_name|>pkg_config.py<|end_file_name|><|fim▁begin|>from __future__ import print_function import shlex import subprocess import sys from .config import Configuration class PkgConfig(object): class Error(Exception): """Raised when information could not be obtained from pkg-config.""" def __init__(self, package_name): """Query pkg-config for information about a package. :type package_name: str :param package_name: The name of the package to query. :raises PkgConfig.Error: When a call to pkg-config fails. """ self.package_name = package_name self._cflags = self._call("--cflags") self._cflags_only_I = self._call("--cflags-only-I") self._cflags_only_other = self._call("--cflags-only-other") self._libs = self._call("--libs") self._libs_only_l = self._call("--libs-only-l") self._libs_only_L = self._call("--libs-only-L") self._libs_only_other = self._call("--libs-only-other") def _call(self, *pkg_config_args): try: cmd = [Configuration.current.pkg_config] + list(pkg_config_args) + [self.package_name] print("Executing command '{}'".format(cmd), file=sys.stderr) return shlex.split(subprocess.check_output(cmd).decode('utf-8')) except subprocess.CalledProcessError as e: raise self.Error("pkg-config exited with error code {}".format(e.returncode)) @property def swiftc_flags(self): <|fim_middle|> @property def cflags(self): """CFLAGS for this package. :rtype: list[str] """ return self._cflags @property def ldflags(self): """LDFLAGS for this package. :rtype: list[str] """ return self._libs <|fim▁end|>
"""Flags for this package in a format suitable for passing to `swiftc`. :rtype: list[str] """ return ( ["-Xcc {}".format(s) for s in self._cflags_only_other] + ["-Xlinker {}".format(s) for s in self._libs_only_other] + self._cflags_only_I + self._libs_only_L + self._libs_only_l)
<|file_name|>pkg_config.py<|end_file_name|><|fim▁begin|>from __future__ import print_function import shlex import subprocess import sys from .config import Configuration class PkgConfig(object): class Error(Exception): """Raised when information could not be obtained from pkg-config.""" def __init__(self, package_name): """Query pkg-config for information about a package. :type package_name: str :param package_name: The name of the package to query. :raises PkgConfig.Error: When a call to pkg-config fails. """ self.package_name = package_name self._cflags = self._call("--cflags") self._cflags_only_I = self._call("--cflags-only-I") self._cflags_only_other = self._call("--cflags-only-other") self._libs = self._call("--libs") self._libs_only_l = self._call("--libs-only-l") self._libs_only_L = self._call("--libs-only-L") self._libs_only_other = self._call("--libs-only-other") def _call(self, *pkg_config_args): try: cmd = [Configuration.current.pkg_config] + list(pkg_config_args) + [self.package_name] print("Executing command '{}'".format(cmd), file=sys.stderr) return shlex.split(subprocess.check_output(cmd).decode('utf-8')) except subprocess.CalledProcessError as e: raise self.Error("pkg-config exited with error code {}".format(e.returncode)) @property def swiftc_flags(self): """Flags for this package in a format suitable for passing to `swiftc`. :rtype: list[str] """ return ( ["-Xcc {}".format(s) for s in self._cflags_only_other] + ["-Xlinker {}".format(s) for s in self._libs_only_other] + self._cflags_only_I + self._libs_only_L + self._libs_only_l) @property def cflags(self): <|fim_middle|> @property def ldflags(self): """LDFLAGS for this package. :rtype: list[str] """ return self._libs <|fim▁end|>
"""CFLAGS for this package. :rtype: list[str] """ return self._cflags
<|file_name|>pkg_config.py<|end_file_name|><|fim▁begin|>from __future__ import print_function import shlex import subprocess import sys from .config import Configuration class PkgConfig(object): class Error(Exception): """Raised when information could not be obtained from pkg-config.""" def __init__(self, package_name): """Query pkg-config for information about a package. :type package_name: str :param package_name: The name of the package to query. :raises PkgConfig.Error: When a call to pkg-config fails. """ self.package_name = package_name self._cflags = self._call("--cflags") self._cflags_only_I = self._call("--cflags-only-I") self._cflags_only_other = self._call("--cflags-only-other") self._libs = self._call("--libs") self._libs_only_l = self._call("--libs-only-l") self._libs_only_L = self._call("--libs-only-L") self._libs_only_other = self._call("--libs-only-other") def _call(self, *pkg_config_args): try: cmd = [Configuration.current.pkg_config] + list(pkg_config_args) + [self.package_name] print("Executing command '{}'".format(cmd), file=sys.stderr) return shlex.split(subprocess.check_output(cmd).decode('utf-8')) except subprocess.CalledProcessError as e: raise self.Error("pkg-config exited with error code {}".format(e.returncode)) @property def swiftc_flags(self): """Flags for this package in a format suitable for passing to `swiftc`. :rtype: list[str] """ return ( ["-Xcc {}".format(s) for s in self._cflags_only_other] + ["-Xlinker {}".format(s) for s in self._libs_only_other] + self._cflags_only_I + self._libs_only_L + self._libs_only_l) @property def cflags(self): """CFLAGS for this package. :rtype: list[str] """ return self._cflags @property def ldflags(self): <|fim_middle|> <|fim▁end|>
"""LDFLAGS for this package. :rtype: list[str] """ return self._libs
<|file_name|>pkg_config.py<|end_file_name|><|fim▁begin|>from __future__ import print_function import shlex import subprocess import sys from .config import Configuration class PkgConfig(object): class Error(Exception): """Raised when information could not be obtained from pkg-config.""" def <|fim_middle|>(self, package_name): """Query pkg-config for information about a package. :type package_name: str :param package_name: The name of the package to query. :raises PkgConfig.Error: When a call to pkg-config fails. """ self.package_name = package_name self._cflags = self._call("--cflags") self._cflags_only_I = self._call("--cflags-only-I") self._cflags_only_other = self._call("--cflags-only-other") self._libs = self._call("--libs") self._libs_only_l = self._call("--libs-only-l") self._libs_only_L = self._call("--libs-only-L") self._libs_only_other = self._call("--libs-only-other") def _call(self, *pkg_config_args): try: cmd = [Configuration.current.pkg_config] + list(pkg_config_args) + [self.package_name] print("Executing command '{}'".format(cmd), file=sys.stderr) return shlex.split(subprocess.check_output(cmd).decode('utf-8')) except subprocess.CalledProcessError as e: raise self.Error("pkg-config exited with error code {}".format(e.returncode)) @property def swiftc_flags(self): """Flags for this package in a format suitable for passing to `swiftc`. :rtype: list[str] """ return ( ["-Xcc {}".format(s) for s in self._cflags_only_other] + ["-Xlinker {}".format(s) for s in self._libs_only_other] + self._cflags_only_I + self._libs_only_L + self._libs_only_l) @property def cflags(self): """CFLAGS for this package. :rtype: list[str] """ return self._cflags @property def ldflags(self): """LDFLAGS for this package. :rtype: list[str] """ return self._libs <|fim▁end|>
__init__
<|file_name|>pkg_config.py<|end_file_name|><|fim▁begin|>from __future__ import print_function import shlex import subprocess import sys from .config import Configuration class PkgConfig(object): class Error(Exception): """Raised when information could not be obtained from pkg-config.""" def __init__(self, package_name): """Query pkg-config for information about a package. :type package_name: str :param package_name: The name of the package to query. :raises PkgConfig.Error: When a call to pkg-config fails. """ self.package_name = package_name self._cflags = self._call("--cflags") self._cflags_only_I = self._call("--cflags-only-I") self._cflags_only_other = self._call("--cflags-only-other") self._libs = self._call("--libs") self._libs_only_l = self._call("--libs-only-l") self._libs_only_L = self._call("--libs-only-L") self._libs_only_other = self._call("--libs-only-other") def <|fim_middle|>(self, *pkg_config_args): try: cmd = [Configuration.current.pkg_config] + list(pkg_config_args) + [self.package_name] print("Executing command '{}'".format(cmd), file=sys.stderr) return shlex.split(subprocess.check_output(cmd).decode('utf-8')) except subprocess.CalledProcessError as e: raise self.Error("pkg-config exited with error code {}".format(e.returncode)) @property def swiftc_flags(self): """Flags for this package in a format suitable for passing to `swiftc`. :rtype: list[str] """ return ( ["-Xcc {}".format(s) for s in self._cflags_only_other] + ["-Xlinker {}".format(s) for s in self._libs_only_other] + self._cflags_only_I + self._libs_only_L + self._libs_only_l) @property def cflags(self): """CFLAGS for this package. :rtype: list[str] """ return self._cflags @property def ldflags(self): """LDFLAGS for this package. :rtype: list[str] """ return self._libs <|fim▁end|>
_call
<|file_name|>pkg_config.py<|end_file_name|><|fim▁begin|>from __future__ import print_function import shlex import subprocess import sys from .config import Configuration class PkgConfig(object): class Error(Exception): """Raised when information could not be obtained from pkg-config.""" def __init__(self, package_name): """Query pkg-config for information about a package. :type package_name: str :param package_name: The name of the package to query. :raises PkgConfig.Error: When a call to pkg-config fails. """ self.package_name = package_name self._cflags = self._call("--cflags") self._cflags_only_I = self._call("--cflags-only-I") self._cflags_only_other = self._call("--cflags-only-other") self._libs = self._call("--libs") self._libs_only_l = self._call("--libs-only-l") self._libs_only_L = self._call("--libs-only-L") self._libs_only_other = self._call("--libs-only-other") def _call(self, *pkg_config_args): try: cmd = [Configuration.current.pkg_config] + list(pkg_config_args) + [self.package_name] print("Executing command '{}'".format(cmd), file=sys.stderr) return shlex.split(subprocess.check_output(cmd).decode('utf-8')) except subprocess.CalledProcessError as e: raise self.Error("pkg-config exited with error code {}".format(e.returncode)) @property def <|fim_middle|>(self): """Flags for this package in a format suitable for passing to `swiftc`. :rtype: list[str] """ return ( ["-Xcc {}".format(s) for s in self._cflags_only_other] + ["-Xlinker {}".format(s) for s in self._libs_only_other] + self._cflags_only_I + self._libs_only_L + self._libs_only_l) @property def cflags(self): """CFLAGS for this package. :rtype: list[str] """ return self._cflags @property def ldflags(self): """LDFLAGS for this package. :rtype: list[str] """ return self._libs <|fim▁end|>
swiftc_flags
<|file_name|>pkg_config.py<|end_file_name|><|fim▁begin|>from __future__ import print_function import shlex import subprocess import sys from .config import Configuration class PkgConfig(object): class Error(Exception): """Raised when information could not be obtained from pkg-config.""" def __init__(self, package_name): """Query pkg-config for information about a package. :type package_name: str :param package_name: The name of the package to query. :raises PkgConfig.Error: When a call to pkg-config fails. """ self.package_name = package_name self._cflags = self._call("--cflags") self._cflags_only_I = self._call("--cflags-only-I") self._cflags_only_other = self._call("--cflags-only-other") self._libs = self._call("--libs") self._libs_only_l = self._call("--libs-only-l") self._libs_only_L = self._call("--libs-only-L") self._libs_only_other = self._call("--libs-only-other") def _call(self, *pkg_config_args): try: cmd = [Configuration.current.pkg_config] + list(pkg_config_args) + [self.package_name] print("Executing command '{}'".format(cmd), file=sys.stderr) return shlex.split(subprocess.check_output(cmd).decode('utf-8')) except subprocess.CalledProcessError as e: raise self.Error("pkg-config exited with error code {}".format(e.returncode)) @property def swiftc_flags(self): """Flags for this package in a format suitable for passing to `swiftc`. :rtype: list[str] """ return ( ["-Xcc {}".format(s) for s in self._cflags_only_other] + ["-Xlinker {}".format(s) for s in self._libs_only_other] + self._cflags_only_I + self._libs_only_L + self._libs_only_l) @property def <|fim_middle|>(self): """CFLAGS for this package. :rtype: list[str] """ return self._cflags @property def ldflags(self): """LDFLAGS for this package. :rtype: list[str] """ return self._libs <|fim▁end|>
cflags
<|file_name|>pkg_config.py<|end_file_name|><|fim▁begin|>from __future__ import print_function import shlex import subprocess import sys from .config import Configuration class PkgConfig(object): class Error(Exception): """Raised when information could not be obtained from pkg-config.""" def __init__(self, package_name): """Query pkg-config for information about a package. :type package_name: str :param package_name: The name of the package to query. :raises PkgConfig.Error: When a call to pkg-config fails. """ self.package_name = package_name self._cflags = self._call("--cflags") self._cflags_only_I = self._call("--cflags-only-I") self._cflags_only_other = self._call("--cflags-only-other") self._libs = self._call("--libs") self._libs_only_l = self._call("--libs-only-l") self._libs_only_L = self._call("--libs-only-L") self._libs_only_other = self._call("--libs-only-other") def _call(self, *pkg_config_args): try: cmd = [Configuration.current.pkg_config] + list(pkg_config_args) + [self.package_name] print("Executing command '{}'".format(cmd), file=sys.stderr) return shlex.split(subprocess.check_output(cmd).decode('utf-8')) except subprocess.CalledProcessError as e: raise self.Error("pkg-config exited with error code {}".format(e.returncode)) @property def swiftc_flags(self): """Flags for this package in a format suitable for passing to `swiftc`. :rtype: list[str] """ return ( ["-Xcc {}".format(s) for s in self._cflags_only_other] + ["-Xlinker {}".format(s) for s in self._libs_only_other] + self._cflags_only_I + self._libs_only_L + self._libs_only_l) @property def cflags(self): """CFLAGS for this package. :rtype: list[str] """ return self._cflags @property def <|fim_middle|>(self): """LDFLAGS for this package. :rtype: list[str] """ return self._libs <|fim▁end|>
ldflags