Skip to content

Commit 7d6b0c0

Browse files
committed
Add new release v0.1.1
1 parent e4425a8 commit 7d6b0c0

6 files changed

Lines changed: 93 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
# Changelog
22
WITSML 2.1 to BSON parser changelogs
33

4+
## [0.1.1] - 2023-09-23
5+
- Add Python 3 module (>= 3.8) 🐍✔️
6+
- Add Node JS (>= v16.20.2) addon ✔️
7+
- Add PGP public key for signature verification ✔️
8+
- Add C tests (in progress) ⏰🧪👀
9+
410
## [0.1.0] - 2023-09-03
5-
- Inicial release of WITSML 2.1 to BSON parser
11+
- Inicial release of WITSML 2.1 to BSON parser ✔️
612

713
## [master] - current
814

15+
[0.1.1]: https://github.com/devfabiosilva/witsml21parser/tree/v0.1.1
916
[0.1.0]: https://github.com/devfabiosilva/witsml21parser/tree/v0.1.0
1017
[master]: https://github.com/devfabiosilva/witsml21parser/tree/master
1118

NodeJS/app.js

Lines changed: 76 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,81 @@
1-
// Begin add sample application Node WITSML 2.1 parser
2-
//import { BSON, EJSON, ObjectId } from 'bson';
3-
const { BSON, EJSON } = require('bson');
4-
a = require('./jswitsml21bson')
1+
const witml21bson = require('./jswitsml21bson')
2+
const { BSON } = require('bson')
53

6-
b = a.create()
4+
parser = witml21bson.create()
75

8-
bytes = b.parseFromFile('../examples/xmls/OpsReport.xml')
6+
O_LIST = [
7+
'BhaRun', 'CementJob', 'DepthRegImage', 'DownholeComponent', 'DrillReport', 'FluidsReport', 'Log', 'MudLogReport', 'OpsReport', 'Rig',
8+
'Risk', 'StimJob', 'SurveyProgram', 'Target', 'ToolErrorModel', 'Trajectory', 'Tubular', 'Well', 'Wellbore', 'WellboreCompletion',
9+
'WellboreGeology', 'WellCMLedger', 'WellCompletion', "INVALID_Log", "INVALID_OpsReport"
10+
]
911

10-
const doc = BSON.deserialize(bytes);
11-
//console.log(doc["website"])
12-
//console.log(doc["dependencies"]["gSoap"])
13-
console.log(doc)
14-
console.log(EJSON.stringify(doc, { relaxed: false }));
12+
console.log("\n" + parser.getInstanceName() + "\n")
1513

16-
b=null
14+
const DEFAULT_PATH = "../examples/"
15+
const DEFAULT_PATH_XML = DEFAULT_PATH + "xmls/"
16+
17+
function save_to_file(caller, file_path) {
18+
var ret = false
19+
try {
20+
caller(file_path)
21+
} catch (e) {
22+
ret = true
23+
console.log("Error " + e.toString())
24+
console.log("Maybe file " + file_path + " exists")
25+
}
26+
27+
return ret
28+
}
29+
30+
function print_parser_error(parser) {
31+
console.log("Error number: " + parser.getError().toString())
32+
var faultString = parser.getFaultString()
33+
var XMLfaultdetail = parser.getXMLfaultdetail()
34+
if (faultString != null)
35+
console.log(faultString)
36+
if (XMLfaultdetail != null)
37+
console.log(XMLfaultdetail)
38+
}
39+
40+
function readWitsml21Objects(parser) {
41+
for (o of O_LIST) {
42+
var fp = DEFAULT_PATH_XML + o + ".xml"
43+
var bsonByte
44+
console.log("\nOpening " + fp)
45+
console.log(o)
46+
try {
47+
bsonByte = parser.parseFromFile(fp)
48+
} catch (e) {
49+
console.log(e.toString())
50+
print_parser_error(parser)
51+
continue
52+
}
53+
54+
try {
55+
console.log("WITSML 2.1 XML statistics:")
56+
console.log(parser.getStatistics())
57+
var jsonFile = DEFAULT_PATH + o + ".json"
58+
console.log("Saving JSON to file " + jsonFile)
59+
60+
if (save_to_file(parser.saveToFileJSON, jsonFile))
61+
continue
62+
63+
bsonFile = DEFAULT_PATH + o + ".bson"
64+
console.log("Saving BSON to file " + bsonFile)
65+
66+
if (save_to_file(parser.saveToFile, bsonFile))
67+
continue
68+
69+
console.log(bsonByte)
70+
console.log("BSON to NodeJS object")
71+
console.log(BSON.deserialize(bsonByte))
72+
console.log("JSON string")
73+
console.log(parser.getJson())
74+
} catch (e) {
75+
console.log("Error " + e.toString())
76+
}
77+
}
78+
}
79+
80+
readWitsml21Objects(parser)
1781

Python/witsml21parser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def save_to_file(caller, file_path) -> bool:
2121
except Exception as e:
2222
ret = True
2323
print("File saving error: " + str(e))
24-
finally:
2524
print("Maybe file " + file_path + " exists")
2625

2726
return ret

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@ Answer is simple.
257257
- Only two library dependency ([gSoap](https://www.genivia.com/products.html) and [libbson](https://github.com/mongodb/mongo-c-driver/tree/master/src/libbson))
258258
- No garbage collector on parsing objects
259259

260+
# SIGNING KEY
261+
262+
_Keys for signature_:
263+
264+
**[fabioegel@gmail.com](mailto:fabioegel@gmail.com)**
265+
**fingerprint**: 6E21 A6B6 E1A4 6580 CA00 FA54 1077 26E9 14B9 16A2
266+
260267
# LICENSES
261268

262269
This project is fully open source and MIT license.

binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"libraries": [
99
"-Wl,--start-group ../lib/libcws_js.a ../lib/libbson-shared-1.0.a ../soapC_shared.o -Wl,--end-group"
1010
],
11-
"defines": ["CWS_LITTLE_ENDIAN", "WITH_STATISTICS", "JS_SOAP_DEBUG"],
11+
"defines": ["CWS_LITTLE_ENDIAN", "WITH_STATISTICS"],
1212
"cflags": ["-Wno-stringop-truncation", "-Wno-format-truncation"],
1313
}
1414
]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def main():
1414
libraries=['cws_py', 'bson-shared-1.0'],
1515
extra_objects=["soapC_shared.o"],
1616
include_dirs=['include'],
17-
define_macros=[('CWS_LITTLE_ENDIAN', None), ('WITH_STATISTICS', None), ('PY_SOAP_DEBUG', None)]
17+
define_macros=[('CWS_LITTLE_ENDIAN', None), ('WITH_STATISTICS', None)]
1818
)])
1919

2020
if __name__ == "__main__":

0 commit comments

Comments
 (0)