Re: Recommendation on PyCharm config when working with SCons
"KANNEGIESER Veit (MM)" <[email protected]>
| Newsgroups | gmane.comp.programming.tools.scons.user |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hello,
> Your SConscripts are scons's "configuration script", which are not
> executed directly by the Python interpreter, but rather handled
> by SCons in... ummm... interesting ways.
When trying to use pylint to find ugly places and to get code
refactoring hints like for Python 3 support,
i use in SConstruct files:
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# resolve names for pylint
if 'SCons' not in sys.modules:
from scons_dummy import AddPostAction, Alias, Clean, Default, \
Delete, Depends, Environment, Exit, Export, GetOption, \
Import, SConscript, SideEffect
vs2010 = Environment()
ghsARM = Environment()
iarARM = Environment()
tools = Environment()
ignore_missing_subprojects = False
only_engineering = False
comm_crc32_ML = 0
comm_crc32_TS = 0
comm_crc32_TD = 0
comm_crc32_report_ML = []
comm_crc32_report_TS = []
comm_crc32_report_TD = []
def get_version_and_counter_arguments():
'''for pylint only'''
return ('0001', '001', '0001')
def printTextFrame(list_arg):
'''for pylint only'''
if list_arg:
pass
def removeIfExist(name_arg):
'''for pylint only'''
if name_arg:
pass
so it imports functions that allow SCons like syntax, and it localy
implements some functions that otherwise would be in SConscript files.
If you are using the editor in PyCharm,
> or Atom, or Visual Studio Code, or SublimeText, or other popular
> Python editing systems that are more or less IDE, how is it going
> to figure out the SCons API that your SConscript uses? As you've
> seen, the call SConscript("blab") is just an undefined reference.
>
> You can probably import SCons into your sconscript as a temporary
> measure and see if it helps what you're after:
>
> from SCons.Script import *
>
>
> PyCharm and Visual Studio Code - the two I've looked at - have
> languages for describing what you want to recognize. VS Code uses
> TextMate, which PyCharm used to, but they have transitioned away
> for grammar extensions (PyCharm extension themselves are written
> in Java, sadly) - I don't remember what the new technology is
> called. But in glancing at plugin development docs, it's hard to
> see where this goes, because, again, things don't work in the same
> order as for a "normal" Python program.
>
>
>
>
>
> _______________________________________________ Scons-users
> mailing list [email protected]
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
regards
- --
Veit Kannegieser
software developer
Magneti Marelli GmbH
Instrument Cluster and Display
Waldburgstraße 21
70563 Stuttgart
Tel: +49 711 12371 129
Fax: +49 711 12371 198
mailto:[email protected]
Manager: Heinrich-Gerhard Schüring
Domicile: Stuttgart
Court of Registry: Stuttgart, HRB 761189
please send plain text mail.
please ignore the mail server appended spam.
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEElP6zc7O10FCIcxYNH1Nrgn5dJmkFAlyramIACgkQH1Nrgn5d
JmkBvBAAvSJPe2uxdoDFh992JY0dRnpAC9NFo6JMXvzG4dYtp5M9/RkutMg2ibqF
BgHx8nTSuO6U4QnLmNXTLP+v0WvyiJ1d5Oe8JbD7c4ompjBfJvSLJegX4TbNZHjD
v61ThncC8siDJymqNR+YcxJmTerTs3ayRBhYi2pwBMuLKp28Ld+ZVV4qkmHEBZf2
oGcIlPALY3ZzvVYP8tAI9L0kmwUheaaJpuRs0U/npFC+bvY255pWYvwE0av7wwxQ
qujf4UjOjgWZ1Q/bmVISzNwviMiOJYs94IbySMz/VVN9hl5onnPy2lf+kqT3OepE
VCNvqJ4XwbdsaUuo6EBumq8bG5b59AIW+NG0PadDCGUmS7w96f4C5Ph3jtCJ7TSW
od/2b4dKQCJajsn+4cEaDQrVjEa9vXiy3v/wgvVC4yN/ulL5eaTWwk1RajfhC4cE
5/WJMfk7nUwvGb6oaYanOWwxAXdbKbGUKZb7KRdApk2+7OtyhXygSxLacw3Sw4ro
ncuQ1tvSRyKJ3CkNIEJUq+bHbnmI3m8iCPXhKDdKprpegZrO2h/LKiKBXcfBvYgx
gjmnipy9risTqnv9MQ2U/LzeHHW3TjbBSq5J/Rymb4EsgXNNNgIlqClG+s+zZ4s4
QTghulsEnKsqpTwBqfOe26MH84f4L349jIP/duyenVlIsbiSDtQ=
=VfhJ
-----END PGP SIGNATURE-----
Besuchen Sie unseren Internetauftritt! - VISIT OUR WEB SITE! www.magnetimarelli.com Dieses Dokument ist vertraulich zu behandeln. Es ist nicht gestattet, es ohne unsere ausdrückliche Genehmigung weiterzuleiten, zu vervielfältigen oder den Inhalt zu verwerten. Wenn Sie nicht der beabsichtigte Empfänger sind, informieren Sie bitte den Absender und löschen diese Email. This document is to be treated confidentially. It is not allowed to pass on, duplicate, exploit or disclose the contents of this email in all respects without our expressed permission. If you are not the intended recipient, please contact the sender and delete this message. ---------------------------------------------------------------------------------------------------------- Geschäftsführer: Heinrich-Gerhard Schuering Sitz der Gesellschaft: Stuttgart Amtsgericht: Stuttgart HRB 761189
_______________________________________________
Scons-users mailing list
[email protected]
https://pairlist4.pair.net/mailman/listinfo/scons-users
scons_dummy.py
(text/plain, 7.2 KB)
'''
for use with pylint.
to avoid "Undefined variable 'Builder' (undefined-variable)"
usage: put in SConscript* file:
if 'SCons' not in sys.modules:
from scons_dummy import Builder, Environment, Export
'''
# pylint: disable = bad-indentation
# pylint: disable = invalid-name
# pylint: disable = exec-used
# pylint: disable = too-many-instance-attributes
# pylint: disable = too-many-arguments
# pylint: disable = too-many-boolean-expressions
from __future__ import print_function
import os
import sys
sys.stderr.write('scons_dummy.py should only used for pylint!\n')
def Builder(**kwargs):
'''dummy for pylint'''
if kwargs:
pass
class Environment(object):
'''dummy for pylint'''
def __init__(self, **kwargs):
'''dummy for pylint'''
self.dict = kwargs
self['DEVENV_EXE'] = '-'
self['CL_EXE'] = '-'
self['BINPATH'] = '-'
self.vc_version = self.dummy_builder
self.genVcxProj = self.dummy_builder
self.member = self.dummy_builder
self.gmemfile = self.dummy_builder
self.AddChecksumAndVersionHeaders = self.dummy_builder
self.lines_of_code = self.dummy_builder
self.sevenZip = self.dummy_builder
self.FillChecksumHeader = self.dummy_builder
self.bin2mot = self.dummy_builder
self.FillChecksumHeader = self.dummy_builder
self.genSizeRep = self.dummy_builder
self.cc = self.dummy_builder
self.asm = self.dummy_builder
self.ar = self.dummy_builder
self.lnk = self.dummy_builder
self.vc = self.dummy_builder
self.CompressECL = self.dummy_builder
self.aes_128_cbc = self.dummy_builder
self.GBuild = self.dummy_builder
self.GBuildIntegrity = self.dummy_builder
self.gmemfile_map_add_ROM2RAM = self.dummy_builder
self.binMerge = self.dummy_builder
self.mfc = self.dummy_builder
self.binMergeReport = self.dummy_builder
self.copy_file = self.dummy_builder
self.crc32 = self.dummy_builder
self.socwizard_batch = self.dummy_builder
self.jflasharm_batch = self.dummy_builder
self.jlink_batch = self.dummy_builder
self.multiflash_batch = self.dummy_builder
self.emerald_jl_batch = self.dummy_builder
self.emerald_jl_shell = self.dummy_builder
self.titan_jl_batch = self.dummy_builder
self.titan_jl_shell = self.dummy_builder
self.atlasl_jl_batch = self.dummy_builder
self.atlasl_jl_shell = self.dummy_builder
self.jlink_batch_eeprom = self.dummy_builder
self.OdxCreate = self.dummy_builder
self.CommandFlasherBatch = self.dummy_builder
self.CommandFlasherIni = self.dummy_builder
self.CommandFlasherBatchSeq = self.dummy_builder
self.mostContainer = self.dummy_builder
self.zip = self.dummy_builder
self.report_products = self.dummy_builder
self.flash_kombi = self.dummy_builder
@staticmethod
def dummy_builder(target, source, **env):
'''dummy for pylint'''
if target or source or env:
pass
return target
#if kwargs is not None:
# pass
#return kwargs
def __getitem__(self, key):
'''dummy for pylint'''
return self.dict[key]
def __setitem__(self, key, value):
'''dummy for pylint'''
self.dict[key] = value
def AddMethod(self, function, name=None):
'''dummy for pylint'''
pass
def AppendUnique(self, **kwargs):
'''iarARM.AppendUnique(CPPSUFFIXES = ['.dat'])'''
for d in kwargs:
print('.{} := {}'.format(d, kwargs[d]))
if d not in self.dict:
self.dict[d] = []
self.dict[d].extend(kwargs[d])
def Clone(self, **kwargs):
'''dummy for pylint'''
for key in kwargs:
self[key] = kwargs[key]
return self
def clearReadOnly(self, arg):
'''dummy for pylint'''
if self or arg:
pass
def Precious(self, arg):
'''dummy for pylint'''
if self or arg:
pass
def Command(self, target, source, action, **kw):
'''dummy for pylint'''
if self or target or source or action or kw:
pass
def multiFileCompileLink(self, out_elf, out_map, out_dnm, out_dla, in_sources, in_headers):
'''dummy for pylint'''
if self or out_elf or out_map or out_dnm or out_dla or in_sources or in_headers:
pass
def version(self, target):
'''dummy for pylint'''
if self or target:
pass
def Export(what):
'''dummy for pylint'''
assert what
def Delete(dest, must_exist=0):
'''dummy for pylint'''
if dest:
if must_exist:
pass
class ARGUMENTS_(object):
'''dummy for pylint'''
def __init__(self):
self.defaults = {}
def get(self, name, default):
'''ARGUMENTS.get('extver', ...)'''
if self or name:
pass
if name in self.defaults:
print('{} -> {}'.format(name, self.defaults[name]))
return self.defaults[name]
print('{} -> {}'.format(name, default))
return default
def set(self, name, value):
'''dummy for pylint'''
print('{} := {}'.format(name, value))
self.defaults[name] = value
ARGUMENTS = ARGUMENTS_()
def SetOption(name, value):
'''dummy for pylint'''
ARGUMENTS.set(name, value)
def GetOption(optionname):
'''dummy for pylint'''
return ARGUMENTS.get(optionname, None)
def Help(str_):
'''dummy for pylint'''
if str_:
pass
def EnsurePythonVersion(ma, mi):
'''dummy for pylint'''
if ma and mi:
pass
def EnsureSConsVersion(ma, mi):
'''dummy for pylint'''
if ma and mi:
pass
def AddOption(args, **kwargs):
'''dummy for pylint'''
# AddOption('--define', action = 'append', dest = 'compiler_defines', default = [])
if args:
pass
if 'default' in kwargs:
ARGUMENTS.set(kwargs['dest'], kwargs['default'])
def SConscript(name):
'''dummy for pylint'''
# maybe lambda x:
#name = os.path.splitext(name)[0]
#name = name.replace('\\', '.').replace('/', '.')
print('SConscript({})'.format(name))
#exec('import ' + name)
p = os.path.dirname(name)
if p != '':
sys.path.insert(0, p)
print(sys.path)
if name.endswith('.py'):
exec('import {}'.format(os.path.splitext(name)[0]))
else:
execfile(name)
def CScan():
'''dummy for pylint'''
return None
def Decider(arg):
'''dummy for pylint'''
if arg:
pass
def Progress(arg):
'''Progress('Evaluating $TARGET\n')'''
if arg:
pass
def SideEffect(side, main):
'''SideEffect(list_files + side_effects, output_elf)'''
if side or main:
pass
def Depends(main, dep):
'''Depends(output_elf, headers_other_dependencies)'''
if main or dep:
pass
def Alias(arg1, arg2):
'''dummy for pylint'''
if arg1 or arg2:
pass
def Default(arg):
'''dummy for pylint'''
if arg:
pass
def Dir(arg):
'''dummy for pylint'''
if arg:
pass
return arg
def Import(arg):
'''dummy for pylint'''
if arg == 'top_level':
raise UserError('is expected in this case.')
if arg:
pass
exec('global {}'.format(arg))
def Clean(main, to_clean):
'''dummy for pylint'''
if main or to_clean:
pass
return main
class UserError(Exception):
'''dummy for pylint'''
pass
def Exit(exitcode):
'''dummy for pylint'''
sys.exit(exitcode)
def AddPostAction(arg1, arg2):
'''dummy for pylint'''
if arg1 or arg2:
pass
scons_dummy.py.sig
(application/octet-stream, 566 B) - not displayed