rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
return False
def delete_event(self, widget, event, data=None): cancel = self.autosave_image() if cancel == True: return self.stop_now = True self.closing_app = True self.save_settings() sys.exit(0) return False
return
return True
def destroy(self, event, data=None): cancel = self.autosave_image() if cancel == True: return self.stop_now = True self.closing_app = True self.save_settings() return False
return False
def destroy(self, event, data=None): cancel = self.autosave_image() if cancel == True: return self.stop_now = True self.closing_app = True self.save_settings() return False
return
return True
def exit_app(self, action): cancel = self.autosave_image() if cancel == True: return self.stop_now = True self.closing_app = True self.save_settings() sys.exit(0)
self.first_image_load = False
def put_zoom_image_to_window(self, currimg_preloaded): self.window.window.freeze_updates() if currimg_preloaded == False: # Always start with the original image to preserve quality! # Calculate image size: finalimg_width = int(self.currimg_pixbuf_original.get_width() * self.currimg_zoomratio) finalimg_height = int(self...
self.zoom_to_fit_window(None, False, False)
if self.last_image_action_was_smart_fit == True: self.zoom_to_fit_or_1_to_1(None, False, False) else: self.zoom_to_fit_window(None, False, False)
def toggle_status_bar(self, action): if self.statusbar.get_property('visible') == True: self.statusbar.hide() self.statusbar2.hide() self.statusbar_show = False else: self.statusbar.show() self.statusbar2.show() self.statusbar_show = True if self.image_loaded == True and self.last_image_action_was_fit == True: self.zoo...
self.zoom_to_fit_window(None, False, False)
if self.last_image_action_was_smart_fit == True: self.zoom_to_fit_or_1_to_1(None, False, False) else: self.zoom_to_fit_window(None, False, False)
def toggle_toolbar(self, action): if self.toolbar.get_property('visible') == True: self.toolbar.hide() self.toolbar_show = False else: self.toolbar.show() self.toolbar_show = True if self.image_loaded == True and self.last_image_action_was_fit == True: self.zoom_to_fit_window(None, False, False)
self.last_image_action_was_fit = True
def zoom_to_fit_or_1_to_1(self, action, is_preloadimg_next, is_preloadimg_prev): if is_preloadimg_next == True: if self.preloading_images == True and self.preloadimg_next_pixbuf_original != None: win_width = self.available_image_width() win_height = self.available_image_height() preimg_width = self.preloadimg_next_pixb...
if self.first_image_load == True and self.currimg_zoomratio > 1:
if self.currimg_zoomratio > 1:
def zoom_to_fit_or_1_to_1(self, action, is_preloadimg_next, is_preloadimg_prev): if is_preloadimg_next == True: if self.preloading_images == True and self.preloadimg_next_pixbuf_original != None: win_width = self.available_image_width() win_height = self.available_image_height() preimg_width = self.preloadimg_next_pixb...
self.zoom_to_fit_or_1_to_1(None, False, False)
if self.last_image_action_was_smart_fit == True: self.zoom_to_fit_or_1_to_1(None, False, False) else: self.zoom_to_fit_window(None, False, False)
def rotate_left(self, action): if self.currimg_name != "" and self.UIManager.get_widget('/MainMenu/EditMenu/Rotate Left').get_property('sensitive') == True: self.currimg_pixbuf_original = self.image_rotate(self.currimg_pixbuf_original, 90) if self.last_image_action_was_fit == True: self.zoom_to_fit_or_1_to_1(None, Fals...
self.zoom_to_fit_or_1_to_1(None, False, False)
if self.last_image_action_was_smart_fit == True: self.zoom_to_fit_or_1_to_1(None, False, False) else: self.zoom_to_fit_window(None, False, False)
def rotate_right(self, action): if self.currimg_name != "" and self.UIManager.get_widget('/MainMenu/EditMenu/Rotate Right').get_property('sensitive') == True: self.currimg_pixbuf_original = self.image_rotate(self.currimg_pixbuf_original, 270) if self.last_image_action_was_fit == True: self.zoom_to_fit_or_1_to_1(None, F...
self.first_image_load = True
def load_new_image(self, use_preloadimg_next, use_preloadimg_prev, use_current_pixbuf_original, reset_cursor, perform_onload_action): # If use_current_pixbuf_original == True, do not reload the # self.currimg_pixbuf_original from the file; instead, use the existing # one. This is only currently useful for resizing imag...
if coords[0] < 0: coords[0] = 0 if coords[1] < 0: coords[1] = 0
def crop_image(self, action): dialog = gtk.Dialog(_("Crop Image"), self.window, gtk.DIALOG_MODAL, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)) dialog.add_button(_("Crop"), gtk.RESPONSE_ACCEPT) image = gtk.DrawingArea() # Create a pixbuf that fits in a window of 400x400 image_width = self.currimg_pixbuf_original.get_width()...
('Fit', gtk.STOCK_ZOOM_FIT, _('Zoom To _Fit'), '<Ctrl>0', _('Fit'), self.zoom_to_fit_window(None, False)), ('1:1', gtk.STOCK_ZOOM_100, _('_1:1'), '<Ctrl>1', _('1:1'), self.zoom_1_to_1(None, False)),
('Fit', gtk.STOCK_ZOOM_FIT, _('Zoom To _Fit'), '<Ctrl>0', _('Fit'), self.zoom_to_fit_window_action), ('1:1', gtk.STOCK_ZOOM_100, _('_1:1'), '<Ctrl>1', _('1:1'), self.zoom_1_to_1_action),
def __init__(self):
self.editor = "gimp-remote"
def __init__(self):
opts, args = getopt.getopt(sys.argv[1:], "hRvVsf", ["help", "version", "recursive", "verbose", "slideshow", "fullscreen"])
opts, args = getopt.getopt(sys.argv[1:], "hRvVsfo:", ["help", "version", "recursive", "verbose", "slideshow", "fullscreen", "onload="])
def __init__(self):
self.editor = conf.get('prefs', 'editor')
def __init__(self):
('Open Image', gtk.STOCK_OPEN, _('_Open Image...'), '<control>O', _('Open Image'), self.open_file), ('Open Folder', gtk.STOCK_OPEN, _('Open _Folder...'), '<control>F', _('Open Folder'), self.open_folder), ('Quit', gtk.STOCK_QUIT, _('_Quit'), '<control>Q', _('Quit'), self.exit_app),
('Open Image', gtk.STOCK_OPEN, _('_Open Image...'), '<Ctrl>O', _('Open Image'), self.open_file), ('Open Folder', gtk.STOCK_OPEN, _('Open _Folder...'), '<Ctrl>F', _('Open Folder'), self.open_folder), ('Quit', gtk.STOCK_QUIT, _('_Quit'), '<Ctrl>Q', _('Quit'), self.exit_app),
def __init__(self):
('Preferences', gtk.STOCK_PREFERENCES, _('_Preferences'), None, _('Preferences'), self.prefs_show),
('Preferences', gtk.STOCK_PREFERENCES, _('_Preferences...'), None, _('Preferences'), self.prefs_show),
def __init__(self):
('Open in Editor', gtk.STOCK_EXECUTE, _('Open in _Editor'), '<Ctrl>E', _('Open in Editor'), self.load_editor), ('Delete Image', gtk.STOCK_DELETE, _('Delete Image'), 'Delete', _('Delete Image'), self.delete_image)
('Delete Image', gtk.STOCK_DELETE, _('_Delete Image'), 'Delete', _('Delete Image'), self.delete_image), ('Custom Actions', None, _('Custom _Actions...'), None, _('Custom Actions'), self.custom_actions_show), ('MiscKeysMenuHidden', None, 'Keys'), ('Escape', None, '', 'Escape', _('Exit Full Screen'), self.leave_fullscree...
def __init__(self):
<menuitem action="Open in Editor"/> <separator name="FM2"/>
<menuitem action="Custom Actions"/>
def __init__(self):
if event.keyval == 65361:
if event.keyval == gtk.gdk.keyval_from_name('Left'):
def topwindow_keypress(self, widget, event): if event.state != gtk.gdk.SHIFT_MASK and event.state != gtk.gdk.CONTROL_MASK and event.state != gtk.gdk.MOD1_MASK and event.state != gtk.gdk.CONTROL_MASK | gtk.gdk.MOD2_MASK and event.state != gtk.gdk.LOCK_MASK | gtk.gdk.CONTROL_MASK: if event.keyval == 65361: # Left arro...
elif event.keyval == 65363 or event.keyval == 32:
return elif event.keyval == gtk.gdk.keyval_from_name('Right'):
def topwindow_keypress(self, widget, event): if event.state != gtk.gdk.SHIFT_MASK and event.state != gtk.gdk.CONTROL_MASK and event.state != gtk.gdk.MOD1_MASK and event.state != gtk.gdk.CONTROL_MASK | gtk.gdk.MOD2_MASK and event.state != gtk.gdk.LOCK_MASK | gtk.gdk.CONTROL_MASK: if event.keyval == 65361: # Left arro...
elif event.keyval == 65360: self.first_img_in_list(None) elif event.keyval == 65367: self.last_img_in_list(None) elif event.keyval == 65307: self.leave_fullscreen(None) elif event.keyval == 45: self.zoom_out(None) elif event.keyval == 61 or event.keyval == 43: self.zoom_in(None) elif event.state == gtk.gdk.CONTROL_MA...
return shortcut = gtk.accelerator_name(event.keyval, event.state) if "<Mod2>" in shortcut: shortcut = shortcut.replace("<Mod2>", "") for i in range(len(self.action_shortcuts)): try: if shortcut == self.action_shortcuts[i]: self.parse_action_command(self.action_commands[i], self.action_batch[i]) except: pass def parse...
def topwindow_keypress(self, widget, event): if event.state != gtk.gdk.SHIFT_MASK and event.state != gtk.gdk.CONTROL_MASK and event.state != gtk.gdk.MOD1_MASK and event.state != gtk.gdk.CONTROL_MASK | gtk.gdk.MOD2_MASK and event.state != gtk.gdk.LOCK_MASK | gtk.gdk.CONTROL_MASK: if event.keyval == 65361: # Left arro...
self.UIManager.get_widget('/MainMenu/EditMenu/Open in Editor').set_sensitive(enable)
def set_image_sensitivities(self, enable): self.set_zoom_in_sensitivities(enable) self.set_zoom_out_sensitivities(enable) self.UIManager.get_widget('/MainMenu/ViewMenu/1:1').set_sensitive(enable) self.UIManager.get_widget('/MainMenu/ViewMenu/Fit').set_sensitive(enable) self.UIManager.get_widget('/MainMenu/EditMenu/Rota...
print _(" -h, --help Show this help and exit") print _(" -v, --version Show version information and exit") print _(" -V, --verbose Show more detailed information") print _(" -R, --recursive Recursively include all images found in") print _(" subdirectories of FOLDERS") print _(" -s, --slidesho...
print _(" -h, --help Show this help and exit") print _(" -v, --version Show version information and exit") print _(" -V, --verbose Show more detailed information") print _(" -R, --recursive Recursively include all images found in") print _(" subdirectories of FOLDE...
def print_usage(self): self.print_version() print "" print _("Usage: mirage [OPTION]... FILES|FOLDERS...") print "" print _("Options:") print _(" -h, --help Show this help and exit") print _(" -v, --version Show version information and exit") print _(" -V, --verbose Show more detailed information") print _(" ...
conf.set('prefs', 'editor', self.editor)
def save_settings(self): conf = ConfigParser.ConfigParser() conf.add_section('window') conf.set('window', 'w', self.window.get_allocation().width) conf.set('window', 'h', self.window.get_allocation().height) conf.set('window', 'toolbar', self.toolbar_show) conf.set('window', 'statusbar', self.statusbar_show) conf.add_s...
gtk.Tooltips().set_tip(disable_screensaver, _("If enabled, Mirage will attempt to temporarily disable xscreensaver during slideshow mode."))
gtk.Tooltips().set_tip(disable_screensaver, _("If enabled, xscreensaver will be temporarily disabled during slideshow mode."))
def prefs_show(self, action): self.prefs_dialog = gtk.Dialog(title=_("Mirage Preferences"), parent=self.window) self.prefs_dialog.set_has_separator(False) self.prefs_dialog.set_resizable(False) # Add "Interface" prefs: table_settings = gtk.Table(13, 3, False) table_settings.attach(gtk.Label(), 1, 3, 1, 2, gtk.FILL|gtk....
gtk.Tooltips().set_tip(ss_in_fs, _("If enabled, Mirage will switch to fullscreen when a slideshow is started."))
gtk.Tooltips().set_tip(ss_in_fs, _("If enabled, starting a slideshow will put the application in fullscreen mode."))
def prefs_show(self, action): self.prefs_dialog = gtk.Dialog(title=_("Mirage Preferences"), parent=self.window) self.prefs_dialog.set_has_separator(False) self.prefs_dialog.set_resizable(False) # Add "Interface" prefs: table_settings = gtk.Table(13, 3, False) table_settings.attach(gtk.Label(), 1, 3, 1, 2, gtk.FILL|gtk....
table_editor = gtk.Table(13, 2, False) table_editor.attach(gtk.Label(), 1, 2, 1, 2, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 0, 0) editorlabel = gtk.Label() editorlabel.set_markup('<b>' + _('External Image Editor') + '</b>') editorlabel.set_alignment(0, 1) table_editor.attach(editorlabel, 1, 2, 2, 3, gtk.FILL|gtk.EXPA...
def prefs_show(self, action): self.prefs_dialog = gtk.Dialog(title=_("Mirage Preferences"), parent=self.window) self.prefs_dialog.set_has_separator(False) self.prefs_dialog.set_resizable(False) # Add "Interface" prefs: table_settings = gtk.Table(13, 3, False) table_settings.attach(gtk.Label(), 1, 3, 1, 2, gtk.FILL|gtk....
notebook.append_page(table_editor, gtk.Label(str=_("Editor")))
def prefs_show(self, action): self.prefs_dialog = gtk.Dialog(title=_("Mirage Preferences"), parent=self.window) self.prefs_dialog.set_has_separator(False) self.prefs_dialog.set_resizable(False) # Add "Interface" prefs: table_settings = gtk.Table(13, 3, False) table_settings.attach(gtk.Label(), 1, 3, 1, 2, gtk.FILL|gtk....
self.prefs_dialog.realize() editorlabel.set_size_request(self.prefs_dialog.get_allocation().width-85, -1)
def prefs_show(self, action): self.prefs_dialog = gtk.Dialog(title=_("Mirage Preferences"), parent=self.window) self.prefs_dialog.set_has_separator(False) self.prefs_dialog.set_resizable(False) # Add "Interface" prefs: table_settings = gtk.Table(13, 3, False) table_settings.attach(gtk.Label(), 1, 3, 1, 2, gtk.FILL|gtk....
self.editor = editortext.get_text()
def prefs_show(self, action): self.prefs_dialog = gtk.Dialog(title=_("Mirage Preferences"), parent=self.window) self.prefs_dialog.set_has_separator(False) self.prefs_dialog.set_resizable(False) # Add "Interface" prefs: table_settings = gtk.Table(13, 3, False) table_settings.attach(gtk.Label(), 1, 3, 1, 2, gtk.FILL|gtk....
self.zoom_to_fit_window(action, False)
self.zoom_to_fit_window(action, False, False)
def zoom_to_fit_window_action(self, action): self.zoom_to_fit_window(action, False)
self.zoom_1_to_1(action, False)
self.zoom_1_to_1(action, False, False)
def zoom_1_to_1_action(self, action): self.zoom_1_to_1(action, False)
if self.preloading_images == True and len(self.image_list) > 1: if use_existing_image == False: if self.curr_img_in_list + 1 <= len(self.image_list)-1: temp_name = str(self.image_list[self.curr_img_in_list+1]) elif self.listwrap_mode > 0: temp_name = str(self.image_list[0]) else:
try: if self.preloading_images == True and len(self.image_list) > 1: if use_existing_image == False: if self.curr_img_in_list + 1 <= len(self.image_list)-1: temp_name = str(self.image_list[self.curr_img_in_list+1]) elif self.listwrap_mode > 0: temp_name = str(self.image_list[0]) else: return if temp_name == self.preloa...
def preload_next_image(self, use_existing_image): if self.preloading_images == True and len(self.image_list) > 1: if use_existing_image == False: if self.curr_img_in_list + 1 <= len(self.image_list)-1: temp_name = str(self.image_list[self.curr_img_in_list+1]) elif self.listwrap_mode > 0: temp_name = str(self.image_list...
if temp_name == self.preloadimg_next_name:
if self.open_mode == self.open_mode_smart: self.zoom_to_fit_or_1_to_1(None, True, False) elif self.open_mode == self.open_mode_fit: self.zoom_to_fit_window(None, True, False) elif self.open_mode == self.open_mode_1to1: self.zoom_1_to_1(None, True, False) elif self.open_mode == self.open_mode_last: if self.last_mode == ...
def preload_next_image(self, use_existing_image): if self.preloading_images == True and len(self.image_list) > 1: if use_existing_image == False: if self.curr_img_in_list + 1 <= len(self.image_list)-1: temp_name = str(self.image_list[self.curr_img_in_list+1]) elif self.listwrap_mode > 0: temp_name = str(self.image_list...
self.preloadimg_next_name = temp_name pre_animtest = gtk.gdk.PixbufAnimation(self.preloadimg_next_name) if pre_animtest.is_static_image() == True: self.preloadimg_next_is_animation = False self.preloadimg_next_pixbuf_original = pre_animtest.get_static_image() else: self.preloadimg_next_is_animation = True self.preloadi...
self.preloadimg_prev_pixbuf = self.preloadimg_prev_pixbuf_original gc.collect() if self.verbose == True: print _("Preloading:"), self.preloadimg_prev_name except: self.preloadimg_prev_pixbuf_original = None
def preload_next_image(self, use_existing_image): if self.preloading_images == True and len(self.image_list) > 1: if use_existing_image == False: if self.curr_img_in_list + 1 <= len(self.image_list)-1: temp_name = str(self.image_list[self.curr_img_in_list+1]) elif self.listwrap_mode > 0: temp_name = str(self.image_list...
self.image_list.append(item2) if go_buttons_enabled == False: if len(self.image_list) > 1: self.set_go_navigation_sensitivities(True) go_buttons_enabled = True
if not item2 in self.image_list: self.image_list.append(item2) if go_buttons_enabled == False: if len(self.image_list) > 1: self.set_go_navigation_sensitivities(True) go_buttons_enabled = True
def expand_directory(self, item, stop_when_image_found, go_buttons_enabled, update_title, print_found_msg): if self.stop_now == False and self.closing_app == False: folderlist = [] filelist = [] if os.access(item, os.R_OK) == False: return False for item2 in os.listdir(item): if item2[0] != '.' and self.closing_app == ...
_VERSION = "0.6-0"
_VERSION = "0.6-1"
def txtToCDF(txtFile, ncFile, varName, attr): # Transfer contents of 'txtFile' to NC.FLOAT variable 'varName' inside # netCDF file 'ncFile'. `attr' is a dictionnary holding attributes # to assign to the variable.
unlim = self._ncid.inq_unlimdim()
if self.isrecord(): unlim = 0 else: unnlim = -1
def __buildStartCountStride(self, elem):
_VERSION = "0.6-1"
_VERSION = "0.6-2"
def txtToCDF(txtFile, ncFile, varName, attr): # Transfer contents of 'txtFile' to NC.FLOAT variable 'varName' inside # netCDF file 'ncFile'. `attr' is a dictionnary holding attributes # to assign to the variable.
__all__ = ['CDF', 'CDFAttr', 'CDFDim', 'CDFVar',
__all__ = ['CDF', 'CDFAttr', 'CDFDim', 'CDFVar', 'CDFMF',
def txtToCDF(txtFile, ncFile, varName, attr): # Transfer contents of 'txtFile' to NC.FLOAT variable 'varName' inside # netCDF file 'ncFile'. `attr' is a dictionnary holding attributes # to assign to the variable.
associated with the variable
associated with the variable; an empty sequence is returned in the case of a scalar variable
def inq(self): """Return information about the variable. Dataset mode: does not matter.
number of dimensions
number of dimensions; 0 indicates a scalar variable
def inq_ndims(self): """Get the number of dimensions associated with the variable. Dataset mode: does not matter.
sequence of dimension index numbers
sequence of dimension index numbers; an empty sequence is returned in the case of a scalar variable
def inq_dimid(self): """Get the index numbers of the dimensions associated with the variable. Dataset mode: does not matter.
return self.inq_dimid()[0] == self._ncid.inq_unlimdim()
return (self.inq_ndims() > 0 and self.inq_dimid()[0] == self._ncid.inq_unlimdim())
def isrecord(self): """Determines whether the variable is a record variable, eg its first dimension refers to the unlimited dimension.
tuple storing the names of the variable dimensions
tuple storing the names of the variable dimensions; an empty tuple is returned in the case of a scalar variable
def dimensions(self): """Return the names of the variable dimensions. Dataset mode: does not matter.
variable dimensions
variable dimensions; an empty tup;e is returned in the case of a scalar variable
def shape(self): """Return the variable shape, that is, the length of its dimensions. Dataset mode: does not matter.
o = SpatialReference(obj=_gdal.OSRClone( self._o ))
o = _gdal.OSRClone( self._o )
def Clone(self): o = SpatialReference(obj=_gdal.OSRClone( self._o )) if o is None or o == 'NULL': return None else: return SpatialReference(obj=o)
shp_layer = shp_ds.CreateLayer( 'out', geom_type = ogr.wkbPolygon )
shp_layer = shp_ds.CreateLayer( 'out', geom_type = ogr.wkbPolygon, srs = nad83 )
def Usage(): print 'Usage: tigerpoly.py infile [outfile].shp' print sys.exit(1)
driver_count = _gdal.GDALGetDriverCount() for iDriver in range(driver_count): driver_o = _gdal.GDALGetDriver( iDriver ) if _gdal.GDALGetDriverShortName(driver_o) == name: return Driver(driver_o) return None
driver_o = _gdal.GDALGetDriverByName( name ) if driver_o is None or driver_o == "NULL": return None else: return Driver( driver_o )
def GetDriverByName(name): _gdal.GDALAllRegister() driver_count = _gdal.GDALGetDriverCount() for iDriver in range(driver_count): driver_o = _gdal.GDALGetDriver( iDriver ) if _gdal.GDALGetDriverShortName(driver_o) == name: return Driver(driver_o) return None
if i > 0 & i <= self.RasterCount:
if i > 0 and i <= self.RasterCount:
def GetRasterBand(self, i): if i > 0 & i <= self.RasterCount: return self._band[i-1] else: return None
_obj = _gdal.OGR_G_CreateFromWkb( bin_string, srs )
if srs is not None: srs_o = srs._o else: srs_o = '' _obj = _gdal.OGR_G_CreateFromWkb( bin_string, srs_o )
def CreateGeometryFromWkb( bin_string, srs = None ): _obj = _gdal.OGR_G_CreateFromWkb( bin_string, srs ) return Geometry( obj = _obj )
_obj = _Gdal.OGR_G_CreateFromWkt( string, srs )
if srs is not None: srs_o = srs._o else: srs_o = '' _obj = _gdal.OGR_G_CreateFromWkt( string, srs_o )
def CreateGeometryFromWkt( string, srs = None ): _obj = _Gdal.OGR_G_CreateFromWkt( string, srs ) return Geometry( obj = _obj )
return SpatialReference(obj=_gdal.OSRCloneGeogCS( self._o ))
o = _gdal.OSRCloneGeogCS( self._o ) if o is None: return None else: return SpatialReference(obj=o)
def CloneGeogCS(self): return SpatialReference(obj=_gdal.OSRCloneGeogCS( self._o ))
return SpatialReference(obj=_gdal.OSRClone( self._o ))
o = SpatialReference(obj=_gdal.OSRClone( self._o )) if o is None: return None else: return SpatialReference(obj=o)
def Clone(self): return SpatialReference(obj=_gdal.OSRClone( self._o ))
ds_o = _gdal.OGROpen( filename, update, None ) if ds_o is None:
ds_o = _gdal.OGROpen( filename, update, 'NULL' ) if ds_o is None or ds_o == 'NULL':
def Open( filename, update = 0 ): ds_o = _gdal.OGROpen( filename, update, None ) if ds_o is None: raise ValueError, 'Unable to open: ' + filename else: return DataSource( ds_o )
if dr_o is None:
if dr_o is None or dr_o == 'NULL':
def GetDriver( driver_index ): dr_o = _gdal.OGRGetDriver( driver_index ) if dr_o is None: raise IndexError else: return Driver( dr_o )
if ds_o is None:
if ds_o is None or ds_o == 'NULL':
def Open( self, filename, update = 0 ): ds_o = _gdal.OGR_Dr_Open( self._o, filename, update ) if ds_o is None: return None else: return DataSource( ds_o )
if ds_o is None: return None
if ds_o is None or ds_o == 'NULL': raise ValueError, CPLGetLastErrorMsg()
def CreateDataSource( self, filename, options = None ): ds_o = _gdal.OGR_Dr_CreateDataSource( self._o, filename, "NULL" ) if ds_o is None: return None else: return DataSource( ds_o )
layer_count = self.GetLayerCount() for i in range(layer_count): if self.GetLayer(i).GetName() == iLayer: return self.GetLayer(i) return None
return self.GetLayerByName( iLayer )
def GetLayer(self,iLayer=0): # If given a layer name, scan for it. if type(iLayer).__name__ == 'str': layer_count = self.GetLayerCount() for i in range(layer_count): if self.GetLayer(i).GetName() == iLayer: return self.GetLayer(i) return None l_obj = _gdal.OGR_DS_GetLayer( self._o, iLayer) if l_obj is not None: return...
if l_obj is not None:
if l_obj is not None and l_obj != 'NULL':
def GetLayer(self,iLayer=0): # If given a layer name, scan for it. if type(iLayer).__name__ == 'str': layer_count = self.GetLayerCount() for i in range(layer_count): if self.GetLayer(i).GetName() == iLayer: return self.GetLayer(i) return None l_obj = _gdal.OGR_DS_GetLayer( self._o, iLayer) if l_obj is not None: return...
return None
raise IndexError, 'No layer %d on datasource' % iLayer def GetLayerByName(self,name): l_obj = _gdal.OGR_DS_GetLayerByName( self._o, name) if l_obj is not None and l_obj != 'NULL': return Layer( l_obj ) else: raise IndexError, 'No layer %s on datasource' % name
def GetLayer(self,iLayer=0): # If given a layer name, scan for it. if type(iLayer).__name__ == 'str': layer_count = self.GetLayerCount() for i in range(layer_count): if self.GetLayer(i).GetName() == iLayer: return self.GetLayer(i) return None l_obj = _gdal.OGR_DS_GetLayer( self._o, iLayer) if l_obj is not None: return...
def GetLayerByName(self,name): layer_count = self.GetLayerCount() for i in range(layer_count): if self.GetLayer(i).GetName() == name: return self.GetLayer(i) return None
def DeleteLayer( self, iLayer ): return _gdal.OGR_DS_DeleteLayer( self._o, iLayer )
if obj is None: return None
if obj is None and obj != 'NULL': raise ValueError, gdal.GetLastErrorMsg()
def CreateLayer(self, name, srs = None, geom_type = wkbUnknown, options = [] ): obj = _gdal.OGR_DS_CreateLayer( self._o, name, srs, geom_type, options) if obj is None: return None else: return Layer( obj = obj )
def ExecuteSQL( self, statement, region = None, dialect = "" ):
def ExecuteSQL( self, statement, region = 'NULL', dialect = "" ):
def ExecuteSQL( self, statement, region = None, dialect = "" ): l_obj = _gdal.OGR_DS_ExecuteSQL( self._o, statement, region, dialect ) if l_obj is not None: return Layer( l_obj ) else: return None
if l_obj is not None:
if l_obj is not None and l_obj != 'NULL':
def ExecuteSQL( self, statement, region = None, dialect = "" ): l_obj = _gdal.OGR_DS_ExecuteSQL( self._o, statement, region, dialect ) if l_obj is not None: return Layer( l_obj ) else: return None
def ReleaseResultsSet( self, layer ): _gdal.OGR_DS_ReleaseResultsSet( self._o, layer._o )
def ReleaseResultSet( self, layer ): _gdal.OGR_DS_ReleaseResultSet( self._o, layer._o )
def ReleaseResultsSet( self, layer ): _gdal.OGR_DS_ReleaseResultsSet( self._o, layer._o )
geom_o = None
geom_o = 'NULL'
def SetSpatialFilter( self, geom ): if geom is None: geom_o = None else: geom_o = geom._o _gdal.OGR_L_SetSpatialFilter( self._o, geom_o )
if geom_o is None:
if geom_o is None or geom_o == 'NULL':
def GetSpatialFilter( self ): geom_o = _gdal.OGR_L_GetSpatialGeometry( self._o ) if geom_o is None: return None else: return Geometry( _obj = geom_o )
if f_o is None:
if f_o is None or f_o == 'NULL':
def GetFeature( self, fid ): f_o = _gdal.OGR_L_GetFeature( self._o, fid ) if f_o is None: return None else: return Feature( obj = f_o )
if f_o is None:
if f_o is None or f_o == 'NULL':
def GetNextFeature( self ): f_o = _gdal.OGR_L_GetNextFeature( self._o ) if f_o is None: return None else: return Feature( obj = f_o )
raise ValueError, 'No implemented yet'
raise ValueError, 'Not implemented yet'
def GetExtent( self, force = 1 ): raise ValueError, 'No implemented yet'
def SetPoint( self, i, x, y, z ):
def SetPoint( self, i, x, y, z = 0):
def SetPoint( self, i, x, y, z ): return _gdal.OGR_G_SetPoint( self._o, i, x, y, z )
def AddPoint( self, x, y, z ):
def AddPoint( self, x, y, z = 0 ):
def AddPoint( self, x, y, z ): return _gdal.OGR_G_AddPoint( self._o, x, y, z )
if src_ds is None:
if src_ds is None or src_ds == 'NULL':
def RGBFile2PCTFile( src_filename, dst_filename ): src_ds = Open(src_filename) if src_ds is None: return 1 ct = ColorTable() err = ComputeMedianCutPCT( src_ds.GetRasterBand(1), src_ds.GetRasterBand(2), src_ds.GetRasterBand(3), 256, ct ) if err <> 0: return err gtiff_driver = GetDriverByName('GTiff') if gtiff_driver i...
if target_ds is None:
if target_ds is None or target_ds == 'NULL':
def Create(self, filename, xsize, ysize, bands=1, datatype=GDT_Byte, options = []): target_ds = _gdal.GDALCreate( self._o, filename, xsize, ysize, bands, datatype, options )
if target_ds is None:
if target_ds is None or target_ds == 'NULL':
def CreateCopy(self, filename, source_ds, strict=1, options=[], callback = None, callback_data = None ): target_ds = _gdal.GDALCreateCopy( self._o, filename, source_ds._o, strict, options, callback, callback_data ) if target_ds is None: return None else: _gdal.GDALDereferenceDataset( target_ds ) return Dataset(target_d...
if _ct is None:
if _ct is None or _ct == 'NULL':
def GetRasterColorTable(self): _ct = _gdal.GDALGetRasterColorTable( self._o ) if _ct is None: return None else: return ColorTable( _ct )
if _o is None:
if _o is None or _o == 'NULL':
def GetOverview(self, ov_index ): _o = _gdal.GDALGetOverview( self._o, ov_index ) if _o is None: return None else: return Band( _obj = _o )
outfile = 'graticule.shp'
outfile = None
def Usage(): print 'Usage: mkgraticule [-connected] [-s stepsize] [-substep substepsize]' print ' [-t_srs srs] [-range xmin ymin xmax ymax] outfile' print sys.exit(1)
Usage()
outfile = "graticule.shp"
def Usage(): print 'Usage: mkgraticule [-connected] [-s stepsize] [-substep substepsize]' print ' [-t_srs srs] [-range xmin ymin xmax ymax] outfile' print sys.exit(1)
base.append([CXT_Attribute,'Z',[CXT_Text,yval]])
base.append([CXT_Attribute,'Z',[CXT_Text,zval]])
def serialize(self,with_Z=0): base = [CXT_Element,'GCP'] base.append([CXT_Attribute,'Id',[CXT_Text,self.Id]]) pixval = '%0.15E' % self.GCPPixel lineval = '%0.15E' % self.GCPLine xval = '%0.15E' % self.GCPX yval = '%0.15E' % self.GCPY zval = '%0.15E' % self.GCPZ base.append([CXT_Attribute,'Pixel',[CXT_Text,pixval]]) bas...
return _gdal.OGR_G_Transform( self._o, srs_out._o )
return _gdal.OGR_G_TransformTo( self._o, srs_out._o )
def TransformTo( self, srs_out ): return _gdal.OGR_G_Transform( self._o, srs_out._o )
ogr_module],debug=0 )
ogr_module] )
def unique(list): """Stolen from MapScript setup script""" dict = {} for item in list: dict[item] = '' return dict.keys()
ogr_module],debug=1 )
ogr_module],debug=0 )
def unique(list): """Stolen from MapScript setup script""" dict = {} for item in list: dict[item] = '' return dict.keys()
bands = 1
bands = file_infos[0].bands
def Usage(): print 'Usage: gdal_merge.py [-o out_filename] [-f out_format] [-v] [-pct]' print ' [-ps pixelsize_x pixelsize_y] [-separate]' print ' [-ul_lr ulx uly lrx lry] [-n nodata_value]' print ' input_files' print
fi.copy_into( t_fh, 1, 1, nodata )
for band in range(1, bands+1): fi.copy_into( t_fh, band, band, nodata )
def Usage(): print 'Usage: gdal_merge.py [-o out_filename] [-f out_format] [-v] [-pct]' print ' [-ps pixelsize_x pixelsize_y] [-separate]' print ' [-ul_lr ulx uly lrx lry] [-n nodata_value]' print ' input_files' print
if _obj = None or _obj == "NULL" :
if _obj is None or _obj == "NULL" :
def Open(file,access=GA_ReadOnly): _gdal.GDALAllRegister() _obj = _gdal.GDALOpen(file,access) if _obj = None or _obj == "NULL" : return None; else: _gdal.GDALDereferenceDataset( _obj ) return Dataset(_obj)
print cb_data, complete
print '%s %3d%%' % (cb_data, int(complete*100.0))
def progress_cb( complete, message, cb_data ): print cb_data, complete
256, ct,
color_count, ct,
def Usage(): print 'Usage: rgb2pct.py [-n colors] [-of format] source_file dest_file' sys.exit(1)
gtiff_driver.Delete( tif_filename )
def Usage(): print 'Usage: rgb2pct.py [-n colors] [-of format] source_file dest_file' sys.exit(1)
if obj is None and obj != 'NULL':
if obj is None or obj == 'NULL':
def CreateLayer(self, name, srs = None, geom_type = wkbUnknown, options = [] ): if srs is None: srs_o = 'NULL' else: srs_o = srs._o md_c = _gdal.ListToStringList( options ) obj = _gdal.OGR_DS_CreateLayer( self._o, name, srs_o, geom_type, md_c) _gdal.CSLDestroy(md_c) if obj is None and obj != 'NULL': raise ValueError, g...
def __init__(self, type=None, obj=None):
def __init__(self, type=None, obj=None, wkt=None):
def __init__(self, type=None, obj=None): if obj is not None: self._o = obj elif type is not None: self._o = _gdal.OGR_G_CreateGeometry( type ) else: raise ValueError, 'OGRGeometry may not be directly instantiated.'
tgw_uly = min(t_uly,self.uly)
def copy_into( self, t_fh, s_band = 1, t_band = 1, nodata_arg=None ): """ Copy this files image into target file.
tgw_lry = max(t_lry,self.lry)
if t_geotransform[5] < 0: tgw_uly = min(t_uly,self.uly) tgw_lry = max(t_lry,self.lry) else: tgw_uly = max(t_uly,self.uly) tgw_lry = min(t_lry,self.lry)
def copy_into( self, t_fh, s_band = 1, t_band = 1, nodata_arg=None ): """ Copy this files image into target file.
if tgw_ulx >= tgw_lrx or tgw_uly <= tgw_lry: return 1
if tgw_ulx >= tgw_lrx: return 1 if t_geotransform[5] < 0 and tgw_uly <= tgw_lry: return 1 if t_geotransform[5] > 0 and tgw_uly >= tgw_lry: return 1
def copy_into( self, t_fh, s_band = 1, t_band = 1, nodata_arg=None ): """ Copy this files image into target file.
proj_parms --- tuple of 16 coordinate system parameters (double
proj_parms --- tuple of 17 coordinate system parameters (double
def ImportFromPCI( self, proj, units = "METRE", proj_parms = None ):
is a tuple of 16 double precition floating point values with
is a tuple of 17 double precition floating point values with
def ExportToPCI(self):