omnata-plugin-runtime 0.6.7a176__tar.gz → 0.6.9__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.6.7a176
3
+ Version: 0.6.9
4
4
  Summary: Classes and common runtime components for building and running Omnata Plugins
5
5
  Author: James Weakley
6
6
  Author-email: james.weakley@omnata.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "omnata-plugin-runtime"
3
- version = "0.6.7-a176"
3
+ version = "0.6.9"
4
4
  description = "Classes and common runtime components for building and running Omnata Plugins"
5
5
  authors = ["James Weakley <james.weakley@omnata.com>"]
6
6
  readme = "README.md"
@@ -15,7 +15,7 @@ else:
15
15
  # Python 3.8 and below
16
16
  from typing_extensions import Annotated
17
17
 
18
-
18
+ import zipfile
19
19
  import datetime
20
20
  import http
21
21
  import json
@@ -1296,7 +1296,7 @@ class InboundSyncRequest(SyncRequest):
1296
1296
  ]
1297
1297
  for datetime_property in datetime_properties:
1298
1298
  try:
1299
- if datetime_property in data:
1299
+ if datetime_property in data and data[datetime_property] is not None:
1300
1300
  data[datetime_property] = parse(
1301
1301
  data[datetime_property]
1302
1302
  ).isoformat()
@@ -2552,4 +2552,23 @@ def find_udf_functions(path:str = '.') -> List[UDFDefinition]:
2552
2552
  description='The connection object, obtained from calling PLUGIN.PLUGIN_CONNECTION.')] + udf_obj.params
2553
2553
  matching_classes.append(udf_obj)
2554
2554
 
2555
- return matching_classes
2555
+ return matching_classes
2556
+
2557
+ def get_static_file_contents(relative_path:str) -> bytes:
2558
+ """
2559
+ Retrieve file packaged with this plugin, by extracting it from the zip file.
2560
+ The relative path will be relative to the root of the src folder of the plugin.
2561
+ """
2562
+ # this file will be inside the zip file, so we can find it by looking at the path of this file
2563
+ full_path_to_this = os.path.abspath(__file__)
2564
+ split_position = full_path_to_this.find('app.zip')
2565
+ if split_position == -1:
2566
+ with open(relative_path, 'rb') as f:
2567
+ return f.read()
2568
+ # Add the length of 'app.zip' to split just after it
2569
+ split_position += len('app.zip')
2570
+
2571
+ path_to_zip = full_path_to_this[:split_position]
2572
+ with zipfile.ZipFile(path_to_zip, 'r') as z:
2573
+ with z.open(relative_path, 'r') as f:
2574
+ return f.read()