Skip to content
Permalink
Browse files

transpile.js createPythonClassImports

  • Loading branch information
kroitor committed Jan 30, 2020
1 parent ab43e93 commit ca18c4dca424cd58c706cb0778de977b824a632d
Showing with 19 additions and 8 deletions.
  1. +19 −8 build/transpile.js
@@ -447,14 +447,14 @@ class Transpiler {
return 'class ' + className + '(' + baseClass + '):'
}

createPythonClassHeader (ccxtImports, bodyAsString) {
createPythonClassHeader (imports, bodyAsString) {
return [
"# -*- 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",
"",
... ccxtImports,
... imports,
// 'from ' + importFrom + ' import ' + baseClass,
... (bodyAsString.match (/basestring/) ? [
"",
@@ -468,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 = {
@@ -484,15 +499,11 @@ 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 = []

0 comments on commit ca18c4d

Please sign in to comment.
You can’t perform that action at this time.