eric7/Globals/__init__.py

branch
eric7
changeset 8467
bccf0a3fa67c
parent 8459
0ae07748dbe8
child 8468
57ed532d4cde
equal deleted inserted replaced
8466:bb21fd901f49 8467:bccf0a3fa67c
42 42
43 def isWindowsPlatform(): 43 def isWindowsPlatform():
44 """ 44 """
45 Function to check, if this is a Windows platform. 45 Function to check, if this is a Windows platform.
46 46
47 @return flag indicating Windows platform (boolean) 47 @return flag indicating Windows platform
48 @rtype bool
48 """ 49 """
49 return sys.platform.startswith(("win", "cygwin")) 50 return sys.platform.startswith(("win", "cygwin"))
50 51
51 52
52 def isMacPlatform(): 53 def isMacPlatform():
53 """ 54 """
54 Function to check, if this is a Mac platform. 55 Function to check, if this is a Mac platform.
55 56
56 @return flag indicating Mac platform (boolean) 57 @return flag indicating Mac platform
58 @rtype bool
57 """ 59 """
58 return sys.platform == "darwin" 60 return sys.platform == "darwin"
59 61
60 62
61 def isLinuxPlatform(): 63 def isLinuxPlatform():
62 """ 64 """
63 Function to check, if this is a Linux platform. 65 Function to check, if this is a Linux platform.
64 66
65 @return flag indicating Linux platform (boolean) 67 @return flag indicating Linux platform
68 @rtype bool
66 """ 69 """
67 return sys.platform.startswith("linux") 70 return sys.platform.startswith("linux")
68 71
69 72
70 def desktopName(): 73 def desktopName():
192 195
193 def getConfigDir(): 196 def getConfigDir():
194 """ 197 """
195 Module function to get the name of the directory storing the config data. 198 Module function to get the name of the directory storing the config data.
196 199
197 @return directory name of the config dir (string) 200 @return directory name of the config dir
201 @rtype str
198 """ 202 """
199 if configDir is not None and os.path.exists(configDir): 203 if configDir is not None and os.path.exists(configDir):
200 hp = configDir 204 hp = configDir
201 else: 205 else:
202 cdn = ".eric7" 206 cdn = ".eric7"
238 242
239 def setConfigDir(d): 243 def setConfigDir(d):
240 """ 244 """
241 Module function to set the name of the directory storing the config data. 245 Module function to set the name of the directory storing the config data.
242 246
243 @param d name of an existing directory (string) 247 @param d name of an existing directory
248 @type str
244 """ 249 """
245 global configDir 250 global configDir
246 configDir = os.path.expanduser(d) 251 configDir = os.path.expanduser(d)
247 252
248 253
255 """ 260 """
256 import distutils.sysconfig 261 import distutils.sysconfig
257 return distutils.sysconfig.get_python_lib(True) 262 return distutils.sysconfig.get_python_lib(True)
258 263
259 264
260 # TODO: change this for PyQt6
261 def getPyQt6ModulesDirectory(): 265 def getPyQt6ModulesDirectory():
262 """ 266 """
263 Function to determine the path to PyQt6 modules directory. 267 Function to determine the path to PyQt6 modules directory.
264 268
265 @return path to the PyQt6 modules directory (string) 269 @return path to the PyQt6 modules directory
270 @rtype str
266 """ 271 """
267 import distutils.sysconfig 272 import distutils.sysconfig
268 273
269 pyqtPath = os.path.join(distutils.sysconfig.get_python_lib(True), "PyQt6") 274 pyqtPath = os.path.join(distutils.sysconfig.get_python_lib(True), "PyQt6")
270 if os.path.exists(pyqtPath): 275 if os.path.exists(pyqtPath):
478 def toBool(value): 483 def toBool(value):
479 """ 484 """
480 Module function to convert a value to bool. 485 Module function to convert a value to bool.
481 486
482 @param value value to be converted 487 @param value value to be converted
488 @type str
483 @return converted data 489 @return converted data
490 @rtype bool
484 """ 491 """
485 if value in ["true", "1", "True"]: 492 if value in ["true", "1", "True"]:
486 return True 493 return True
487 elif value in ["false", "0", "False"]: 494 elif value in ["false", "0", "False"]:
488 return False 495 return False
493 def toList(value): 500 def toList(value):
494 """ 501 """
495 Module function to convert a value to a list. 502 Module function to convert a value to a list.
496 503
497 @param value value to be converted 504 @param value value to be converted
505 @type None, list or Any
498 @return converted data 506 @return converted data
507 @rtype list
499 """ 508 """
500 if value is None: 509 if value is None:
501 return [] 510 return []
502 elif not isinstance(value, list): 511 elif not isinstance(value, list):
503 return [value] 512 return [value]
508 def toByteArray(value): 517 def toByteArray(value):
509 """ 518 """
510 Module function to convert a value to a byte array. 519 Module function to convert a value to a byte array.
511 520
512 @param value value to be converted 521 @param value value to be converted
522 @type QByteArray or None
513 @return converted data 523 @return converted data
524 @rtype QByteArray
514 """ 525 """
515 if value is None: 526 if value is None:
516 return QByteArray() 527 return QByteArray()
517 else: 528 else:
518 return value 529 return value
521 def toDict(value): 532 def toDict(value):
522 """ 533 """
523 Module function to convert a value to a dictionary. 534 Module function to convert a value to a dictionary.
524 535
525 @param value value to be converted 536 @param value value to be converted
537 @type dict or None
526 @return converted data 538 @return converted data
539 @rtype dict
527 """ 540 """
528 if value is None: 541 if value is None:
529 return {} 542 return {}
530 else: 543 else:
531 return value 544 return value

eric ide

mercurial