Bug Fixes

This commit is contained in:
Luis Fernando Molina committed 2020-02-09 16:35:17 +01:00
1 parent 82bc086e92
commit b1af6e078c
131 files changed
+8597 -1930

No files matched your search

+28 -12
View File
@@ -447,15 +447,19 @@ class Transpiler {
return 'class ' + className + '(' + baseClass + '):'
}
createPythonClassHeader (ccxtImports, bodyAsString) {
createPythonClassHeader (imports, bodyAsString) {
return [
"# -*- coding: utf-8 -*-\n",
"# -*- coding: utf-8 -*-",
"",
"# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:",
"# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code\n",
... ccxtImports,
"# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code",
"",
... imports,
// 'from ' + importFrom + ' import ' + baseClass,
... (bodyAsString.match (/basestring/) ? [
"\n# -----------------------------------------------------------------------------\n",
"",
"# -----------------------------------------------------------------------------",
"",
"try:",
" basestring # Python 3",
"except NameError:",
@@ -464,6 +468,21 @@ class Transpiler {
]
}
createPythonClassImports (baseClass, async = false) {
const baseClasses = {
'Exchange': 'base.exchange',
}
async = (async ? '.async_support' : '')
return [
(baseClass.indexOf ('ccxt.') === 0) ?
('import ccxt' + async + ' as ccxt') :
('from ccxt' + async + '.' + safeString (baseClasses, baseClass, baseClass) + ' import ' + baseClass)
]
}
createPythonClass (className, baseClass, body, methods, async = false) {
const pythonStandardLibraries = {
@@ -471,6 +490,7 @@ class Transpiler {
'hashlib': 'hashlib',
'math': 'math',
'json.loads': 'json',
'sys': 'sys',
}
const baseClasses = {
@@ -479,20 +499,16 @@ class Transpiler {
async = (async ? '.async_support' : '')
const ccxtImports = [
(baseClass.indexOf ('ccxt.') === 0) ?
('import ccxt' + async + ' as ccxt') :
('from ccxt' + async + '.' + safeString (baseClasses, baseClass, baseClass) + ' import ' + baseClass)
]
const imports = this.createPythonClassImports (baseClass, async)
let bodyAsString = body.join ("\n")
let header = this.createPythonClassHeader (ccxtImports, bodyAsString)
let header = this.createPythonClassHeader (imports, bodyAsString)
const libraries = []
for (let library in pythonStandardLibraries) {
const regex = new RegExp ("[^\\']" + library + "[^\\'a-zA-Z]")
const regex = new RegExp ("[^\\'a-zA-Z]" + library + "[^\\'a-zA-Z]")
if (bodyAsString.match (regex))
libraries.push ('import ' + pythonStandardLibraries[library])
}