How to convert Flutter package to JavaScript - flutter-web

Whether it is possible to convert the entire Flutter package to JavaScript or else how to convert a single dart file to a JavaScript file. If I try to convert a single dart file to a JavaScript file using dart2js, it is failed like the main method is not found. Any idea to convert the single dart file without the main method.

Related

Confusion regarding joblib.dump()

One way to save sklearn models is to use joblib.dump(model,filename). I have a confusion regarding the filename argument. One way to run this function is through :
joblib.dump(model,"model.joblib")
This saves the model successfully and also the model is loaded correctly using the:
model=joblib.load("model.joblib")
Another way is to use :
joblib.dump(model,"model")
With no ".joblib" extension this time. This also runs successfully and the model is loaded correctly using the:
model=joblib.load("model")
What confuses me is the file extension in the filename, Is there a certain file extension that I should use for saving the model? Or it is not necessary to use a file extension as I did above? If it is not necessary, then why?
There is no file extension that "must" be used to serialize a model. You can specify the compression method by using one of the supported filename extensions (.z, .gz, .bz2, .xz or .lzma). By default joblib will use zlib to serialize objects.
Therefore you can use any file extension. However it is a good practice to use the library as the extension in order to know how to load it.
I name my serialized model model.pickle when I am using pickle library and model.joblib when I am using joblib.

how to convert IFC file to Png with Node.js

I tried to find a way to convert IFC file to PNG by his layers. The only ways that I have found are by java or c# that are not working.
Does someone dicover a way to convert it by js or python?

Best way to store XML needed for api calls in a Python Package

I have a question about where to store XML data needed for making API calls in a python package I am building. For some of the API calls in my package I need to provide a binary xml string in the request. Right now I am reading it in from the same directory that my source code is kept in. What would be the best way to store this XML for use during run time after my project has been packaged and installed through pip? I read about package_data from the setuptools package but i'm not sure how you would open the files included in there when a API call is made.
Below is an example of how I am currently executing one of these API calls. and current directory structure.
def make_api_call(self):
# line below just extracts creds for api call from db
API_CREDENTIALS = self.stage_request()
#request_input.xml contains xml needed to make request
data = open('./request_input.xml', 'rb').read()
r = requests.post(url='apiurl',data=data,auth=(API_CREDENTIALS[0], API_CREDENTIALS[1]),headers={'Content-Type': 'text/xml'})
-----Package
-------Packages
---------module1.py
---------module2.py
---------module3.py
---------request_input.xml
-----setup.py
-----README.md
To read the package data, use one of the following...
importlib.resources
pkgutil.get_data()
pkg_resources from setuptools

Python 3, can I tell if a file opened in binary mode contains text?

I am upgrading some code from python 2 to python 3.
There is a function to open and read files. In Python 2 there is no need to specify binary mode or as a string. While in Python 3 I should specify the mode.
The python 2 code is:
with open(f_path, mode=open_mode) as fp:
content = fp.read()
This is causing me problems as it is called by various other functions where I don't necessarily know the file type in advance. (Sometimes the data is written to a zip file, other times the data is returned via an HTTP endpoint).
I expect most data will be binary image files, though CSv and text files will also be present.
What would be the best way of opening a file of unknown type and detecting if it is binary or string data?
Is it possible for example to open a file in binary mode, then detect that it contains text and convert it (or alternatively generate an exception and open it in string mode instead)?
You might try the binaryornot library.
pip install binaryornot
Then in the code:
from binaryornot.check import is_binary
is_binary(f_path)
Here is their documentation:
https://pypi.org/project/binaryornot/

How to convert a string into a pyc file without using a py file?

I have a string print("hello"). I want to directly store this as a .pyc file and execute it later. How can I do this?
Take a look at the py_compile.compile and its source code to see how it is done.

Resources