Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __lt__(self, other):
if isinstance(other, VersionNumber):
return self.value < other.value
elif isinstance(other, string_types):
return self.value < VersionNumber(other).value
elif isinstance(other, tuple):
return self.value[:len(other)] < other
elif isinstance(other, int):
return self.major < other
else:
raise TypeError("Cannot compare other object with version number")
def __lt__(self, other):
if isinstance(other, VersionNumber):
return self.value < other.value
elif isinstance(other, string_types):
return self.value < VersionNumber(other).value
elif isinstance(other, tuple):
return self.value[:len(other)] < other
elif isinstance(other, int):
return self.major < other
else:
raise TypeError("Cannot compare other object with version number")
def add(self, filename, link_to_file, save_with_document, left, top, width, height):
version = VersionNumber(self.parent.book.app.version)
if not link_to_file and version >= 15:
# Office 2016 for Mac is sandboxed. This path seems to work without the need of granting access explicitly
xlwings_picture = os.path.expanduser("~") + '/Library/Containers/com.microsoft.Excel/Data/xlwings_picture.png'
shutil.copy2(filename, xlwings_picture)
filename = xlwings_picture
sheet_index = self.parent.xl.entry_index.get()
picture = Picture(
self.parent,
self.parent.xl.make(
at=self.parent.book.xl.sheets[sheet_index],
new=kw.picture,
with_properties={
kw.file_name: posix_to_hfs_path(filename),
kw.link_to_file: link_to_file,
def __eq__(self, other):
if isinstance(other, VersionNumber):
return self.value == other.value
elif isinstance(other, string_types):
return self.value == VersionNumber(other).value
elif isinstance(other, tuple):
return self.value[:len(other)] == other
elif isinstance(other, int):
return self.major == other
else:
return False
def __eq__(self, other):
if isinstance(other, VersionNumber):
return self.value == other.value
elif isinstance(other, string_types):
return self.value == VersionNumber(other).value
elif isinstance(other, tuple):
return self.value[:len(other)] == other
elif isinstance(other, int):
return self.major == other
else:
return False
def version(self):
"""
Returns the Excel version number object.
Examples
--------
>>> import xlwings as xw
>>> xw.App().version
VersionNumber('15.24')
>>> xw.apps[10559].version.major
15
.. versionchanged:: 0.9.0
"""
return VersionNumber(self.impl.version)