Bug Fixes
This commit is contained in:
1 parent
82bc086e92
commit
b1af6e078c
131 files changed
+8597
-1930
No files matched your search
+94
@@ -0,0 +1,94 @@
|
||||
"use strict"
|
||||
|
||||
const { execSync } = require ('child_process')
|
||||
const log = require ('ololog').noLocate
|
||||
const { groupBy } = require ('../ccxt.js')
|
||||
const { values } = Object
|
||||
const assert = require ('assert')
|
||||
|
||||
function cleanupOldTags () {
|
||||
|
||||
const tags = execSync ('git tag').toString ().split ('\n').filter (s => s).map (t => {
|
||||
|
||||
const [major, minor, patch] = t.replace ('v', '').split ('.').map (Number)
|
||||
|
||||
assert (major < 100)
|
||||
assert (minor < 100)
|
||||
|
||||
return {
|
||||
key: (major * 100) + minor,
|
||||
tag: t,
|
||||
major,
|
||||
minor,
|
||||
patch,
|
||||
}
|
||||
})
|
||||
|
||||
const tagsByMajorMinor = values (groupBy (tags, 'key')).sort ((a, b) => a[0].key - b[0].key)
|
||||
|
||||
// Preserve all tags for first 3 minor versions
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
|
||||
const tags = tagsByMajorMinor.pop ()
|
||||
|
||||
if (tags) {
|
||||
log.green.bright ('Preserving', tags[0].tag, '...', tags[tags.length - 1].tag)
|
||||
}
|
||||
}
|
||||
|
||||
// For older versions, leave only "round" numbered versions (1/10th)
|
||||
|
||||
let tagsToDelete = []
|
||||
|
||||
for (const tags of tagsByMajorMinor) {
|
||||
|
||||
for (const { tag, patch } of tags) {
|
||||
|
||||
if (patch === 1) {
|
||||
log.green ('Preserving', tag)
|
||||
|
||||
} else {
|
||||
tagsToDelete.push (tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.bright.red ('Deleting', tagsToDelete.length, 'tags...')
|
||||
|
||||
if (!process.argv.includes ('--paper')) {
|
||||
|
||||
/* If it happens on a CI server, we don't want it to fail the build because of a super
|
||||
long execution time (one tag deletion takes ~5 sec...), hence that limit here */
|
||||
|
||||
if (process.argv.includes ('--limit')) {
|
||||
tagsToDelete = tagsToDelete.slice (-500)
|
||||
}
|
||||
|
||||
for (const tag of tagsToDelete) {
|
||||
|
||||
log.dim ('Deleting', tag)
|
||||
execSync (`git tag -d ${tag} && git push origin :refs/tags/${tag}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// main entry point
|
||||
|
||||
if (require.main === module) {
|
||||
|
||||
// if called directly like `node module`
|
||||
|
||||
cleanupOldTags ()
|
||||
|
||||
} else {
|
||||
|
||||
// do nothing if required as a module
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
module.exports = {
|
||||
cleanupOldTags,
|
||||
}
|
||||
+28
-12
@@ -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])
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user