Giter VIP home page Giter VIP logo

gsheetsender's People

Contributors

beregabor avatar pethical avatar

Forkers

pethical

gsheetsender's Issues

Remove range input from cli args

After named_ranges and cell_values option added to email_config.json, the range argument is not necessary any more.

Remove the arg, and change template sample, to use only named_ranges and cell_values.

Add input validation to email_config.json fields

Add input validation to email_config.json fields:

  • template_dir: exists and contain a mail_template.html
  • send_from: an email address.
  • send_to: email address list with , separator
  • subject: not empty string
    -named_ranges: named ranges list with , separator. Syntax can read in README.MD
    -cell_values: cell value list with , separator. Syntax can read in README.MD
    -add_attachment: boolean value: true or false.
    -attachment_file_name: valid file name with xlsx extension.

Input validation run before core business logic execution. Implement in separated class.

Refact and add unit tests

Refact and add unit tests.
Separate hard dependencies from logic in different classes.

Public google sheet to unit tests.

Named ranges parameter

Add multi_range option to email_config json to add more range data read from.

named_ranges option values separete with , char.
A range syntax: [range_name]=[Sheet]![LeftTopCell]:[RightBottomCell]

The script add the multi_range dict to template rendering.
template.render(values=table_content, named_ranges=named_range_dict)

The dict will contain the values under range_name keys in dict.

named_range sample in json:

{ "template_dir": "/tmp/template", "send_from": "[email protected]", "send_to": "[email protected]", "subject": "Test mail", "add_attachment": false, "attachment_file_name": "release_plan.xlsx", "named_ranges": "customer_name=Sheet1!A1:A1,orders=Orders!A3:D" }

this sample will read 2 ranges:

  1. from Sheet1 named sheet and contain A1 cell value. This range name is customer_name.
  2. from Orders named sheet and contain the table defined A3:D cells. This range name is orders.

From template this values can use as:

{{named_ranges.customer_name[0][0]}}

{% for order in named_ranges.orders %}
{{order[0]}}
{{order[1]}}
{{order[2]}}

Cell values parameter

Add cell_values option to email_config json

syntax:
"cell_values": "value_name=Sheet1!A1,value2=Sheet1!C3"

A cell value definition syntax: [name]=[sheet_name]![Cell]
The cell values definitions are separate with ,

The script add the cell_values dict to template rendering.
template.render(values=table_content, cell_values=cell_values_dict)

The dict will contain the cell values under the cell_name key.
The script read cell values from sheet, and use this values in template rendering.

From template can use cell_values (as example above):

{{cell_values.value_name}}
{{cell_values.value2}}

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.