Best Python code snippet using autotest_python
_mobileservice.py
Source:_mobileservice.py
...52 self._referer_url = self._securityHandler.referer_url53 self._proxy_port = proxy_port54 self._proxy_url = proxy_url55 if initialize:56 self.__init()57 #----------------------------------------------------------------------58 def __init(self):59 """ inializes the properties """60 params = {61 "f" : "json",62 }63 json_dict = self._do_get(self._url, params,64 securityHandler=self._securityHandler,65 proxy_url=self._proxy_url,66 proxy_port=self._proxy_port)67 self._json_dict = json_dict68 self._json = json.dumps(self._json_dict)69 attributes = [attr for attr in dir(self)70 if not attr.startswith('__') and \71 not attr.startswith('_')]72 for k,v in json_dict.iteritems():73 if k in attributes:74 setattr(self, "_"+ k, v)75 else:76 print k, " - attribute not implemented for Mobile Service Layer."77 #----------------------------------------------------------------------78 def __str__(self):79 """returns object as string"""80 if self._json is None:81 self.__init()82 return self._json83 #----------------------------------------------------------------------84 def __iter__(self):85 """86 returns key/value pair87 """88 attributes = json.loads(str(self))89 for att in attributes.keys():90 yield (att, getattr(self, att))91 #----------------------------------------------------------------------92 @property93 def drawingInfo(self):94 """gets the services drawing information"""95 if self._drawingInfo is None:96 self.__init()97 return self._drawingInfo98 #----------------------------------------------------------------------99 @property100 def extent(self):101 """returns the service layer extent"""102 if self._extent is None:103 self.__init()104 return self._extent105 #----------------------------------------------------------------------106 @property107 def canModifyLayer(self):108 """returns value for can modify layer"""109 if self._canModifyLayer is None:110 self.__init()111 return self._canModifyLayer112 #----------------------------------------------------------------------113 @property114 def advancedQueryCapabilities(self):115 """gets the advancedQueryCapabilities value"""116 if self._advancedQueryCapabilities is None:117 self.__init()118 return self._advancedQueryCapabilities119 #----------------------------------------------------------------------120 @property121 def hasLabels(self):122 """returns the has labels value"""123 if self._hasLabels is None:124 self.__init()125 return self._hasLabels126 #----------------------------------------------------------------------127 @property128 def supportsAdvancedQueries(self):129 """returns the supportsAdvancedQueries value"""130 if self._supportsAdvancedQueries is None:131 self.__init()132 return self._supportsAdvancedQueries133 #----------------------------------------------------------------------134 @property135 def id(self):136 """returns the layers' id"""137 if self._id is None:138 self.__init()139 return self._id140 #----------------------------------------------------------------------141 @property142 def currentVersion(self):143 """gets the layers current version"""144 if self._currentVersion is None:145 self.__init()146 return self._currentVersion147 #----------------------------------------------------------------------148 @property149 def geometryType(self):150 """retusn the layers geometry type"""151 if self._geometryType is None:152 self.__init()153 return self._geometryType154 #----------------------------------------------------------------------155 @property156 def ownershipBasedAccessControlForFeatures(self):157 """returns the ownershipBasedAccessControlForFeatures value"""158 if self._ownershipBasedAccessControlForFeatures is None:159 self.__init()160 return self._ownershipBasedAccessControlForFeatures161 #----------------------------------------------------------------------162 @property163 def type(self):164 """gets the layer type"""165 if self._type is None:166 self.__init()167 return self._type168 #----------------------------------------------------------------------169 @property170 def useStandardizedQueries(self):171 """gets the useStandardizedQueries value"""172 if self._useStandardizedQueries is None:173 self.__init()174 return self._useStandardizedQueries175 #----------------------------------------------------------------------176 @property177 def hasAttachments(self):178 """returns if the layer has attachments enabled"""179 if self._hasAttachments is None:180 self.__init()181 return self._hasAttachments182 #----------------------------------------------------------------------183 @property184 def supportedQueryFormats(self):185 """returns the supportedQueryFormats value"""186 if self._supportedQueryFormats is None:187 self.__init()188 return self._supportedQueryFormats189 #----------------------------------------------------------------------190 @property191 def maxRecordCount(self):192 """returns the max record count"""193 if self._maxRecordCount is None:194 self.__init()195 return self._maxRecordCount196 #----------------------------------------------------------------------197 @property198 def description(self):199 """returns the service layer description"""200 if self._description is None:201 self.__init()202 return self._description203 #----------------------------------------------------------------------204 @property205 def defaultVisibility(self):206 """returns the defaultVisibility value"""207 if self._defaultVisibility is None:208 self.__init()209 return self._defaultVisibility210 #----------------------------------------------------------------------211 @property212 def typeIdField(self):213 """returns the type id field"""214 if self._typeIdField is None:215 self.__init()216 return self._typeIdField217 #----------------------------------------------------------------------218 @property219 def displayField(self):220 """returns the display field"""221 if self._displayField is None:222 self.__init()223 return self._display224 #----------------------------------------------------------------------225 @property226 def name(self):227 """returns the layers name"""228 if self._name is None:229 self.__init()230 return self._name231 #----------------------------------------------------------------------232 @property233 def supportsStatistics(self):234 """returns the supports statistics value"""235 if self._supportsStatistics is None:236 self.__init()237 return self._supportsStatistics238 #----------------------------------------------------------------------239 @property240 def fields(self):241 """gets the fields for the layer"""242 if self._fields is None:243 self.__init()244 return self._fields245 #----------------------------------------------------------------------246 @property247 def copyrightText(self):248 """gets the copy right text"""249 if self._copyrightText is None:250 self.__init()251 return self._copyrightText252 #----------------------------------------------------------------------253 @property254 def canScaleSymbols(self):255 """returns the can scale symbols value"""256 if self._canScaleSymbols is None:257 self.__init()258 return self._canScaleSymbols259 #----------------------------------------------------------------------260 @property261 def minScale(self):262 """returns the minScale value"""263 if self._minScale is None:264 self.__init()265 return self._minScale266 #----------------------------------------------------------------------267 @property268 def maxScale(self):269 """gets the max scale for the layer"""270 if self._maxScale is None:271 self.__init()272 return self._maxScale273########################################################################274class MobileService(BaseAGSServer):275 """276 Represents a single globe layer277 """278 _url = None279 _proxy_url = None280 _proxy_port = None281 _securityHandler = None282 _json = None283 _json_dict = None284 _layers = None285 _description = None286 _initialExtent = None287 _spatialReference = None288 _mapName = None289 _currentVersion = None290 _units = None291 _fullExtent = None292 _serviceDescription = None293 #----------------------------------------------------------------------294 def __init__(self, url,295 securityHandler=None,296 proxy_url=None,297 proxy_port=None,298 initialize=False):299 """Constructor"""300 self._url = url301 self._securityHandler = securityHandler302 if self._securityHandler is not None:303 self._referer_url = self._securityHandler.referer_url304 self._proxy_port = proxy_port305 self._proxy_url = proxy_url306 if initialize:307 self.__init()308 #----------------------------------------------------------------------309 def __init(self):310 """ inializes the properties """311 params = {312 "f" : "json",313 }314 json_dict = self._do_get(self._url, params,315 securityHandler=self._securityHandler,316 proxy_url=self._proxy_url,317 proxy_port=self._proxy_port)318 self._json_dict = json_dict319 self._json = json.dumps(self._json_dict)320 attributes = [attr for attr in dir(self)321 if not attr.startswith('__') and \322 not attr.startswith('_')]323 for k,v in json_dict.iteritems():324 if k in attributes:325 setattr(self, "_"+ k, v)326 else:327 print k, " - attribute not implemented for Mobile Service."328 #----------------------------------------------------------------------329 def __str__(self):330 """returns object as string"""331 if self._json is None:332 self.__init()333 return self._json334 #----------------------------------------------------------------------335 def __iter__(self):336 """337 returns key/value pair338 """339 attributes = json.loads(str(self))340 for att in attributes.keys():341 yield [att, getattr(self, att)]342 #----------------------------------------------------------------------343 @property344 def layers(self):345 """gets the service layers"""346 if self._layers is None:347 self.__init()348 lyrs = []349 for lyr in self._layers:350 url = self._url + "/%s" % lyr['id']351 lyr['object'] = MobileServiceLayer(url=url,352 securityHandler=self._securityHandler,353 proxy_url=self._proxy_url,354 proxy_port=self._proxy_port,355 initialize=False)356 return self._layers357 #----------------------------------------------------------------------358 @property359 def description(self):360 """gets the service description"""361 if self._description is None:362 self.__init()363 return self._description364 #----------------------------------------------------------------------365 @property366 def initialExtent(self):367 """gets the service initial extent"""368 if self._initialExtent is None:369 self.__init()370 return self._initialExtent371 #----------------------------------------------------------------------372 @property373 def spatialReference(self):374 """gets the spatial reference"""375 if self._spatialReference is None:376 self.__init()377 return self._spatialReference378 #----------------------------------------------------------------------379 @property380 def mapName(self):381 """gets the map name"""382 if self._mapName is None:383 self._mapName384 return self._mapName385 #----------------------------------------------------------------------386 @property387 def currentVersion(self):388 """gets the current version"""389 if self._currentVersion is None:390 self.__init()391 return self._currentVersion392 #----------------------------------------------------------------------393 @property394 def units(self):395 """gets the units for the service"""396 if self._units is None:397 self.__init()398 return self._units399 #----------------------------------------------------------------------400 @property401 def fullExtent(self):402 """returns the service full extent"""403 if self._fullExtent is None:404 self.__init()405 return self._fullExtent406 #----------------------------------------------------------------------407 @property408 def serviceDescription(self):409 """returns the service description"""410 if self._serviceDescription is None:411 self.__init()...
tiledservice.py
Source:tiledservice.py
...63 self._referer_url = securityHandler.referer_url64 self._proxy_url = proxy_url65 self._proxy_port = proxy_port66 if initialize:67 self.__init()68 #----------------------------------------------------------------------69 def __init(self):70 """ loads the data into the class """71 params = {"f": "json"}72 json_dict = self._do_get(self._url, params,73 securityHandler=self._securityHandler,74 proxy_url=self._proxy_url, proxy_port=self._proxy_port)75 attributes = [attr for attr in dir(self)76 if not attr.startswith('__') and \77 not attr.startswith('_')]78 for k,v in json_dict.iteritems():79 if k in attributes:80 setattr(self, "_"+ k, json_dict[k])81 else:82 print k, " - attribute not implemented in tiled service."83 #----------------------------------------------------------------------84 @property85 def maxExportTilesCount(self):86 """ returns the max export tiles count"""87 if self._maxExportTilesCount is None:88 self.__init()89 return self._maxExportTilesCount90 #----------------------------------------------------------------------91 @property92 def exportTilesAllowed(self):93 """ export tiles allowed """94 if self._exportTilesAllowed is None:95 self.__init()96 return self._exportTilesAllowed97 #----------------------------------------------------------------------98 @property99 def securityHandler(self):100 """ gets the security handler """101 return self._securityHandler102 #----------------------------------------------------------------------103 @securityHandler.setter104 def securityHandler(self, value):105 """ sets the security handler """106 if isinstance(value, BaseSecurityHandler):107 if isinstance(value, security.AGOLTokenSecurityHandler):108 self._securityHandler = value109 elif isinstance(value, security.OAuthSecurityHandler):110 self._securityHandler = value111 else:112 pass113 #----------------------------------------------------------------------114 def __str__(self):115 """ returns object as string """116 return json.dumps(dict(self),117 default=_date_handler)118 #----------------------------------------------------------------------119 def __iter__(self):120 """ iterator generator for public values/properties121 It only returns the properties that are public.122 """123 attributes = [attr for attr in dir(self)124 if not attr.startswith('__') and \125 not attr.startswith('_') and \126 not isinstance(getattr(self, attr), (types.MethodType,127 types.BuiltinFunctionType,128 types.BuiltinMethodType))129 ]130 for att in attributes:131 yield (att, getattr(self, att))132 #----------------------------------------------------------------------133 @property134 def initialExtent(self):135 """ initial extent of tile service """136 if self._initialExtent is None:137 self.__init()138 return self._initialExtent139 #----------------------------------------------------------------------140 @property141 def mapName(self):142 """ returns the map name """143 if self._mapName is None:144 self.__init()145 return self._mapName146 #----------------------------------------------------------------------147 @property148 def documentInfo(self):149 """ returns the document information """150 if self._documentInfo is None:151 self.__init()152 return self._documentInfo153 #----------------------------------------------------------------------154 @property155 def copyrightText(self):156 """ returns the copyright information """157 if self._copyrightText is None:158 self.__init()159 return self._copyrightText160 #----------------------------------------------------------------------161 @property162 def id(self):163 """ returns the ID """164 if self._id is None:165 self.__init()166 return self._id167 #----------------------------------------------------------------------168 @property169 def layers(self):170 """ returns the layers """171 if self._layers is None:172 self.__init()173 return self._layers174 #----------------------------------------------------------------------175 @property176 def tables(self):177 """ returns the tables in the map service """178 if self._tables is None:179 self.__init()180 return self._tables181 #----------------------------------------------------------------------182 @property183 def supportedImageFormatTypes(self):184 """ returns the supported image format types """185 if self._supportedImageFormatTypes is None:186 self.__init()187 return self._supportedImageFormatTypes188 #----------------------------------------------------------------------189 @property190 def storageFormat(self):191 """ returns the storage format """192 if self._storageFormat is None:193 self.__init()194 return self._storageFormat195 #----------------------------------------------------------------------196 @property197 def capabilities(self):198 """ returns the capabilities """199 if self._capabilities is None:200 self.__init()201 return self._capabilities202 #----------------------------------------------------------------------203 @property204 def access(self):205 """ returns the access value """206 if self._access is None:207 self.__init()208 return self._access209 #----------------------------------------------------------------------210 @property211 def currentVersion(self):212 """ returns the current version """213 if self._currentVersion is None:214 self.__init()215 return self._currentVersion216 #----------------------------------------------------------------------217 @property218 def units(self):219 """ returns the units """220 if self._units is None:221 self.__init()222 return self._units223 #----------------------------------------------------------------------224 @property225 def type(self):226 """ returns the type """227 if self._type is None:228 self.__init()229 return self._type230 #----------------------------------------------------------------------231 @property232 def serviceDescription(self):233 """ returns the service description """234 if self._serviceDescription is None:235 self.__init()236 return self._serviceDescription237 #----------------------------------------------------------------------238 @property239 def status(self):240 """ returns the status """241 if self._status is None:242 self.__init()243 return self._status244 #----------------------------------------------------------------------245 @property246 def tileInfo(self):247 """ returns the tile information """248 if self._tileInfo is None:249 self.__init()250 return self._tileInfo251 #----------------------------------------------------------------------252 @property253 def description(self):254 """ returns the description """255 if self._description is None:256 self.__init()257 return self._description258 #----------------------------------------------------------------------259 @property260 def fullExtent(self):261 """ returns the full extent """262 if self._fullExtent is None:263 self.__init()264 return self._fullExtent265 #----------------------------------------------------------------------266 @property267 def singleFusedMapCache(self):268 """ information about the single fused map cache """269 if self._singleFusedMapCache is None:270 self.__init()271 return self._singleFusedMapCache272 #----------------------------------------------------------------------273 @property274 def name(self):275 """ returns the service name """276 if self._name is None:277 self.__init()278 return self._name279 #----------------------------------------------------------------------280 @property281 def created(self):282 """ returns the created value """283 if self._created is None:284 self.__init()285 return self._created286 #----------------------------------------------------------------------287 @property288 def maxScale(self):289 """ returns the maximum scale """290 if self._maxScale is None:291 self.__init()292 return self._maxScale293 #----------------------------------------------------------------------294 @property295 def modified(self):296 """ returns the modified value """297 if self._modified is None:298 self.__init()299 return self._modified300 #----------------------------------------------------------------------301 @property302 def spatialReference(self):303 """ returns the spatial reference value """304 if self._spatialReference is None:305 self.__init()306 return self._spatialReference307 #----------------------------------------------------------------------308 @property309 def minScale(self):310 """ returns the minimum scale """311 if self._minScale is None:312 self.__init()313 return self._minScale314 #----------------------------------------------------------------------315 @property316 def server(self):317 """ returns the server information """318 if self._server is None:319 self.__init()320 return self._server321 #----------------------------------------------------------------------322 @property323 def tileServers(self):324 """ returns the tile services value """325 if self._tileServers is None:326 self.__init()...
inif.py
Source:inif.py
1# MIT License2#3# Copyright (c) 2021 Ferhat GeçdoÄan All Rights Reserved.4# Distributed under the terms of the MIT License.5#6# inif[dot]py - fast .ini file parser in python7#8# github.com/ferhatgec/inif.py9# github.com/ferhatgec/inif10class inif_category:11 def __init__(self):12 self.category_name = ''13 self.key_value = {}14class inif:15 class inif_tokens:16 CategoryStart = '['17 CategoryEnd = ']'18 Eq = '='19 Comment = ';'20 def __init__(self):21 self.__init = []22 self.__category_start, \23 self.__category_data, \24 self.__key_data = False, False, False25 self.__category_name, self.__key, self.__data = '', '', ''26 def parse(self, file_data: str):27 for ch in file_data:28 if self.__key_data:29 if ch != '\n':30 self.__data += ch31 continue32 self.__key = self.__key.strip()33 if len(self.__init) > 1 and self.__init[len(self.__init) - 1].category_name == self.__category_name:34 self.__init[len(self.__init) - 1].key_value[self.__key].append(self.__data)35 else:36 val = inif_category()37 val.category_name = self.__category_name38 val.key_value = {39 self.__key: self.__data40 }41 self.__init.append(val)42 self.__key_data = False43 self.__key = ''44 self.__data = ''45 continue46 if self.__category_start:47 if ch != self.inif_tokens.CategoryEnd:48 self.__category_name += ch49 continue50 self.__category_start = False51 self.__category_data = True52 continue53 if ch == self.inif_tokens.CategoryStart:54 if not len(self.__category_name) == 1:55 self.__category_name = ''56 self.__category_start = True57 elif ch == self.inif_tokens.Eq:58 if self.__category_data and not len(self.__key) == 1:59 self.__key_data = True60 else:61 if self.__category_data and ch != ' ':62 self.__key += ch63 def get(self, category: str, key: str) -> str:64 for val in self.__init:65 if val.category_name == category:66 for store in val.key_value.items():67 if store[0] == key:68 return store[1]...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!