Code Monkey home page Code Monkey logo

ecoindex_python's Introduction

⚠️ This project is being replaced by ecoindex_python_fullstack and will be archived soon. Please refer to the new project for any contribution or issue. ⚠️

ECOINDEX PYTHON

Quality check PyPI version

This basic module provides a simple interface to get the Ecoindex based on 3 parameters:

  • The number of DOM elements in the page
  • The size of the page
  • The number of external requests of the page

Requirements

  • Python ^3.10 with pip

Install

pip install ecoindex

Use

Get ecoindex

You can easily get the ecoindex by calling the function get_ecoindex():

(function) get_ecoindex: (dom: int, size: float, requests: int) -> Coroutine[Any, Any, Ecoindex]

Example:

import asyncio
from pprint import pprint

from ecoindex import get_ecoindex

# Get ecoindex from DOM elements, size of page and requests of the page
ecoindex = asyncio.run(get_ecoindex(dom=100, size=100, requests=100))
pprint(ecoindex)

Result example:

Ecoindex(grade='B', score=72.0, ges=1.56, water=2.34, ecoindex_version='3.0.0')

Contribute

You need poetry to install and manage dependencies. Once poetry installed, run :

poetry install

Tests

poetry run pytest

Disclaimer

The LCA values used by ecoindex to evaluate environmental impacts are not under free license - ©Frédéric Bordage Please also refer to the mentions provided in the code files for specifics on the IP regime.

ecoindex_python's People

Contributors

dependabot[bot] avatar vvatelot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

djembenj tsecher

ecoindex_python's Issues

[Bug]: selenium.common.exceptions.JavascriptException: Message: javascript error: point.offset is not a function

What happened?

Issue appears when calling

asyncio.run(get_page_analysis(url="https://www.patoutrailsaintlary.com"))

Version

^3.6

What OS do you use?

Linux

Relevant log output

Traceback (most recent call last):
  File "test.py", line 5, in <module>
    result = asyncio.run(get_page_analysis(url="https://www.patoutrailsaintlary.com"))
  File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/20100229/Devel/ecoindex_python/ecoindex/scrap.py", line 23, in get_page_analysis
    page_metrics, page_type = await scrap_page(
  File "/home/20100229/Devel/ecoindex_python/ecoindex/scrap.py", line 67, in scrap_page
    driver.execute_script(
  File "/home/20100229/.cache/pypoetry/virtualenvs/ecoindex-algVPkgo-py3.8/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 790, in execute_script
    return self.execute(command, {
  File "/home/20100229/.cache/pypoetry/virtualenvs/ecoindex-algVPkgo-py3.8/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 400, in execute
    self.error_handler.check_response(response)
  File "/home/20100229/.cache/pypoetry/virtualenvs/ecoindex-algVPkgo-py3.8/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 236, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: javascript error: point.offset is not a function
  (Session info: chrome=95.0.4638.69)
Stacktrace:
#0 0x55fc9fd00f93 <unknown>
#1 0x55fc9f7db908 <unknown>
#2 0x55fc9f7de78c <unknown>
#3 0x55fc9f7de586 <unknown>
#4 0x55fc9f7df142 <unknown>
#5 0x55fc9f842983 <unknown>
#6 0x55fc9f82ea82 <unknown>
#7 0x55fc9f841c91 <unknown>
#8 0x55fc9f82e973 <unknown>
#9 0x55fc9f804df4 <unknown>
#10 0x55fc9f805de5 <unknown>
#11 0x55fc9fd302be <unknown>
#12 0x55fc9fd45ba0 <unknown>
#13 0x55fc9fd31215 <unknown>
#14 0x55fc9fd46fe8 <unknown>
#15 0x55fc9fd259db <unknown>
#16 0x55fc9fd62218 <unknown>
#17 0x55fc9fd62398 <unknown>
#18 0x55fc9fd7d6cd <unknown>
#19 0x7f3870da4609 <unknown>

Code of Conduct

  • I agree to follow this project's Code of Conduct

Use https://github.com/cnumr/ecoindex_reference

In order to

Use the common ecoindex reference values

I want to

implement the json file in ecoindex_python library

Details

  • Adapt lib to read values from local json file
  • Manually retrieve the json file?
  • Make a command to get the latest version of json file?
  • Retrieve the latest version of json file at package install?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.